From bc2f082dac475eff7fc0e40f90eb6c0552511170 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Fri, 26 Oct 2012 17:59:53 -0700 Subject: [PATCH] Stop animating All Apps during transition to Home One of the sources of jank in launcher is during the All Apps -> Home transition. specifically, if the user has started a fling operation (where we are animating between pages in All Apps) and then hits the Home button, we continue the fling animation while also doing the transition to Home scale/fade animations. This causes a lot of work for launcher, particularly because the fling animation is causing the All Apps layer to get recreated on every frame. The fix is to simply pause the fling animation, then snap to its end state when the animation to Home is complete. We also need to pause/snap the scroll indicator animation, because it's fading animation causes the same layer-recreation jank that the fling itself causes. Issue #7387124 Home <-> All Apps transition animation is janky while flinging Change-Id: Icbcaf2d5b3b2f6ce8fd7419419d258248aa1475b --- src/com/android/launcher2/Launcher.java | 3 +++ src/com/android/launcher2/PagedView.java | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 56fdbb60cc..b2fbb3e608 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2682,6 +2682,7 @@ public final class Launcher extends Activity dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); + mAppsCustomizeContent.pauseScrolling(); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override @@ -2696,6 +2697,8 @@ public final class Launcher extends Activity if (onCompleteRunnable != null) { onCompleteRunnable.run(); } + mAppsCustomizeContent.updateCurrentPageScroll(); + mAppsCustomizeContent.resumeScrolling(); } }); diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 9b973847c4..81ce6ea236 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -181,6 +181,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc protected static final int sScrollIndicatorFadeInDuration = 150; protected static final int sScrollIndicatorFadeOutDuration = 650; protected static final int sScrollIndicatorFlashDuration = 650; + private boolean mScrollingPaused = false; // If set, will defer loading associated pages until the scrolling settles private boolean mDeferLoadAssociatedPagesUntilScrollCompletes; @@ -303,6 +304,24 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mScroller.forceFinished(true); } + /** + * Called during AllApps/Home transitions to avoid unnecessary work. When that other animation + * ends, {@link #resumeScrolling()} should be called, along with + * {@link #updateCurrentPageScroll()} to correctly set the final state and re-enable scrolling. + */ + void pauseScrolling() { + mScroller.forceFinished(true); + cancelScrollingIndicatorAnimations(); + mScrollingPaused = true; + } + + /** + * Enables scrolling again. + * @see #pauseScrolling() + */ + void resumeScrolling() { + mScrollingPaused = false; + } /** * Sets the current page. */ @@ -1743,7 +1762,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc updateScrollingIndicatorPosition(); mScrollIndicator.setVisibility(View.VISIBLE); cancelScrollingIndicatorAnimations(); - if (immediately) { + if (immediately || mScrollingPaused) { mScrollIndicator.setAlpha(1f); } else { mScrollIndicatorAnimator = LauncherAnimUtils.ofFloat(mScrollIndicator, "alpha", 1f); @@ -1768,7 +1787,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // Fade the indicator out updateScrollingIndicatorPosition(); cancelScrollingIndicatorAnimations(); - if (immediately) { + if (immediately || mScrollingPaused) { mScrollIndicator.setVisibility(View.INVISIBLE); mScrollIndicator.setAlpha(0f); } else {