diff options
author | Alan Viverette <alanv@google.com> | 2014-08-12 23:51:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-12 23:14:35 +0000 |
commit | 2adf8902ce39f066d001cb7171d93066162fb486 (patch) | |
tree | e017a4b5605a5bfc533c9b37c5de01eae5b62c2b /graphics | |
parent | aa2474d50a9c61301d973349ba3eab4e69974729 (diff) | |
parent | 27cede8777c999f226e2e1035b5011e59b558444 (diff) | |
download | frameworks_base-2adf8902ce39f066d001cb7171d93066162fb486.zip frameworks_base-2adf8902ce39f066d001cb7171d93066162fb486.tar.gz frameworks_base-2adf8902ce39f066d001cb7171d93066162fb486.tar.bz2 |
Merge "Prevent re-entry when clearing animating hotspots" into lmp-dev
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/RippleDrawable.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index f097239..ea9f732 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -157,6 +157,12 @@ public class RippleDrawable extends LayerDrawable { private boolean mOverrideBounds; /** + * Whether hotspots are being cleared. Used to prevent re-entry by + * animation finish listeners. + */ + private boolean mClearingHotspots; + + /** * Constructor used for drawable inflation. */ RippleDrawable() { @@ -524,6 +530,8 @@ public class RippleDrawable extends LayerDrawable { } private void clearHotspots() { + mClearingHotspots = true; + final int count = mAnimatingRipplesCount; final Ripple[] ripples = mAnimatingRipples; for (int i = 0; i < count; i++) { @@ -532,11 +540,6 @@ 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) { @@ -549,6 +552,7 @@ public class RippleDrawable extends LayerDrawable { mBackground = null; } + mClearingHotspots = false; mAnimatingRipplesCount = 0; invalidateSelf(); } @@ -647,15 +651,17 @@ public class RippleDrawable extends LayerDrawable { * @param ripple the ripple to remove */ void removeRipple(Ripple ripple) { - // Ripple ripple ripple ripple. Ripple ripple. - final Ripple[] ripples = mAnimatingRipples; - final int count = mAnimatingRipplesCount; - final int index = getRippleIndex(ripple); - if (index >= 0) { - System.arraycopy(ripples, index + 1, ripples, index + 1 - 1, count - (index + 1)); - ripples[count - 1] = null; - mAnimatingRipplesCount--; - invalidateSelf(); + if (!mClearingHotspots) { + // Ripple ripple ripple ripple. Ripple ripple. + final Ripple[] ripples = mAnimatingRipples; + final int count = mAnimatingRipplesCount; + final int index = getRippleIndex(ripple); + if (index >= 0) { + System.arraycopy(ripples, index + 1, ripples, index + 1 - 1, count - (index + 1)); + ripples[count - 1] = null; + mAnimatingRipplesCount--; + invalidateSelf(); + } } } |