diff options
author | Adam Powell <adamp@google.com> | 2011-11-10 11:32:09 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-11-10 11:35:12 -0800 |
commit | 37419d7321e71edb179faa0eafd2a2acf12b62c1 (patch) | |
tree | 968d272f96633ee917a8d8f3e808b6ff2d3447bf /core | |
parent | 843e04d977fd348ed474da1d3c6a62e7dc837444 (diff) | |
download | frameworks_base-37419d7321e71edb179faa0eafd2a2acf12b62c1.zip frameworks_base-37419d7321e71edb179faa0eafd2a2acf12b62c1.tar.gz frameworks_base-37419d7321e71edb179faa0eafd2a2acf12b62c1.tar.bz2 |
Fix bug 5581874 - Animated drawables don't start as expected
Fix a bug that caused animated drawables to not schedule properly when
a view has not yet been attached. Also make ImageViews update their
drawable visibility state properly, which will handle scheduling
concerns as ImageViews are attached and detached from their windows.
This should also fix the bug where animated notification icons in the
status bar do not animate until the posting app posts an update to the
notification.
Change-Id: I24c403182831258d1f251736e920c9efe1d38299
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/View.java | 16 | ||||
-rw-r--r-- | core/java/android/widget/ImageView.java | 24 |
2 files changed, 36 insertions, 4 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 62e6ebd..dc46d42 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11402,8 +11402,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * {@link SystemClock#uptimeMillis} timebase. */ public void scheduleDrawable(Drawable who, Runnable what, long when) { - if (verifyDrawable(who) && what != null && mAttachInfo != null) { - mAttachInfo.mHandler.postAtTime(what, who, when); + if (verifyDrawable(who) && what != null) { + if (mAttachInfo != null) { + mAttachInfo.mHandler.postAtTime(what, who, when); + } else { + ViewRootImpl.getRunQueue().postDelayed(what, when - SystemClock.uptimeMillis()); + } } } @@ -11414,8 +11418,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * @param what the action to cancel */ public void unscheduleDrawable(Drawable who, Runnable what) { - if (verifyDrawable(who) && what != null && mAttachInfo != null) { - mAttachInfo.mHandler.removeCallbacks(what, who); + if (verifyDrawable(who) && what != null) { + if (mAttachInfo != null) { + mAttachInfo.mHandler.removeCallbacks(what, who); + } else { + ViewRootImpl.getRunQueue().removeCallbacks(what); + } } } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index b24dd69..1e2d0d1 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -1035,4 +1035,28 @@ public class ImageView extends View { mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8); } } + + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + if (mDrawable != null) { + mDrawable.setVisible(visibility == VISIBLE, false); + } + } + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mDrawable != null) { + mDrawable.setVisible(getVisibility() == VISIBLE, false); + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mDrawable != null) { + mDrawable.setVisible(false, false); + } + } } |