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

Commit 723f1f99 authored by Mady Mellor's avatar Mady Mellor
Browse files

Clean up animation listener when translating notification

The listener only needs to be added to one of the translating views
but was added to all of them, this CL changes it to add to the
listener to the first view.

This CL also handles cancelling the animation.

Change-Id: Ifda0f7f04bae1608250e9d2f008b4f21c1745bc6
parent 466b702c
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -745,6 +745,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {

    public Animator getTranslateViewAnimator(final float leftTarget,
            AnimatorUpdateListener listener) {
        if (mTranslateAnim != null) {
            mTranslateAnim.cancel();
        }
        if (areGutsExposed()) {
            // No translation if guts are exposed.
            return null;
@@ -769,19 +772,27 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
                    if (listener != null) {
                        translateAnim.addUpdateListener(listener);
                    }
                }
                    translateAnim.addListener(new AnimatorListenerAdapter() {
                        boolean cancelled = false;

                        @Override
                        public void onAnimationCancel(Animator anim) {
                            cancelled = true;
                        }

                        @Override
                        public void onAnimationEnd(Animator anim) {
                        if (mSettingsIconRow != null && leftTarget == 0) {
                            if (!cancelled && mSettingsIconRow != null && leftTarget == 0) {
                                mSettingsIconRow.resetState();
                        }
                                mTranslateAnim = null;
                            }
                        }
                    });
                }
                set.play(translateAnim);
            }
        }
        mTranslateAnim = set;
        return set;
    }