From 43ea54bdc343a913f62885304796e4ab1bca4ef1 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Fri, 9 Mar 2012 14:37:48 -0800 Subject: Don't remove all animation callbacks if action/who was null. Fixes a bug in View.removeCallbacks and View.unscheduleDrawable where it was possible for the caller to remove all animation callbacks if it happened to specify an action or who parameter of null. Also refactored the callback queueing code in Choreographer to make it more intent revealing although the behavior remains the same. Bug: 6144688 Change-Id: Iba29dcda6b3aaad73af664bb63feab65ae3483e5 --- core/java/android/view/View.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 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 a651362..61660b9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8852,13 +8852,15 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * (for instance, if the Runnable was not in the queue already.) */ public boolean removeCallbacks(Runnable action) { - final AttachInfo attachInfo = mAttachInfo; - if (attachInfo != null) { - attachInfo.mHandler.removeCallbacks(action); - attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null); - } else { - // Assume that post will succeed later - ViewRootImpl.getRunQueue().removeCallbacks(action); + if (action != null) { + final AttachInfo attachInfo = mAttachInfo; + if (attachInfo != null) { + attachInfo.mHandler.removeCallbacks(action); + attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null); + } else { + // Assume that post will succeed later + ViewRootImpl.getRunQueue().removeCallbacks(action); + } } return true; } @@ -11963,7 +11965,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * @see #drawableStateChanged */ public void unscheduleDrawable(Drawable who) { - if (mAttachInfo != null) { + if (mAttachInfo != null && who != null) { mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(null, who); } } -- cgit v1.1