use of android.view.animation.PathInterpolator in project android_frameworks_base by DirtyUnicorns.
the class VolumeDialogMotion method startShowAnimation.
private void startShowAnimation() {
if (D.BUG)
Log.d(TAG, "startShowAnimation");
mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mChevronPositionAnimator == null)
return;
// reposition chevron
final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
final int posY = chevronPosY();
mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
}
}).start();
mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled)
return;
if (D.BUG)
Log.d(TAG, "show.onAnimationEnd");
setShowing(false);
}
@Override
public void onAnimationCancel(Animator animation) {
if (D.BUG)
Log.d(TAG, "show.onAnimationCancel");
mCancelled = true;
}
});
mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (Float) animation.getAnimatedValue();
mContents.setTranslationY(v + -mDialogView.getTranslationY());
}
});
mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
mContentsPositionAnimator.start();
mContents.setAlpha(0);
mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
mChevronPositionAnimator.start();
mChevron.setAlpha(0);
mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
use of android.view.animation.PathInterpolator in project android_frameworks_base by AOSPA.
the class FlingAnimationUtils method getDismissingProperties.
private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) {
float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
float diff = Math.abs(endValue - currValue);
float velAbs = Math.abs(velocity);
float y2 = calculateLinearOutFasterInY2(velAbs);
float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
float durationSeconds = startGradient * diff / velAbs;
if (durationSeconds <= maxLengthSeconds) {
mAnimatorProperties.interpolator = mLinearOutFasterIn;
} else if (velAbs >= mMinVelocityPxPerSecond) {
// Cross fade between linear-out-faster-in and linear interpolator with current
// velocity.
durationSeconds = maxLengthSeconds;
VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff);
InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(velocityInterpolator, mLinearOutFasterIn, mLinearOutSlowIn);
mAnimatorProperties.interpolator = superInterpolator;
} else {
// Just use a normal interpolator which doesn't take the velocity into account.
durationSeconds = maxLengthSeconds;
mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
}
mAnimatorProperties.duration = (long) (durationSeconds * 1000);
return mAnimatorProperties;
}
use of android.view.animation.PathInterpolator in project android_frameworks_base by crdroidandroid.
the class FlingAnimationUtils method getDismissingProperties.
private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) {
float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
float diff = Math.abs(endValue - currValue);
float velAbs = Math.abs(velocity);
float y2 = calculateLinearOutFasterInY2(velAbs);
float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
float durationSeconds = startGradient * diff / velAbs;
if (durationSeconds <= maxLengthSeconds) {
mAnimatorProperties.interpolator = mLinearOutFasterIn;
} else if (velAbs >= mMinVelocityPxPerSecond) {
// Cross fade between linear-out-faster-in and linear interpolator with current
// velocity.
durationSeconds = maxLengthSeconds;
VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff);
InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(velocityInterpolator, mLinearOutFasterIn, mLinearOutSlowIn);
mAnimatorProperties.interpolator = superInterpolator;
} else {
// Just use a normal interpolator which doesn't take the velocity into account.
durationSeconds = maxLengthSeconds;
mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
}
mAnimatorProperties.duration = (long) (durationSeconds * 1000);
return mAnimatorProperties;
}
use of android.view.animation.PathInterpolator in project android_frameworks_base by crdroidandroid.
the class VolumeDialogMotion method startShowAnimation.
private void startShowAnimation() {
if (D.BUG)
Log.d(TAG, "startShowAnimation");
mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mChevronPositionAnimator == null)
return;
// reposition chevron
final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
final int posY = chevronPosY();
mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
}
}).start();
mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled)
return;
if (D.BUG)
Log.d(TAG, "show.onAnimationEnd");
setShowing(false);
}
@Override
public void onAnimationCancel(Animator animation) {
if (D.BUG)
Log.d(TAG, "show.onAnimationCancel");
mCancelled = true;
}
});
mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (Float) animation.getAnimatedValue();
mContents.setTranslationY(v + -mDialogView.getTranslationY());
}
});
mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
mContentsPositionAnimator.start();
mContents.setAlpha(0);
mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
mChevronPositionAnimator.start();
mChevron.setAlpha(0);
mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
use of android.view.animation.PathInterpolator in project android_frameworks_base by AOSPA.
the class VolumeDialogMotion method startShowAnimation.
private void startShowAnimation() {
if (D.BUG)
Log.d(TAG, "startShowAnimation");
mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mChevronPositionAnimator == null)
return;
// reposition chevron
final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
final int posY = chevronPosY();
mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
}
}).start();
mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled)
return;
if (D.BUG)
Log.d(TAG, "show.onAnimationEnd");
setShowing(false);
}
@Override
public void onAnimationCancel(Animator animation) {
if (D.BUG)
Log.d(TAG, "show.onAnimationCancel");
mCancelled = true;
}
});
mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (Float) animation.getAnimatedValue();
mContents.setTranslationY(v + -mDialogView.getTranslationY());
}
});
mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
mContentsPositionAnimator.start();
mContents.setAlpha(0);
mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
mChevronPositionAnimator.start();
mChevron.setAlpha(0);
mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
Aggregations