diff options
| author | 2010-09-29 14:28:03 -0700 | |
|---|---|---|
| committer | 2010-09-29 14:28:03 -0700 | |
| commit | 9a042772c2d76dba3a541dc4190b7be1a438445a (patch) | |
| tree | 31f9c9890eb4414a1135dcd4801b76f0a0490ef9 | |
| parent | 5cf44f6907cde1126dd982af2d4dfd5c35da9eb9 (diff) | |
| parent | 2a0b3c0d4cd98385ebfa60cc2014bdb2d7b5a7f5 (diff) | |
am 2a0b3c0d: Merge "AnimatedImageView: Stop the animation when we\'re not visible." into gingerbread
Merge commit '2a0b3c0d4cd98385ebfa60cc2014bdb2d7b5a7f5' into gingerbread-plus-aosp
* commit '2a0b3c0d4cd98385ebfa60cc2014bdb2d7b5a7f5':
AnimatedImageView: Stop the animation when we're not visible.
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/AnimatedImageView.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/AnimatedImageView.java b/packages/SystemUI/src/com/android/systemui/statusbar/AnimatedImageView.java index 70d4d6a8b207..d4491d814c19 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/AnimatedImageView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/AnimatedImageView.java @@ -20,6 +20,8 @@ import android.content.Context; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import android.util.Slog; +import android.view.View; import android.widget.ImageView; import android.widget.RemoteViews.RemoteView; @@ -43,7 +45,7 @@ public class AnimatedImageView extends ImageView { } if (drawable instanceof AnimationDrawable) { mAnim = (AnimationDrawable)drawable; - if (mAttached) { + if (isShown()) { mAnim.start(); } } else { @@ -67,9 +69,6 @@ public class AnimatedImageView extends ImageView { @Override public void onAttachedToWindow() { super.onAttachedToWindow(); - if (mAnim != null) { - mAnim.start(); - } mAttached = true; } @@ -81,5 +80,17 @@ public class AnimatedImageView extends ImageView { } mAttached = false; } + + @Override + protected void onVisibilityChanged(View changedView, int vis) { + super.onVisibilityChanged(changedView, vis); + if (mAnim != null) { + if (isShown()) { + mAnim.start(); + } else { + mAnim.stop(); + } + } + } } |