diff options
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAnimUtils.java | 35 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherStateTransitionAnimation.java | 28 |
3 files changed, 46 insertions, 18 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 4b368df79..750d211bf 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3760,6 +3760,7 @@ public class Launcher extends Activity * * Implementation of the method from LauncherModel.Callbacks. */ + @Override public void bindItems(final ArrayList<ItemInfo> shortcuts, final int start, final int end, final boolean forceAnimateIcons) { Runnable r = new Runnable() { diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index 853c2ec6b..01e73d4a1 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -55,24 +55,25 @@ public class LauncherAnimUtils { // it should be cancelled public static void startAnimationAfterNextDraw(final Animator animator, final View view) { view.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() { - private boolean mStarted = false; - public void onDraw() { - if (mStarted) return; - mStarted = true; - // Use this as a signal that the animation was cancelled - if (animator.getDuration() == 0) { - return; - } - animator.start(); - - final ViewTreeObserver.OnDrawListener listener = this; - view.post(new Runnable() { - public void run() { - view.getViewTreeObserver().removeOnDrawListener(listener); - } - }); + private boolean mStarted = false; + + public void onDraw() { + if (mStarted) return; + mStarted = true; + // Use this as a signal that the animation was cancelled + if (animator.getDuration() == 0) { + return; } - }); + animator.start(); + + final ViewTreeObserver.OnDrawListener listener = this; + view.post(new Runnable() { + public void run() { + view.getViewTreeObserver().removeOnDrawListener(listener); + } + }); + } + }); } public static void onDestroyActivity() { diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java index a8445f384..aa56f9db2 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -22,6 +22,7 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.res.Resources; @@ -234,6 +235,8 @@ public class LauncherStateTransitionAnimation { startWorkspaceSearchBarAnimation(animation, fromWorkspaceState, toWorkspaceState, animated ? revealDuration : 0, overlaySearchBarView); + Animator updateTransitionStepAnim = dispatchOnLauncherTransitionStepAnim(fromView, toView); + if (animated && initialized) { // Setup the reveal view animation int width = revealView.getMeasuredWidth(); @@ -347,11 +350,12 @@ public class LauncherStateTransitionAnimation { animation.play(workspaceAnim); } + animation.play(updateTransitionStepAnim); + // Dispatch the prepare transition signal dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); - final AnimatorSet stateAnimation = animation; final Runnable startAnimRunnable = new Runnable() { public void run() { @@ -407,6 +411,24 @@ public class LauncherStateTransitionAnimation { } /** + * Returns an Animator that calls {@link #dispatchOnLauncherTransitionStep(View, float)} on + * {@param fromView} and {@param toView} as the animation interpolates. + * + * This is a bit hacky: we create a dummy ValueAnimator just for the AnimatorUpdateListener. + */ + private Animator dispatchOnLauncherTransitionStepAnim(final View fromView, final View toView) { + ValueAnimator updateAnimator = ValueAnimator.ofFloat(0, 1); + updateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + dispatchOnLauncherTransitionStep(fromView, animation.getAnimatedFraction()); + dispatchOnLauncherTransitionStep(toView, animation.getAnimatedFraction()); + } + }); + return updateAnimator; + } + + /** * Starts an animation to the workspace from the apps view. */ private void startAnimationToWorkspaceFromAllApps(final Workspace.State fromWorkspaceState, @@ -603,12 +625,16 @@ public class LauncherStateTransitionAnimation { startWorkspaceSearchBarAnimation(animation, fromWorkspaceState, toWorkspaceState, animated ? revealDuration : 0, overlaySearchBarView); + Animator updateTransitionStepAnim = dispatchOnLauncherTransitionStepAnim(fromView, toView); + if (animated && initialized) { // Play the workspace animation if (workspaceAnim != null) { animation.play(workspaceAnim); } + animation.play(updateTransitionStepAnim); + // hideAppsCustomizeHelper is called in some cases when it is already hidden // don't perform all these no-op animations. In particularly, this was causing // the all-apps button to pop in and out. |