Merge "Fixing animation end not-called when cancelling state the animation recursively" into sc-dev
This commit is contained in:
@@ -2245,7 +2245,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||||||
public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView,
|
public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView,
|
||||||
boolean shouldRemoveTask, long duration) {
|
boolean shouldRemoveTask, long duration) {
|
||||||
if (mPendingAnimation != null) {
|
if (mPendingAnimation != null) {
|
||||||
mPendingAnimation.createPlaybackController().dispatchOnCancel();
|
mPendingAnimation.createPlaybackController().dispatchOnCancel().dispatchOnEnd();
|
||||||
}
|
}
|
||||||
PendingAnimation anim = new PendingAnimation(duration);
|
PendingAnimation anim = new PendingAnimation(duration);
|
||||||
|
|
||||||
|
|||||||
@@ -278,12 +278,19 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchOnStart() {
|
public AnimatorPlaybackController dispatchOnStart() {
|
||||||
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationStart);
|
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationStart);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchOnCancel() {
|
public AnimatorPlaybackController dispatchOnCancel() {
|
||||||
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationCancel);
|
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationCancel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnimatorPlaybackController dispatchOnEnd() {
|
||||||
|
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchSetInterpolator(TimeInterpolator interpolator) {
|
public void dispatchSetInterpolator(TimeInterpolator interpolator) {
|
||||||
@@ -328,7 +335,7 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
|
|||||||
public void onAnimationSuccess(Animator animator) {
|
public void onAnimationSuccess(Animator animator) {
|
||||||
// We wait for the spring (if any) to finish running before completing the end callback.
|
// We wait for the spring (if any) to finish running before completing the end callback.
|
||||||
if (!mDispatched) {
|
if (!mDispatched) {
|
||||||
callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
|
dispatchOnEnd();
|
||||||
if (mEndAction != null) {
|
if (mEndAction != null) {
|
||||||
mEndAction.run();
|
mEndAction.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
// Cancel the current animation. This will reset mState to mCurrentStableState, so store it.
|
||||||
STATE_TYPE fromState = mState;
|
STATE_TYPE fromState = mState;
|
||||||
mConfig.reset();
|
cancelAnimation();
|
||||||
|
|
||||||
if (!animated) {
|
if (!animated) {
|
||||||
mAtomicAnimationFactory.cancelAllStateElementAnimation();
|
mAtomicAnimationFactory.cancelAllStateElementAnimation();
|
||||||
@@ -303,7 +303,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
|||||||
public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state,
|
public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state,
|
||||||
StateAnimationConfig config) {
|
StateAnimationConfig config) {
|
||||||
config.userControlled = true;
|
config.userControlled = true;
|
||||||
mConfig.reset();
|
cancelAnimation();
|
||||||
config.copyTo(mConfig);
|
config.copyTo(mConfig);
|
||||||
mConfig.playbackController = createAnimationToNewWorkspaceInternal(state)
|
mConfig.playbackController = createAnimationToNewWorkspaceInternal(state)
|
||||||
.createPlaybackController();
|
.createPlaybackController();
|
||||||
@@ -393,6 +393,11 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
|||||||
*/
|
*/
|
||||||
public void cancelAnimation() {
|
public void cancelAnimation() {
|
||||||
mConfig.reset();
|
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) {
|
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.
|
* Cancels the current animation and resets config variables.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
AnimatorSet anim = currentAnimation;
|
||||||
|
AnimatorPlaybackController pc = playbackController;
|
||||||
|
|
||||||
DEFAULT.copyTo(this);
|
DEFAULT.copyTo(this);
|
||||||
targetState = null;
|
targetState = null;
|
||||||
|
currentAnimation = null;
|
||||||
|
playbackController = null;
|
||||||
|
changeId++;
|
||||||
|
|
||||||
if (playbackController != null) {
|
if (pc != null) {
|
||||||
playbackController.getAnimationPlayer().cancel();
|
pc.getAnimationPlayer().cancel();
|
||||||
playbackController.dispatchOnCancel();
|
pc.dispatchOnCancel().dispatchOnEnd();
|
||||||
} else if (currentAnimation != null) {
|
} else if (anim != null) {
|
||||||
AnimatorSet anim = currentAnimation;
|
|
||||||
anim.setDuration(0);
|
anim.setDuration(0);
|
||||||
if (!anim.isStarted()) {
|
if (!anim.isStarted()) {
|
||||||
// If the animation is not started the listeners do not get notified,
|
// 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();
|
anim.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAnimation = null;
|
|
||||||
playbackController = null;
|
|
||||||
changeId++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user