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

Commit 5bc04e67 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Protecting QSB scroll while transition animation is running." into ub-launcher3-calgary

parents c80a024f c553c33a
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ public class Workspace extends PagedView
    // Total over scrollX in the overlay direction.
    private float mOverlayTranslation;
    private int mFirstPageScrollX;
    private boolean mIgnoreQsbScroll;

    // Handles workspace state transitions
    private WorkspaceStateTransitionAnimation mStateTransitionAnimation;
@@ -1384,9 +1385,11 @@ public class Workspace extends PagedView
    }

    private void onWorkspaceOverallScrollChanged() {
        if (!mIgnoreQsbScroll) {
            mLauncher.getQsbContainer().setTranslationX(
                    mOverlayTranslation + mFirstPageScrollX - getScrollX());
        }
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
@@ -1797,6 +1800,33 @@ public class Workspace extends PagedView
        super.onLayout(changed, left, top, right, bottom);
        mFirstPageScrollX = getScrollForPage(0);
        onWorkspaceOverallScrollChanged();

        final LayoutTransition transition = getLayoutTransition();
        // If the transition is running defer updating max scroll, as some empty pages could
        // still be present, and a max scroll change could cause sudden jumps in scroll.
        if (transition != null && transition.isRunning()) {
            transition.addTransitionListener(new LayoutTransition.TransitionListener() {

                @Override
                public void startTransition(LayoutTransition transition, ViewGroup container,
                                            View view, int transitionType) {
                    mIgnoreQsbScroll = true;
                }

                @Override
                public void endTransition(LayoutTransition transition, ViewGroup container,
                                          View view, int transitionType) {
                    // Wait until all transitions are complete.
                    if (!transition.isRunning()) {
                        mIgnoreQsbScroll = false;
                        transition.removeTransitionListener(this);
                        mFirstPageScrollX = getScrollForPage(0);
                        onWorkspaceOverallScrollChanged();
                    }
                }
            });
        }

    }

    @Override