diff options
author | George Mount <mount@google.com> | 2014-10-31 14:23:34 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2014-11-04 07:55:03 -0800 |
commit | e48ef2a3efedebdcc351b60d2f3c35c987811938 (patch) | |
tree | 0ab5d3a10a615cdd3b6e3000cfe9742ed1523554 /core/java/android/animation | |
parent | a68da9382996132bb41d6f60b87a3bd5f8028b45 (diff) | |
download | frameworks_base-e48ef2a3efedebdcc351b60d2f3c35c987811938.zip frameworks_base-e48ef2a3efedebdcc351b60d2f3c35c987811938.tar.gz frameworks_base-e48ef2a3efedebdcc351b60d2f3c35c987811938.tar.bz2 |
Cancel animation when target changes.
Bug 18201083
Change-Id: I2ea15063b18881c4b31ae6cdc287649dbc4a61f7
Diffstat (limited to 'core/java/android/animation')
-rw-r--r-- | core/java/android/animation/ObjectAnimator.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java index 500634c..59daaab 100644 --- a/core/java/android/animation/ObjectAnimator.java +++ b/core/java/android/animation/ObjectAnimator.java @@ -885,7 +885,8 @@ public final class ObjectAnimator extends ValueAnimator { } /** - * Sets the target object whose property will be animated by this animation + * Sets the target object whose property will be animated by this animation. If the + * animator has been started, it will be canceled. * * @param target The object being animated */ @@ -893,6 +894,9 @@ public final class ObjectAnimator extends ValueAnimator { public void setTarget(@Nullable Object target) { final Object oldTarget = getTarget(); if (oldTarget != target) { + if (isStarted()) { + cancel(); + } mTarget = target == null ? null : new WeakReference<Object>(target); // New target should cause re-initialization prior to starting mInitialized = false; |