Ensuring that previous animation is completed before starting a new state animation
Bug: 76231621
Bug: 77150113
Change-Id: I086e8063b08d2ba69ead1bd0ee1772d65fb6075c
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 8f2e104..e4a8f36 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -146,15 +146,18 @@
@Override
public AnimatorSet getAnimator(RemoteAnimationTargetCompat[] targetCompats) {
- Animator[] anims = composeRecentsLaunchAnimator(v, targetCompats);
AnimatorSet anim = new AnimatorSet();
- if (anims != null) {
- anim.playTogether(anims);
- } else {
- anim.play(getLauncherAnimators(v, targetCompats));
+ // Set the state animation first so that any state listeners are called
+ // before our internal listeners.
+ mLauncher.getStateManager().setCurrentAnimation(anim);
+
+ if (!composeRecentsLaunchAnimator(v, targetCompats, anim)) {
+ if (launcherIsATargetWithMode(targetCompats, MODE_CLOSING)) {
+ anim.play(getIconAnimator(v));
+ anim.play(getLauncherContentAnimator(false /* show */));
+ }
anim.play(getWindowAnimators(v, targetCompats));
}
- mLauncher.getStateManager().setCurrentAnimation(anim);
return anim;
}
};
@@ -233,11 +236,11 @@
/**
* Composes the animations for a launch from the recents list if possible.
*/
- private Animator[] composeRecentsLaunchAnimator(View v,
- RemoteAnimationTargetCompat[] targets) {
+ private boolean composeRecentsLaunchAnimator(View v,
+ RemoteAnimationTargetCompat[] targets, AnimatorSet target) {
// Ensure recents is actually visible
if (!mLauncher.getStateManager().getState().overviewUi) {
- return null;
+ return false;
}
RecentsView recentsView = mLauncher.getOverviewPanel();
@@ -246,7 +249,7 @@
TaskView taskView = findTaskViewToLaunch(mLauncher, v, targets);
if (taskView == null) {
- return null;
+ return false;
}
// Found a visible recents task that matches the opening app, lets launch the app from there
@@ -273,9 +276,10 @@
};
}
- Animator windowAnim = getRecentsWindowAnimator(taskView, skipLauncherChanges, targets);
- windowAnim.addListener(windowAnimEndListener);
- return new Animator[] {launcherAnim, windowAnim};
+ target.play(getRecentsWindowAnimator(taskView, skipLauncherChanges, targets));
+ target.play(launcherAnim);
+ target.addListener(windowAnimEndListener);
+ return true;
}
/**
@@ -355,18 +359,6 @@
}
/**
- * @return Animators that control the movements of the Launcher and icon of the opening target.
- */
- private AnimatorSet getLauncherAnimators(View v, RemoteAnimationTargetCompat[] targets) {
- AnimatorSet launcherAnimators = new AnimatorSet();
- launcherAnimators.play(getIconAnimator(v));
- if (launcherIsATargetWithMode(targets, MODE_CLOSING)) {
- launcherAnimators.play(getLauncherContentAnimator(false /* show */));
- }
- return launcherAnimators;
- }
-
- /**
* Content is everything on screen except the background and the floating view (if any).
*
* @param show If true: Animate the content so that it moves upwards and fades in.
@@ -687,11 +679,9 @@
anim.play(getClosingWindowAnimators(targetCompats));
if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)) {
- AnimatorSet contentAnimation = getLauncherResumeAnimation();
- anim.play(contentAnimation);
-
// Only register the content animation for cancellation when state changes
- mLauncher.getStateManager().setCurrentAnimation(contentAnimation);
+ mLauncher.getStateManager().setCurrentAnimation(anim);
+ createLauncherResumeAnimation(anim);
}
return anim;
}
@@ -754,14 +744,14 @@
}
/**
- * @return Animator that modifies Launcher as a result from {@link #getWallpaperOpenRunner}.
+ * Creates an animator that modifies Launcher as a result from {@link #getWallpaperOpenRunner}.
*/
- private AnimatorSet getLauncherResumeAnimation() {
+ private void createLauncherResumeAnimation(AnimatorSet anim) {
if (mLauncher.isInState(LauncherState.ALL_APPS)
|| mLauncher.getDeviceProfile().isVerticalBarLayout()) {
AnimatorSet contentAnimator = getLauncherContentAnimator(true /* show */);
contentAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
- return contentAnimator;
+ anim.play(contentAnimator);
} else {
AnimatorSet workspaceAnimator = new AnimatorSet();
@@ -799,12 +789,10 @@
allAppsOvershoot.setDuration(153);
allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
- AnimatorSet resumeLauncherAnimation = new AnimatorSet();
- resumeLauncherAnimation.play(workspaceAnimator);
- resumeLauncherAnimation.playSequentially(allAppsSlideIn, allAppsOvershoot);
- resumeLauncherAnimation.addListener(mReapplyStateListener);
- return resumeLauncherAnimation;
+ anim.play(workspaceAnimator);
+ anim.playSequentially(allAppsSlideIn, allAppsOvershoot);
+ anim.addListener(mReapplyStateListener);
}
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index ef285df..534c8ae 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -356,7 +356,11 @@
* starting another animation and may block some launcher interactions while running.
*/
public void setCurrentAnimation(AnimatorSet anim) {
+ boolean reapplyNeeded = mConfig.mCurrentAnimation != null;
cancelAnimation();
+ if (reapplyNeeded) {
+ reapplyState();
+ }
mConfig.setAnimation(anim);
}