From 37419d7321e71edb179faa0eafd2a2acf12b62c1 Mon Sep 17 00:00:00 2001 From: Adam Powell <adamp@google.com> Date: Thu, 10 Nov 2011 11:32:09 -0800 Subject: 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 --- core/java/android/view/View.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'core/java/android/view/View.java') 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); + } } } -- cgit v1.1