diff options
author | Brian Carlstrom <bdc@google.com> | 2010-11-19 14:04:05 -0800 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2010-11-19 16:16:46 -0800 |
commit | 877e0b99eedfd22590db4a1663ca8a3b8e6b63d2 (patch) | |
tree | 0af9ed38efc067aaa5466a525e8f626549c5b83e /core/java/android/view/animation | |
parent | 8d7572009dfae2a9dd664a4c495144b826e68dd0 (diff) | |
download | frameworks_base-877e0b99eedfd22590db4a1663ca8a3b8e6b63d2.zip frameworks_base-877e0b99eedfd22590db4a1663ca8a3b8e6b63d2.tar.gz frameworks_base-877e0b99eedfd22590db4a1663ca8a3b8e6b63d2.tar.bz2 |
Adding CloseGuard to Animation to find forgotten animations
Change-Id: I90df2c8a88dd75550431b7db63242db1a1b2f16a
Diffstat (limited to 'core/java/android/view/animation')
-rw-r--r-- | core/java/android/view/animation/Animation.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java index c6fae9d..13d0ec1 100644 --- a/core/java/android/view/animation/Animation.java +++ b/core/java/android/view/animation/Animation.java @@ -18,9 +18,11 @@ package android.view.animation; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.RectF; +import android.os.SystemProperties; import android.util.AttributeSet; import android.util.TypedValue; -import android.graphics.RectF; +import dalvik.system.CloseGuard; /** * Abstraction for an Animation that can be applied to Views, Surfaces, or @@ -86,7 +88,10 @@ public abstract class Animation implements Cloneable { * content for the duration of the animation. */ public static final int ZORDER_BOTTOM = -1; - + + private static final boolean USE_CLOSEGUARD + = SystemProperties.getBoolean("log.closeguard.Animation", false); + /** * Set by {@link #getTransformation(long, Transformation)} when the animation ends. */ @@ -194,6 +199,8 @@ public abstract class Animation implements Cloneable { Transformation mTransformation = new Transformation(); Transformation mPreviousTransformation = new Transformation(); + private final CloseGuard guard = CloseGuard.get(); + /** * Creates a new animation with a duration of 0ms, the default interpolator, with * fillBefore set to true and fillAfter set to false @@ -276,6 +283,7 @@ public abstract class Animation implements Cloneable { if (mStarted && !mEnded) { if (mListener != null) mListener.onAnimationEnd(this); mEnded = true; + guard.close(); } // Make sure we move the animation to the end mStartTime = Long.MIN_VALUE; @@ -288,6 +296,7 @@ public abstract class Animation implements Cloneable { public void detach() { if (mStarted && !mEnded) { mEnded = true; + guard.close(); if (mListener != null) mListener.onAnimationEnd(this); } } @@ -781,6 +790,9 @@ public abstract class Animation implements Cloneable { mListener.onAnimationStart(this); } mStarted = true; + if (USE_CLOSEGUARD) { + guard.open("cancel or detach or getTransformation"); + } } if (mFillEnabled) normalizedTime = Math.max(Math.min(normalizedTime, 1.0f), 0.0f); @@ -797,6 +809,7 @@ public abstract class Animation implements Cloneable { if (mRepeatCount == mRepeated) { if (!mEnded) { mEnded = true; + guard.close(); if (mListener != null) { mListener.onAnimationEnd(this); } @@ -953,6 +966,16 @@ public abstract class Animation implements Cloneable { } } + protected void finalize() throws Throwable { + try { + if (guard != null) { + guard.warnIfOpen(); + } + } finally { + super.finalize(); + } + } + /** * Utility class to parse a string description of a size. */ |