summaryrefslogtreecommitdiffstats
path: root/core/java/android/animation
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2014-10-31 14:23:34 -0700
committerGeorge Mount <mount@google.com>2014-11-04 07:55:03 -0800
commite48ef2a3efedebdcc351b60d2f3c35c987811938 (patch)
tree0ab5d3a10a615cdd3b6e3000cfe9742ed1523554 /core/java/android/animation
parenta68da9382996132bb41d6f60b87a3bd5f8028b45 (diff)
downloadframeworks_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.java6
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;