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

Commit 7d42430d authored by Aaron Liu's avatar Aaron Liu
Browse files

[Bouncer] Reset y translation and alpha

When doing the appear animation, sometimes, the animation will not
complete. I am unable to repro reliably, but I have experienced the
behavior more than 3 times, and QA has seen it too.

I'm thinking that this code change will fix the issue, but it's not
guaranteed.

Bug: 228886154
Test: Manual
Change-Id: Ie6b138468e3f8ef3e27bc2e3249c0de13709ed57
parent f08f61e9
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -181,10 +181,12 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
    public void createAnimation(final View view, long delay, long duration, float translationY,
            boolean appearing, Interpolator interpolator, final Runnable endRunnable) {
        if (view != null) {
            view.setAlpha(appearing ? 0f : 1.0f);
            view.setTranslationY(appearing ? translationY : 0);
            Animator alphaAnim;
            float targetAlpha = appearing ? 1f : 0f;
            float targetTranslationY = appearing ? 0 : translationY;
            view.setAlpha(1.0f - targetAlpha);
            view.setTranslationY(translationY - targetTranslationY);
            Animator alphaAnim;

            if (view.isHardwareAccelerated()) {
                RenderNodeAnimator alphaAnimRt = new RenderNodeAnimator(RenderNodeAnimator.ALPHA,
                        targetAlpha);
@@ -205,14 +207,21 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
                    }
                });
            }
            if (endRunnable != null) {
            alphaAnim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationCancel(Animator animation) {
                    // If Animation is canceled, we want to ensure UI is reset.
                    view.setAlpha(targetAlpha);
                    view.setTranslationY(targetTranslationY);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (endRunnable != null) {
                        endRunnable.run();
                    }
                });
                }
            });
            alphaAnim.start();
            startTranslationYAnimation(view, delay, duration, appearing ? 0 : translationY,
                    interpolator);