android.view.animation.GridLayoutAnimationController Java Examples

The following examples show how to use android.view.animation.GridLayoutAnimationController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child,
        ViewGroup.LayoutParams params, int index, int count) {

    GridLayoutAnimationController.AnimationParameters animationParams =
            (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

    if (animationParams == null) {
        animationParams = new GridLayoutAnimationController.AnimationParameters();
        params.layoutAnimationParameters = animationParams;
    }

    animationParams.count = count;
    animationParams.index = index;
    animationParams.columnsCount = mNumColumns;
    animationParams.rowsCount = count / mNumColumns;

    if (!mStackFromBottom) {
        animationParams.column = index % mNumColumns;
        animationParams.row = index / mNumColumns;
    } else {
        final int invertedIndex = count - 1 - index;

        animationParams.column = mNumColumns - 1 - (invertedIndex % mNumColumns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / mNumColumns;
    }
}
 
Example #2
Source File: GridRecyclerView.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params,
                                               int index, int count) {
    final LayoutManager layoutManager = getLayoutManager();
    if (getAdapter() != null && layoutManager instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        final int columns = ((GridLayoutManager) layoutManager).getSpanCount();

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #3
Source File: RecyclerViewEmptySupport.java    From homeassist with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {
    final LayoutManager layoutManager = getLayoutManager();
    if (getAdapter() != null && layoutManager instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams = (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            // If there are no animation parameters, create new once and attach them to
            // the LayoutParams.
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        // Next we are updating the parameters

        // Set the number of items in the RecyclerView and the index of this item
        animationParams.count = count;
        animationParams.index = index;

        // Calculate the number of columns and rows in the grid
        final int columns = ((GridLayoutManager) layoutManager).getSpanCount();
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        // Calculate the column/row position in the grid
        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        // Proceed as normal if using another type of LayoutManager
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #4
Source File: StaggeredGridRecyclerView.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 支持GridLayoutManager以及StaggeredGridLayoutManager
 *
 * @param child
 * @param params
 * @param index
 * @param count
 */
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params,
                                               int index, int count) {
    LayoutManager layoutManager = this.getLayoutManager();
    if (getAdapter() != null && (layoutManager instanceof GridLayoutManager
            || layoutManager instanceof StaggeredGridLayoutManager)) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = 0;
        if (layoutManager instanceof GridLayoutManager) {
            columns = ((GridLayoutManager) layoutManager).getSpanCount();
        } else {
            columns = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
        }

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #5
Source File: GridRecyclerView.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager){

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #6
Source File: EndlessRecyclerView.java    From materialup with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && false) {
        LayoutManager manager = getLayoutManager();

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = 1;
        if (manager instanceof GridLayoutManager) {
            columns = ((GridLayoutManager) manager).getSpanCount();
        }

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #7
Source File: CustomGridRecyclerView.java    From journaldev with MIT License 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #8
Source File: GridRecyclerView.java    From material-activity-chooser with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, @NonNull ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();


        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns + 1;

        animationParams.column = index % columns;
        animationParams.row = index % columns + index / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #9
Source File: GridRecyclerView.java    From cv4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, @NonNull ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #10
Source File: BaseRecyclerView.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && false) {
        LayoutManager manager = getLayoutManager();

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = 1;
        if (manager instanceof GridLayoutManager) {
            columns = ((GridLayoutManager) manager).getSpanCount();
        }

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #11
Source File: TwoWayGridView.java    From recent-images with MIT License 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child,
		ViewGroup.LayoutParams params, int index, int count) {

	GridLayoutAnimationController.AnimationParameters animationParams =
		(GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

	if (animationParams == null) {
		animationParams = new GridLayoutAnimationController.AnimationParameters();
		params.layoutAnimationParameters = animationParams;
	}

	animationParams.count = count;
	animationParams.index = index;
	animationParams.columnsCount = mNumColumns;
	animationParams.rowsCount = count / mNumColumns;

	if (!mStackFromBottom) {
		animationParams.column = index % mNumColumns;
		animationParams.row = index / mNumColumns;
	} else {
		final int invertedIndex = count - 1 - index;

		animationParams.column = mNumColumns - 1 - (invertedIndex % mNumColumns);
		animationParams.row = animationParams.rowsCount - 1 - invertedIndex / mNumColumns;
	}
}
 
Example #12
Source File: GridRecyclerView.java    From MaterializeYourApp with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachLayoutAnimationParameters(View child, @NonNull ViewGroup.LayoutParams params, int index, int count) {

    if (getAdapter() != null && getLayoutManager() instanceof GridLayoutManager) {

        GridLayoutAnimationController.AnimationParameters animationParams =
                (GridLayoutAnimationController.AnimationParameters) params.layoutAnimationParameters;

        if (animationParams == null) {
            animationParams = new GridLayoutAnimationController.AnimationParameters();
            params.layoutAnimationParameters = animationParams;
        }

        int columns = ((GridLayoutManager) getLayoutManager()).getSpanCount();

        animationParams.count = count;
        animationParams.index = index;
        animationParams.columnsCount = columns;
        animationParams.rowsCount = count / columns;

        final int invertedIndex = count - 1 - index;
        animationParams.column = columns - 1 - (invertedIndex % columns);
        animationParams.row = animationParams.rowsCount - 1 - invertedIndex / columns;

    } else {
        super.attachLayoutAnimationParameters(child, params, index, count);
    }
}
 
Example #13
Source File: GridLayoutAnimationControllerAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public GridLayoutAnimationControllerAssert(GridLayoutAnimationController actual) {
  super(actual, GridLayoutAnimationControllerAssert.class);
}