OSDN Git Service

Bug fix: QSB sometimes gets stuck to transparent.
authorSunny Goyal <sunnygoyal@google.com>
Thu, 24 Nov 2016 01:16:50 +0000 (06:46 +0530)
committerSunny Goyal <sunnygoyal@google.com>
Thu, 24 Nov 2016 10:02:45 +0000 (15:32 +0530)
 At some places, we were calling removeAllListeners before calling cancel
 on an animation. AnimationListeners are also used to track states, and
 removing listeners before canceling will prevent onAnimationEnd to be
 called, thus preventing state cleanup.
 PinchAnimationManager was causing ZeroAlphaAnimatorListener to be removing
 from Qsb alpha animation, making the MultiStateAlphaController think there
 is a zeroAlpha animation running.

> Removing all instances of removeAllListeners
> Updating various affected listeners to handle onAnimatinoCancel
> Fixing WorkspaceStateTransitionAnimation, which was animation QSB alpha
  on page scroll index

Bug: 31910152
Change-Id: Ie7f31b67d4c502badcdd41f7b04867d1f35f5d27

src/com/android/launcher3/FastBitmapDrawable.java
src/com/android/launcher3/PinchAnimationManager.java
src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
src/com/android/launcher3/pageindicators/PageIndicatorDots.java

index 7eaae5a..270d539 100644 (file)
@@ -364,7 +364,6 @@ public class FastBitmapDrawable extends Drawable {
 
     private AnimatorSet cancelAnimator(AnimatorSet animator) {
         if (animator != null) {
-            animator.removeAllListeners();
             animator.cancel();
         }
         return null;
index c1d60fd..41074be 100644 (file)
@@ -215,9 +215,18 @@ public class PinchAnimationManager {
             view.setVisibility(View.VISIBLE);
         } else {
             animator.addListener(new AnimatorListenerAdapter() {
+                private boolean mCancelled = false;
+
+                @Override
+                public void onAnimationCancel(Animator animation) {
+                    mCancelled = true;
+                }
+
                 @Override
                 public void onAnimationEnd(Animator animation) {
-                    view.setVisibility(View.INVISIBLE);
+                    if (!mCancelled) {
+                        view.setVisibility(View.INVISIBLE);
+                    }
                 }
             });
         }
@@ -226,7 +235,6 @@ public class PinchAnimationManager {
 
     private void startAnimator(int index, Animator animator, long duration) {
         if (mAnimators[index] != null) {
-            mAnimators[index].removeAllListeners();
             mAnimators[index].cancel();
         }
         mAnimators[index] = animator;
index 1f36468..6a71bef 100644 (file)
@@ -356,7 +356,8 @@ public class WorkspaceStateTransitionAnimation {
                 cl.setShortcutAndWidgetAlpha(finalAlpha);
             }
 
-            if (Workspace.isQsbContainerPage(i)) {
+            if (Workspace.isQsbContainerPage(i) &&
+                    states.stateIsNormal && mWorkspaceFadeInAdjacentScreens) {
                 if (animated) {
                     Animator anim = mWorkspace.mQsbAlphaController
                             .animateAlphaAtIndex(finalAlpha, Workspace.QSB_ALPHA_INDEX_PAGE_SCROLL);
@@ -372,8 +373,6 @@ public class WorkspaceStateTransitionAnimation {
 
         final ViewGroup overviewPanel = mLauncher.getOverviewPanel();
 
-        final View qsbContainer = mLauncher.getQsbContainer();
-
         Animator qsbAlphaAnimation = mWorkspace.mQsbAlphaController
                 .animateAlphaAtIndex(finalQsbAlpha, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE);
 
@@ -395,7 +394,7 @@ public class WorkspaceStateTransitionAnimation {
             // For animation optimization, we may need to provide the Launcher transition
             // with a set of views on which to force build and manage layers in certain scenarios.
             layerViews.addView(overviewPanel);
-            layerViews.addView(qsbContainer);
+            layerViews.addView(mLauncher.getQsbContainer());
             layerViews.addView(mLauncher.getHotseat());
             layerViews.addView(mWorkspace.getPageIndicator());
 
index cfd07e6..bc602f3 100644 (file)
@@ -188,7 +188,6 @@ public class AllAppsBackgroundDrawable extends Drawable {
 
     private ObjectAnimator cancelAnimator(ObjectAnimator animator) {
         if (animator != null) {
-            animator.removeAllListeners();
             animator.cancel();
         }
         return null;
index 12a6701..4f5edc9 100644 (file)
@@ -72,18 +72,6 @@ public class PageIndicatorDots extends PageIndicator {
         }
     };
 
-    /**
-     * Listener for keep running the animation until the final state is reached.
-     */
-    private final AnimatorListenerAdapter mAnimCycleListener = new AnimatorListenerAdapter() {
-
-        @Override
-        public void onAnimationEnd(Animator animation) {
-            mAnimator = null;
-            animateToPosition(mFinalPosition);
-        }
-    };
-
     private final Paint mCirclePaint;
     private final float mDotRadius;
     private final int mActiveColor;
@@ -163,7 +151,7 @@ public class PageIndicatorDots extends PageIndicator {
             float positionForThisAnim = mCurrentPosition > mFinalPosition ?
                     mCurrentPosition - SHIFT_PER_ANIMATION : mCurrentPosition + SHIFT_PER_ANIMATION;
             mAnimator = ObjectAnimator.ofFloat(this, CURRENT_POSITION, positionForThisAnim);
-            mAnimator.addListener(mAnimCycleListener);
+            mAnimator.addListener(new AnimationCycleListener());
             mAnimator.setDuration(ANIMATION_DURATION);
             mAnimator.start();
         }
@@ -171,7 +159,6 @@ public class PageIndicatorDots extends PageIndicator {
 
     public void stopAllAnimations() {
         if (mAnimator != null) {
-            mAnimator.removeAllListeners();
             mAnimator.cancel();
             mAnimator = null;
         }
@@ -326,4 +313,25 @@ public class PageIndicatorDots extends PageIndicator {
             }
         }
     }
+
+    /**
+     * Listener for keep running the animation until the final state is reached.
+     */
+    private class AnimationCycleListener extends AnimatorListenerAdapter {
+
+        private boolean mCancelled = false;
+
+        @Override
+        public void onAnimationCancel(Animator animation) {
+            mCancelled = true;
+        }
+
+        @Override
+        public void onAnimationEnd(Animator animation) {
+            if (!mCancelled) {
+                mAnimator = null;
+                animateToPosition(mFinalPosition);
+            }
+        }
+    }
 }