Fields Summary |
---|
public static final int | DIRECTION_LEFT_TO_RIGHTAnimates the children starting from the left of the grid to the right. |
public static final int | DIRECTION_RIGHT_TO_LEFTAnimates the children starting from the right of the grid to the left. |
public static final int | DIRECTION_TOP_TO_BOTTOMAnimates the children starting from the top of the grid to the bottom. |
public static final int | DIRECTION_BOTTOM_TO_TOPAnimates the children starting from the bottom of the grid to the top. |
public static final int | DIRECTION_HORIZONTAL_MASKBitmask used to retrieve the horizontal component of the direction. |
public static final int | DIRECTION_VERTICAL_MASKBitmask used to retrieve the vertical component of the direction. |
public static final int | PRIORITY_NONERows and columns are animated at the same time. |
public static final int | PRIORITY_COLUMNColumns are animated first. |
public static final int | PRIORITY_ROWRows are animated first. |
private float | mColumnDelay |
private float | mRowDelay |
private int | mDirection |
private int | mDirectionPriority |
Constructors Summary |
---|
public GridLayoutAnimationController(android.content.Context context, android.util.AttributeSet attrs)Creates a new grid layout animation controller from external resources.
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.GridLayoutAnimation);
Animation.Description d = Animation.Description.parseValue(
a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_columnDelay));
mColumnDelay = d.value;
d = Animation.Description.parseValue(
a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_rowDelay));
mRowDelay = d.value;
//noinspection PointlessBitwiseExpression
mDirection = a.getInt(com.android.internal.R.styleable.GridLayoutAnimation_direction,
DIRECTION_LEFT_TO_RIGHT | DIRECTION_TOP_TO_BOTTOM);
mDirectionPriority = a.getInt(com.android.internal.R.styleable.GridLayoutAnimation_directionPriority,
PRIORITY_NONE);
a.recycle();
|
public GridLayoutAnimationController(Animation animation)Creates a new layout animation controller with a delay of 50%
for both rows and columns and the specified animation.
this(animation, 0.5f, 0.5f);
|
public GridLayoutAnimationController(Animation animation, float columnDelay, float rowDelay)Creates a new layout animation controller with the specified delays
and the specified animation.
super(animation);
mColumnDelay = columnDelay;
mRowDelay = rowDelay;
|
Methods Summary |
---|
public float | getColumnDelay()Returns the delay by which the children's animation are offset from one
column to the other. The delay is expressed as a fraction of the
animation duration.
return mColumnDelay;
|
protected long | getDelayForView(android.view.View view){@inheritDoc}
ViewGroup.LayoutParams lp = view.getLayoutParams();
AnimationParameters params = (AnimationParameters) lp.layoutAnimationParameters;
if (params == null) {
return 0;
}
final int column = getTransformedColumnIndex(params);
final int row = getTransformedRowIndex(params);
final int rowsCount = params.rowsCount;
final int columnsCount = params.columnsCount;
final long duration = mAnimation.getDuration();
final float columnDelay = mColumnDelay * duration;
final float rowDelay = mRowDelay * duration;
float totalDelay;
long viewDelay;
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
switch (mDirectionPriority) {
case PRIORITY_COLUMN:
viewDelay = (long) (row * rowDelay + column * rowsCount * rowDelay);
totalDelay = rowsCount * rowDelay + columnsCount * rowsCount * rowDelay;
break;
case PRIORITY_ROW:
viewDelay = (long) (column * columnDelay + row * columnsCount * columnDelay);
totalDelay = columnsCount * columnDelay + rowsCount * columnsCount * columnDelay;
break;
case PRIORITY_NONE:
default:
viewDelay = (long) (column * columnDelay + row * rowDelay);
totalDelay = columnsCount * columnDelay + rowsCount * rowDelay;
break;
}
float normalizedDelay = viewDelay / totalDelay;
normalizedDelay = mInterpolator.getInterpolation(normalizedDelay);
return (long) (normalizedDelay * totalDelay);
|
public int | getDirection()Returns the direction of the animation. {@link #DIRECTION_HORIZONTAL_MASK}
and {@link #DIRECTION_VERTICAL_MASK} can be used to retrieve the
horizontal and vertical components of the direction.
return mDirection;
|
public int | getDirectionPriority()Returns the direction priority for the animation. The priority can
be either {@link #PRIORITY_NONE}, {@link #PRIORITY_COLUMN} or
{@link #PRIORITY_ROW}.
return mDirectionPriority;
|
public float | getRowDelay()Returns the delay by which the children's animation are offset from one
row to the other. The delay is expressed as a fraction of the
animation duration.
return mRowDelay;
|
private int | getTransformedColumnIndex(android.view.animation.GridLayoutAnimationController$AnimationParameters params)
int index;
switch (getOrder()) {
case ORDER_REVERSE:
index = params.columnsCount - 1 - params.column;
break;
case ORDER_RANDOM:
if (mRandomizer == null) {
mRandomizer = new Random();
}
index = (int) (params.columnsCount * mRandomizer.nextFloat());
break;
case ORDER_NORMAL:
default:
index = params.column;
break;
}
int direction = mDirection & DIRECTION_HORIZONTAL_MASK;
if (direction == DIRECTION_RIGHT_TO_LEFT) {
index = params.columnsCount - 1 - index;
}
return index;
|
private int | getTransformedRowIndex(android.view.animation.GridLayoutAnimationController$AnimationParameters params)
int index;
switch (getOrder()) {
case ORDER_REVERSE:
index = params.rowsCount - 1 - params.row;
break;
case ORDER_RANDOM:
if (mRandomizer == null) {
mRandomizer = new Random();
}
index = (int) (params.rowsCount * mRandomizer.nextFloat());
break;
case ORDER_NORMAL:
default:
index = params.row;
break;
}
int direction = mDirection & DIRECTION_VERTICAL_MASK;
if (direction == DIRECTION_BOTTOM_TO_TOP) {
index = params.rowsCount - 1 - index;
}
return index;
|
public void | setColumnDelay(float columnDelay)Sets the delay, as a fraction of the animation duration, by which the
children's animations are offset from one column to the other.
mColumnDelay = columnDelay;
|
public void | setDirection(int direction)Sets the direction of the animation. The direction is expressed as an
integer containing a horizontal and vertical component. For instance,
DIRECTION_BOTTOM_TO_TOP | DIRECTION_RIGHT_TO_LEFT .
mDirection = direction;
|
public void | setDirectionPriority(int directionPriority)Specifies the direction priority of the animation. For instance,
{@link #PRIORITY_COLUMN} will give priority to columns: the animation
will first play on the column, then on the rows.Z
mDirectionPriority = directionPriority;
|
public void | setRowDelay(float rowDelay)Sets the delay, as a fraction of the animation duration, by which the
children's animations are offset from one row to the other.
mRowDelay = rowDelay;
|
public boolean | willOverlap(){@inheritDoc}
return mColumnDelay < 1.0f || mRowDelay < 1.0f;
|