Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ba429c4 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Fix slow dismiss animation" into nyc-dev

parents 18d2b324 dc6c97df
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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;
    }

+7 −4
Original line number Diff line number Diff line
@@ -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);
            }