Merge "Fix slow dismiss animation" into nyc-dev am: 5ba429c

am: 8df9ad6

* commit '8df9ad60d03fe4dafad11a6ad78541baf61cfa6c':
  Fix slow dismiss animation

Change-Id: Ie891215f7ffc0b283c4576aec26ef4ea8f060d81
This commit is contained in:
Mady Mellor
2016-04-04 23:38:46 +00:00
committed by android-build-merger
2 changed files with 14 additions and 11 deletions

View File

@@ -325,10 +325,11 @@ public class SwipeHelper implements Gefingerpoken {
/**
* @param view The view to be dismissed
* @param velocity The desired pixels/second speed at which the view should move
* @param useAccelerateInterpolator Should an accelerating Interpolator be used
*/
public void dismissChild(final View view, float velocity) {
public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) {
dismissChild(view, velocity, null /* endAction */, 0 /* delay */,
velocity == 0 /* useAccelerateInterpolator */, 0 /* fixedDuration */);
useAccelerateInterpolator, 0 /* fixedDuration */);
}
/**
@@ -569,7 +570,8 @@ public class SwipeHelper implements Gefingerpoken {
if (!handleUpEvent(ev, mCurrView, velocity, getTranslation(mCurrView))) {
if (isDismissGesture(ev)) {
// flingadingy
dismissChild(mCurrView, swipedFastEnough() ? velocity : 0f);
dismissChild(mCurrView, velocity,
!swipedFastEnough() /* useAccelerateInterpolator */);
} else {
// snappity
mCallback.onDragCancelled(mCurrView);
@@ -615,11 +617,9 @@ public class SwipeHelper implements Gefingerpoken {
protected boolean swipedFastEnough() {
float velocity = getVelocity(mVelocityTracker);
float perpendicularVelocity = getPerpendicularVelocity(mVelocityTracker);
float translation = getTranslation(mCurrView);
boolean ret = (Math.abs(velocity) > getEscapeVelocity()) &&
(Math.abs(velocity) > Math.abs(perpendicularVelocity)) &&
(velocity > 0) == (translation > 0);
boolean ret = (Math.abs(velocity) > getEscapeVelocity())
&& (velocity > 0) == (translation > 0);
return ret;
}

View File

@@ -3548,8 +3548,9 @@ public class NotificationStackScrollLayout extends ViewGroup
}
@Override
public void dismissChild(final View view, float velocity) {
super.dismissChild(view, velocity);
public void dismissChild(final View view, float velocity,
boolean useAccelerateInterpolator) {
super.dismissChild(view, velocity, useAccelerateInterpolator);
cancelCheckForDrag();
setSnappedToGear(false);
}
@@ -3585,7 +3586,8 @@ public class NotificationStackScrollLayout extends ViewGroup
snapChild(animView, 0 /* leftTarget */, velocity);
} else if (isDismissGesture(ev)) {
// Gesture is a dismiss that's not towards the gear
dismissChild(animView, swipedFastEnough() ? velocity : 0f);
dismissChild(animView, velocity,
!swipedFastEnough() /* useAccelerateInterpolator */);
} else {
// Didn't move enough to dismiss or cover, snap to the gear
snapToGear(animView, velocity);
@@ -3610,7 +3612,8 @@ public class NotificationStackScrollLayout extends ViewGroup
private void dismissOrSnapBack(View animView, float velocity, MotionEvent ev) {
if (isDismissGesture(ev)) {
dismissChild(animView, swipedFastEnough() ? velocity : 0f);
dismissChild(animView, velocity,
!swipedFastEnough() /* useAccelerateInterpolator */);
} else {
snapChild(animView, 0 /* leftTarget */, velocity);
}