* commit 'aa6270375263ebf6da4f2f0de31df808eb278563': Cancel animation when target changes.
This commit is contained in:
@@ -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
|
* @param target The object being animated
|
||||||
*/
|
*/
|
||||||
@@ -893,6 +894,9 @@ public final class ObjectAnimator extends ValueAnimator {
|
|||||||
public void setTarget(@Nullable Object target) {
|
public void setTarget(@Nullable Object target) {
|
||||||
final Object oldTarget = getTarget();
|
final Object oldTarget = getTarget();
|
||||||
if (oldTarget != target) {
|
if (oldTarget != target) {
|
||||||
|
if (isStarted()) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
mTarget = target == null ? null : new WeakReference<Object>(target);
|
mTarget = target == null ? null : new WeakReference<Object>(target);
|
||||||
// New target should cause re-initialization prior to starting
|
// New target should cause re-initialization prior to starting
|
||||||
mInitialized = false;
|
mInitialized = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user