AppearAnimationUtilspublic class AppearAnimationUtils extends Object implements AppearAnimationCreatorA class to make nice appear transitions for views in a tabular layout. |
Fields Summary |
---|
public static final long | DEFAULT_APPEAR_DURATION | private final android.view.animation.Interpolator | mInterpolator | private final float | mStartTranslation | private final AppearAnimationProperties | mProperties | protected final float | mDelayScale | private final long | mDuration | protected boolean | mScaleTranslationWithRow | protected boolean | mAppearing |
Constructors Summary |
---|
public AppearAnimationUtils(android.content.Context ctx)
this(ctx, DEFAULT_APPEAR_DURATION,
1.0f, 1.0f,
AnimationUtils.loadInterpolator(ctx, android.R.interpolator.linear_out_slow_in));
| public AppearAnimationUtils(android.content.Context ctx, long duration, float translationScaleFactor, float delayScaleFactor, android.view.animation.Interpolator interpolator)
mInterpolator = interpolator;
mStartTranslation = ctx.getResources().getDimensionPixelOffset(
R.dimen.appear_y_translation_start) * translationScaleFactor;
mDelayScale = delayScaleFactor;
mDuration = duration;
mScaleTranslationWithRow = false;
mAppearing = true;
|
Methods Summary |
---|
protected long | calculateDelay(int row, int col)
return (long) ((row * 40 + col * (Math.pow(row, 0.4) + 0.4) * 20) * mDelayScale);
| public void | createAnimation(android.view.View view, long delay, long duration, float translationY, boolean appearing, android.view.animation.Interpolator interpolator, java.lang.Runnable endRunnable)
if (view != null) {
view.setAlpha(appearing ? 0f : 1.0f);
view.setTranslationY(appearing ? translationY : 0);
view.animate()
.alpha(appearing ? 1f : 0f)
.translationY(appearing ? 0 : translationY)
.setInterpolator(interpolator)
.setDuration(duration)
.setStartDelay(delay);
if (view.hasOverlappingRendering()) {
view.animate().withLayer();
}
if (endRunnable != null) {
view.animate().withEndAction(endRunnable);
}
}
| private com.android.keyguard.AppearAnimationUtils$AppearAnimationProperties | getDelays(T[][] items)
long maxDelay = -1;
mProperties.maxDelayColIndex = -1;
mProperties.maxDelayRowIndex = -1;
mProperties.delays = new long[items.length][];
for (int row = 0; row < items.length; row++) {
T[] columns = items[row];
mProperties.delays[row] = new long[columns.length];
for (int col = 0; col < columns.length; col++) {
long delay = calculateDelay(row, col);
mProperties.delays[row][col] = delay;
if (items[row][col] != null && delay > maxDelay) {
maxDelay = delay;
mProperties.maxDelayColIndex = col;
mProperties.maxDelayRowIndex = row;
}
}
}
return mProperties;
| private com.android.keyguard.AppearAnimationUtils$AppearAnimationProperties | getDelays(T[] items)
long maxDelay = -1;
mProperties.maxDelayColIndex = -1;
mProperties.maxDelayRowIndex = -1;
mProperties.delays = new long[items.length][];
for (int row = 0; row < items.length; row++) {
mProperties.delays[row] = new long[1];
long delay = calculateDelay(row, 0);
mProperties.delays[row][0] = delay;
if (items[row] != null && delay > maxDelay) {
maxDelay = delay;
mProperties.maxDelayColIndex = 0;
mProperties.maxDelayRowIndex = row;
}
}
return mProperties;
| public android.view.animation.Interpolator | getInterpolator()
return mInterpolator;
| public float | getStartTranslation()
return mStartTranslation;
| public void | startAnimation(android.view.View[][] objects, java.lang.Runnable finishListener)
startAnimation(objects, finishListener, this);
| public void | startAnimation(android.view.View[] objects, java.lang.Runnable finishListener)
startAnimation(objects, finishListener, this);
| public void | startAnimation(T[][] objects, java.lang.Runnable finishListener, AppearAnimationCreator creator)
AppearAnimationProperties properties = getDelays(objects);
startAnimations(properties, objects, finishListener, creator);
| public void | startAnimation(T[] objects, java.lang.Runnable finishListener, AppearAnimationCreator creator)
AppearAnimationProperties properties = getDelays(objects);
startAnimations(properties, objects, finishListener, creator);
| private void | startAnimations(com.android.keyguard.AppearAnimationUtils$AppearAnimationProperties properties, T[] objects, java.lang.Runnable finishListener, AppearAnimationCreator creator)
if (properties.maxDelayRowIndex == -1 || properties.maxDelayColIndex == -1) {
finishListener.run();
return;
}
for (int row = 0; row < properties.delays.length; row++) {
long[] columns = properties.delays[row];
long delay = columns[0];
Runnable endRunnable = null;
if (properties.maxDelayRowIndex == row && properties.maxDelayColIndex == 0) {
endRunnable = finishListener;
}
creator.createAnimation(objects[row], delay, mDuration,
mStartTranslation, true /* appearing */, mInterpolator, endRunnable);
}
| private void | startAnimations(com.android.keyguard.AppearAnimationUtils$AppearAnimationProperties properties, T[][] objects, java.lang.Runnable finishListener, AppearAnimationCreator creator)
if (properties.maxDelayRowIndex == -1 || properties.maxDelayColIndex == -1) {
finishListener.run();
return;
}
for (int row = 0; row < properties.delays.length; row++) {
long[] columns = properties.delays[row];
float translation = mScaleTranslationWithRow
? (float) (Math.pow((properties.delays.length - row), 2)
/ properties.delays.length * mStartTranslation)
: mStartTranslation;
for (int col = 0; col < columns.length; col++) {
long delay = columns[col];
Runnable endRunnable = null;
if (properties.maxDelayRowIndex == row && properties.maxDelayColIndex == col) {
endRunnable = finishListener;
}
creator.createAnimation(objects[row][col], delay, mDuration,
mAppearing ? translation : -translation,
mAppearing, mInterpolator, endRunnable);
}
}
|
|