OSDN Git Service

Don't double-cancel the active ripple
authorAlan Viverette <alanv@google.com>
Tue, 29 Jul 2014 17:21:50 +0000 (10:21 -0700)
committerAlan Viverette <alanv@google.com>
Tue, 29 Jul 2014 17:21:50 +0000 (10:21 -0700)
BUG: 16651728
Change-Id: Ibe413eabf9644c2ac9a5c8c1418ff996dacf606a

graphics/java/android/graphics/drawable/RippleDrawable.java

index 0c9c558..eb7291c 100644 (file)
@@ -525,16 +525,6 @@ public class RippleDrawable extends LayerDrawable {
     }
 
     private void clearHotspots() {
-        if (mRipple != null) {
-            mRipple.cancel();
-            mRipple = null;
-        }
-
-        if (mBackground != null) {
-            mBackground.cancel();
-            mBackground = null;
-        }
-
         final int count = mAnimatingRipplesCount;
         final Ripple[] ripples = mAnimatingRipples;
         for (int i = 0; i < count; i++) {
@@ -543,6 +533,21 @@ public class RippleDrawable extends LayerDrawable {
             final Ripple ripple = ripples[i];
             ripples[i] = null;
             ripple.cancel();
+
+            // The active ripple may also be animating. Don't cancel it twice.
+            if (mRipple == ripple) {
+                mRipple = null;
+            }
+        }
+
+        if (mRipple != null) {
+            mRipple.cancel();
+            mRipple = null;
+        }
+
+        if (mBackground != null) {
+            mBackground.cancel();
+            mBackground = null;
         }
 
         mAnimatingRipplesCount = 0;