summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2015-10-02 16:22:08 -0700
committerTony Wickham <twickham@google.com>2015-10-05 16:57:09 -0700
commit0bb211a9d5cd4eabcbf46385bbfb9895e5cd7325 (patch)
tree9c3bee4d9a19b4f0cc99d8c01111afa55a276c16 /src/com/android/launcher3
parentfd4264b2b52e294ccb1326784bdf1df2cd7fe14c (diff)
downloadandroid_packages_apps_Trebuchet-0bb211a9d5cd4eabcbf46385bbfb9895e5cd7325.tar.gz
android_packages_apps_Trebuchet-0bb211a9d5cd4eabcbf46385bbfb9895e5cd7325.tar.bz2
android_packages_apps_Trebuchet-0bb211a9d5cd4eabcbf46385bbfb9895e5cd7325.zip
Actually call LauncherTransitionable.onLauncherTransitionStep().
Previously, it was only called at the start and end of the transition; now it is called as the animation interpolates. Specifically, a dummy ValueAnimator is played alongside the transition animation and calls dispatchOnLauncherTransitionStep() as it goes. One place where this is important is in Workspace, where mTransitionProgress is used to determine things like whether the workspace should accept a drop - hence the bug that caused apps dragged from All Apps to vanish when dropped before the transition ended. Bug: 24215358 Change-Id: I32cd633c53557305caf84e87c9a4d4f07eef2223
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/Launcher.java1
-rw-r--r--src/com/android/launcher3/LauncherAnimUtils.java36
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java28
3 files changed, 46 insertions, 19 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f90e09c39..59fcb44f1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3824,6 +3824,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 6a248a332..fa20f0360 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -24,7 +24,6 @@ import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
-import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver;
import com.android.launcher3.util.UiThreadCircularReveal;
@@ -59,24 +58,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 47b0a9166..3391d06c1 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.content.res.Resources;
import android.util.Log;
@@ -229,6 +230,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();
@@ -342,11 +345,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() {
@@ -402,6 +406,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 and animation to the workspace from the apps view.
*/
private void startAnimationToWorkspaceFromAllApps(final Workspace.State fromWorkspaceState,
@@ -509,12 +531,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.