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

Commit 53327568 authored by Fengjiang Li's avatar Fengjiang Li
Browse files

[Folder] Fix bug where folder name and page indicator is visible when...

[Folder] Fix bug where folder name and page indicator is visible when cancelling folder open animation

We should resgiter all AnimatorListeners before starting folder open animation.

Fix: 282158620
Test: https://b.corp.google.com/issues/282822254#comment2
Change-Id: I1136ede464f37c174296921594ef887d90844eb5
parent c80d0221
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -558,7 +558,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                .inflate(R.layout.user_folder_icon_normalized, null);
    }

    private void startAnimation(final AnimatorSet a) {
    private void addAnimationStartListeners(AnimatorSet a) {
        mLauncherDelegate.forEachVisibleWorkspacePage(
                visiblePage -> addAnimatorListenerForPage(a, (CellLayout) visiblePage));

@@ -574,7 +574,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                mCurrentAnimator = null;
            }
        });
        a.start();
    }

    private void addAnimatorListenerForPage(AnimatorSet a, CellLayout currentCellLayout) {
@@ -734,10 +733,14 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo

        mPageIndicator.stopAllAnimations();

        // b/282158620 because setCurrentPlayTime() below will start animator, we need to register
        // {@link AnimatorListener} before it so that {@link AnimatorListener#onAnimationStart} can
        // be called to register mCurrentAnimator, which will be used to cancel animator
        addAnimationStartListeners(anim);
        // Because t=0 has the folder match the folder icon, we can skip the
        // first frame and have the same movement one frame earlier.
        anim.setCurrentPlayTime(Math.min(getSingleFrameMs(getContext()), anim.getTotalDuration()));
        startAnimation(anim);
        anim.start();

        // Make sure the folder picks up the last drag move even if the finger doesn't move.
        if (mDragController.isDragging()) {
@@ -815,7 +818,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                mIsAnimatingClosed = false;
            }
        });
        startAnimation(a);
        addAnimationStartListeners(a);
        a.start();
    }

    @Override