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

Commit 28b3ecca authored by George Mount's avatar George Mount
Browse files

Reset transitionAlpha when the transition is stopped early.

Bug 19273502

When a transition runs several animators and is interrupted,
some animators may not have been started. Those animators
that haven't been started will not reset their contents
the same as if the animator was canceled. Fade modifies
transitionAlpha and if it is interrupted prior to the
animator starting, the transitionAlpha doesn't get reset.

Change-Id: I8a49b4fbb7151aadc43d7b10e6acbae9578e5cc4
parent ec3c97d2
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class Fade extends Visibility {
    /**
     * Utility method to handle creating and running the Animator.
     */
    private Animator createAnimation(View view, float startAlpha, float endAlpha) {
    private Animator createAnimation(final View view, float startAlpha, final float endAlpha) {
        if (startAlpha == endAlpha) {
            return null;
        }
@@ -117,9 +117,15 @@ public class Fade extends Visibility {
        if (DBG) {
            Log.d(LOG_TAG, "Created animator " + anim);
        }
        FadeAnimatorListener listener = new FadeAnimatorListener(view);
        final FadeAnimatorListener listener = new FadeAnimatorListener(view);
        anim.addListener(listener);
        anim.addPauseListener(listener);
        addListener(new TransitionListenerAdapter() {
            @Override
            public void onTransitionEnd(Transition transition) {
                view.setTransitionAlpha(1);
            }
        });
        return anim;
    }

@@ -143,7 +149,6 @@ public class Fade extends Visibility {

    private static class FadeAnimatorListener extends AnimatorListenerAdapter {
        private final View mView;
        private boolean mCanceled = false;
        private float mPausedAlpha = -1;
        private boolean mLayerTypeChanged = false;

@@ -159,19 +164,9 @@ public class Fade extends Visibility {
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
            mCanceled = true;
            if (mPausedAlpha >= 0) {
                mView.setTransitionAlpha(mPausedAlpha);
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (!mCanceled) {
            mView.setTransitionAlpha(1);
            }
            if (mLayerTypeChanged) {
                mView.setLayerType(View.LAYER_TYPE_NONE, null);
            }