From c553c33ae6824cf9b2f3274a9a5d275445ac1968 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 20 Jul 2016 11:18:25 -0700 Subject: [PATCH] Protecting QSB scroll while transition animation is running. During transition animation the qorkspace scroll changes while the actual workspace UI is mostly stable. This causes the QSB to animate while the pages are not changing. Bug: 30229069 Change-Id: I66ec41276c0e26164d20da6a5e0e251975390428 --- src/com/android/launcher3/Workspace.java | 36 +++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 78ef074c53..201f0cb59d 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -53,11 +53,9 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; import android.view.accessibility.AccessibilityManager; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; -import android.widget.Space; import android.widget.TextView; import com.android.launcher3.Launcher.CustomContentCallbacks; @@ -315,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; @@ -1395,8 +1394,10 @@ public class Workspace extends PagedView } private void onWorkspaceOverallScrollChanged() { - mLauncher.getQsbContainer().setTranslationX( - mOverlayTranslation + mFirstPageScrollX - getScrollX()); + if (!mIgnoreQsbScroll) { + mLauncher.getQsbContainer().setTranslationX( + mOverlayTranslation + mFirstPageScrollX - getScrollX()); + } } @Override @@ -1805,6 +1806,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