diff options
author | Jay Aliomer <aaliomer@google.com> | 2021-06-22 16:43:04 -0400 |
---|---|---|
committer | Jay Aliomer <aaliomer@google.com> | 2021-06-24 12:19:38 -0400 |
commit | 4508c4ab858c51ba0a0320fca4759d3eeef53ec2 (patch) | |
tree | 510a1bd8856cc412107419733069783bcedfab0d /graphics/java | |
parent | b01c33a7881e1501331d186df699a756f142f3bf (diff) |
Fix ripple radius calculation
Fixes: 191608957
Test: manually using the material showcase app
Change-Id: I3a89d200a842b3dd5f34ffc94a2c62c6fab9436e
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/drawable/RippleDrawable.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index 8aba87ba3c8f..b994ad20320b 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -184,7 +184,6 @@ public class RippleDrawable extends LayerDrawable { private PorterDuffColorFilter mMaskColorFilter; private PorterDuffColorFilter mFocusColorFilter; private boolean mHasValidMask; - private int mComputedRadius = -1; /** The current ripple. May be actively animating or pending entry. */ private RippleForeground mRipple; @@ -390,8 +389,6 @@ public class RippleDrawable extends LayerDrawable { if (mRipple != null) { mRipple.onBoundsChange(); } - - mComputedRadius = Math.round(computeRadius()); invalidateSelf(); } @@ -750,7 +747,7 @@ public class RippleDrawable extends LayerDrawable { if (mBackground != null) { mBackground.onHotspotBoundsChanged(); } - float newRadius = Math.round(computeRadius()); + float newRadius = Math.round(getComputedRadius()); for (int i = 0; i < mRunningAnimations.size(); i++) { RippleAnimationSession s = mRunningAnimations.get(i); s.setRadius(newRadius); @@ -939,14 +936,13 @@ public class RippleDrawable extends LayerDrawable { } private float computeRadius() { - Rect b = getDirtyBounds(); - float radius = (float) Math.sqrt(b.width() * b.width() + b.height() * b.height()) / 2; - return radius; + final float halfWidth = mHotspotBounds.width() / 2.0f; + final float halfHeight = mHotspotBounds.height() / 2.0f; + return (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight); } private int getComputedRadius() { if (mState.mMaxRadius >= 0) return mState.mMaxRadius; - if (mComputedRadius >= 0) return mComputedRadius; return (int) computeRadius(); } |