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
private AnimatorSet cancelAnimator(AnimatorSet animator) {
if (animator != null) {
- animator.removeAllListeners();
animator.cancel();
}
return null;
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);
+ }
}
});
}
private void startAnimator(int index, Animator animator, long duration) {
if (mAnimators[index] != null) {
- mAnimators[index].removeAllListeners();
mAnimators[index].cancel();
}
mAnimators[index] = animator;
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);
final ViewGroup overviewPanel = mLauncher.getOverviewPanel();
- final View qsbContainer = mLauncher.getQsbContainer();
-
Animator qsbAlphaAnimation = mWorkspace.mQsbAlphaController
.animateAlphaAtIndex(finalQsbAlpha, Workspace.QSB_ALPHA_INDEX_STATE_CHANGE);
// 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());
private ObjectAnimator cancelAnimator(ObjectAnimator animator) {
if (animator != null) {
- animator.removeAllListeners();
animator.cancel();
}
return null;
}
};
- /**
- * 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;
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();
}
public void stopAllAnimations() {
if (mAnimator != null) {
- mAnimator.removeAllListeners();
mAnimator.cancel();
mAnimator = null;
}
}
}
}
+
+ /**
+ * 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);
+ }
+ }
+ }
}