From 7eea78a1ed8a1e9ea7fabb5b203556bfa94a25fe Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 23 Jun 2015 15:02:33 -0700 Subject: Code cleanup, WorkspaceStateTransitionAnimation Change-Id: I6b82f705f8dfddc507ddd66d5fd8a499cd6f58fd --- .../WorkspaceStateTransitionAnimation.java | 36 +++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/com/android/launcher3/WorkspaceStateTransitionAnimation.java') diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 399ef9755..b8916a72b 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -192,9 +192,6 @@ public class WorkspaceStateTransitionAnimation { @Thunk final ZoomInInterpolator mZoomInInterpolator = new ZoomInInterpolator(); - // These properties refer to the background protection gradient used for AllApps and Widget tray. - @Thunk ValueAnimator mBackgroundFadeOutAnimation; - @Thunk float mSpringLoadedShrinkFactor; @Thunk float mOverviewModeShrinkFactor; @Thunk float mWorkspaceScrimAlpha; @@ -548,25 +545,29 @@ public class WorkspaceStateTransitionAnimation { * @param animated whether or not to set the background alpha immediately * @duration duration of the animation */ - private void animateBackgroundGradient(TransitionStates states, boolean animated, int duration) { + private void animateBackgroundGradient(TransitionStates states, + boolean animated, int duration) { + final DragLayer dragLayer = mLauncher.getDragLayer(); final float startAlpha = dragLayer.getBackgroundAlpha(); float finalAlpha = states.stateIsNormal ? 0 : mWorkspaceScrimAlpha; if (finalAlpha != startAlpha) { if (animated) { - mBackgroundFadeOutAnimation = + // These properties refer to the background protection gradient used for AllApps + // and Widget tray. + ValueAnimator bgFadeOutAnimation = LauncherAnimUtils.ofFloat(mWorkspace, startAlpha, finalAlpha); - mBackgroundFadeOutAnimation.addUpdateListener( - new ValueAnimator.AnimatorUpdateListener() { + bgFadeOutAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override public void onAnimationUpdate(ValueAnimator animation) { dragLayer.setBackgroundAlpha( ((Float)animation.getAnimatedValue()).floatValue()); } }); - mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); - mBackgroundFadeOutAnimation.setDuration(duration); - mStateAnimator.play(mBackgroundFadeOutAnimation); + bgFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + bgFadeOutAnimation.setDuration(duration); + mStateAnimator.play(bgFadeOutAnimation); } else { dragLayer.setBackgroundAlpha(finalAlpha); } @@ -577,17 +578,10 @@ public class WorkspaceStateTransitionAnimation { * Cancels the current animation. */ private void cancelAnimation() { - cancelAnimator(mStateAnimator); - mStateAnimator = null; - } - - /** - * Cancels the specified animation. - */ - private void cancelAnimator(Animator animator) { - if (animator != null) { - animator.setDuration(0); - animator.cancel(); + if (mStateAnimator != null) { + mStateAnimator.setDuration(0); + mStateAnimator.cancel(); } + mStateAnimator = null; } } \ No newline at end of file -- cgit v1.2.3