Add springs when user clicks on caret / all apps snaps to top.

Bug: 65373058
Change-Id: I9cc5c4c98fd3e5b53d597c4493f2dcef6d9be94a
This commit is contained in:
Jon Miranda
2017-09-05 11:32:13 -07:00
committed by Jonathan Miranda
parent 2021828034
commit 610af37575
2 changed files with 24 additions and 1 deletions

View File

@@ -394,6 +394,11 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect
animationOut.play(driftAndAlpha);
animationOut.addListener(new AnimatorListenerAdapter() {
// Spring values used when the user has not flung all apps.
private final float MAX_RELEASE_VELOCITY = 10000;
// The delay (as a % of the animation duration) to start the springs.
private final float DELAY = 0.3f;
boolean canceled = false;
@Override
@@ -401,6 +406,21 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect
canceled = true;
}
@Override
public void onAnimationStart(Animator animation) {
// Add springs for cases where the user has not flung.
// ie. clicking on the caret, releasing all apps so it snaps up.
mAppsView.postDelayed(new Runnable() {
@Override
public void run() {
if (!canceled && !mSpringAnimationHandler.isRunning()) {
float velocity = mProgress * MAX_RELEASE_VELOCITY;
mSpringAnimationHandler.animateToPositionWithVelocity(0, 1, velocity);
}
}
}, (long) (mAnimationDuration * DELAY));
}
@Override
public void onAnimationEnd(Animator animation) {
if (canceled) {