summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author George Mount <mount@google.com> 2014-11-05 23:04:17 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-11-05 23:04:18 +0000
commitc838b677749e0c20fc201b0418864be3835711b8 (patch)
treed33c85554100811b87deffa67075b37e9aebb571
parent6c96cbf581bf97b034e4c65eabe3c0fe8d930bfa (diff)
parente48ef2a3efedebdcc351b60d2f3c35c987811938 (diff)
Merge "Cancel animation when target changes." into lmp-mr1-dev
-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 500634ceab83..59daaab44a84 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;