summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2021-06-21 22:40:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-06-21 22:40:28 +0000
commitb6cdee307b208e60a38a9aba5dbd33adbef78c43 (patch)
treec737162c730540cc0727d7793b221cabbaa5ee46
parent4de165094078d61ec6e1fa2aefd356393e611abe (diff)
parentb3eafe97bbdf635ce9c099471206cae0dd90ed8e (diff)
downloadLauncher3-b6cdee307b208e60a38a9aba5dbd33adbef78c43.tar.gz
Merge "Fixing animation end not-called when cancelling state the animation recursively" into sc-dev am: b3eafe97bb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15032078 Change-Id: Ia84604f9126b2dc142c1d99ae54c71f36accaa0f
-rw-r--r--quickstep/src/com/android/quickstep/views/RecentsView.java2
-rw-r--r--src/com/android/launcher3/anim/AnimatorPlaybackController.java13
-rw-r--r--src/com/android/launcher3/statemanager/StateManager.java28
3 files changed, 28 insertions, 15 deletions
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index df7f8b5a2a..8c3e5b513b 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2245,7 +2245,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView,
boolean shouldRemoveTask, long duration) {
if (mPendingAnimation != null) {
- mPendingAnimation.createPlaybackController().dispatchOnCancel();
+ mPendingAnimation.createPlaybackController().dispatchOnCancel().dispatchOnEnd();
}
PendingAnimation anim = new PendingAnimation(duration);
diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
index 7d8b82a8eb..85ca280ba2 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -278,12 +278,19 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
}
}
- public void dispatchOnStart() {
+ public AnimatorPlaybackController dispatchOnStart() {
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationStart);
+ return this;
}
- public void dispatchOnCancel() {
+ public AnimatorPlaybackController dispatchOnCancel() {
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationCancel);
+ return this;
+ }
+
+ public AnimatorPlaybackController dispatchOnEnd() {
+ callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
+ return this;
}
public void dispatchSetInterpolator(TimeInterpolator interpolator) {
@@ -328,7 +335,7 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
public void onAnimationSuccess(Animator animator) {
// We wait for the spring (if any) to finish running before completing the end callback.
if (!mDispatched) {
- callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
+ dispatchOnEnd();
if (mEndAction != null) {
mEndAction.run();
}
diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java
index 13d6568f78..b34af975bd 100644
--- a/src/com/android/launcher3/statemanager/StateManager.java
+++ b/src/com/android/launcher3/statemanager/StateManager.java
@@ -209,7 +209,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
// Cancel the current animation. This will reset mState to mCurrentStableState, so store it.
STATE_TYPE fromState = mState;
- mConfig.reset();
+ cancelAnimation();
if (!animated) {
mAtomicAnimationFactory.cancelAllStateElementAnimation();
@@ -303,7 +303,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state,
StateAnimationConfig config) {
config.userControlled = true;
- mConfig.reset();
+ cancelAnimation();
config.copyTo(mConfig);
mConfig.playbackController = createAnimationToNewWorkspaceInternal(state)
.createPlaybackController();
@@ -393,6 +393,11 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
*/
public void cancelAnimation() {
mConfig.reset();
+ // It could happen that a new animation is set as a result of an endListener on the
+ // existing animation.
+ while (mConfig.currentAnimation != null || mConfig.playbackController != null) {
+ mConfig.reset();
+ }
}
public void setCurrentUserControlledAnimation(AnimatorPlaybackController controller) {
@@ -508,14 +513,19 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
* Cancels the current animation and resets config variables.
*/
public void reset() {
+ AnimatorSet anim = currentAnimation;
+ AnimatorPlaybackController pc = playbackController;
+
DEFAULT.copyTo(this);
targetState = null;
+ currentAnimation = null;
+ playbackController = null;
+ changeId++;
- if (playbackController != null) {
- playbackController.getAnimationPlayer().cancel();
- playbackController.dispatchOnCancel();
- } else if (currentAnimation != null) {
- AnimatorSet anim = currentAnimation;
+ if (pc != null) {
+ pc.getAnimationPlayer().cancel();
+ pc.dispatchOnCancel().dispatchOnEnd();
+ } else if (anim != null) {
anim.setDuration(0);
if (!anim.isStarted()) {
// If the animation is not started the listeners do not get notified,
@@ -525,10 +535,6 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
}
anim.cancel();
}
-
- currentAnimation = null;
- playbackController = null;
- changeId++;
}
@Override