diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java index 8e31d323009fe..c51725a2caac4 100644 --- a/core/java/android/animation/Animator.java +++ b/core/java/android/animation/Animator.java @@ -16,6 +16,7 @@ package android.animation; +import android.annotation.Nullable; import android.content.pm.ActivityInfo.Config; import android.content.res.ConstantState; @@ -436,10 +437,14 @@ public abstract class Animator implements Cloneable { * operate on target objects (for example, {@link ValueAnimator}, but this method * is on the superclass for the convenience of dealing generically with those subclasses * that do handle targets. + *

+ * Note: The target is stored as a weak reference internally to avoid leaking + * resources by having animators directly reference old targets. Therefore, you should + * ensure that animator targets always have a hard reference elsewhere. * * @param target The object being animated */ - public void setTarget(Object target) { + public void setTarget(@Nullable Object target) { } // Hide reverse() and canReverse() for now since reverse() only work for simple diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java index efb9192a75836..542ecf41756ec 100644 --- a/core/java/android/animation/ObjectAnimator.java +++ b/core/java/android/animation/ObjectAnimator.java @@ -898,12 +898,6 @@ public final class ObjectAnimator extends ValueAnimator { return mTarget == null ? null : mTarget.get(); } - /** - * 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 - */ @Override public void setTarget(@Nullable Object target) { final Object oldTarget = getTarget();