diff options
author | Alan Viverette <alanv@google.com> | 2015-05-18 22:32:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-18 22:32:57 +0000 |
commit | 365f5c2e4be73382eefeb69a6d4a4aa5d60bc27d (patch) | |
tree | 8f0c11707d2e7214b8c3c0e1f674b6f72e360694 /graphics | |
parent | 6ae9dc804960da833338452c25023fc747e406a1 (diff) | |
parent | 5bc0144302bb378e5f007baa4bf6620ab9031879 (diff) | |
download | frameworks_base-365f5c2e4be73382eefeb69a6d4a4aa5d60bc27d.zip frameworks_base-365f5c2e4be73382eefeb69a6d4a4aa5d60bc27d.tar.gz frameworks_base-365f5c2e4be73382eefeb69a6d4a4aa5d60bc27d.tar.bz2 |
Merge "Update ripple drawable target radius on bounds change" into mnc-dev
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/RippleComponent.java | 17 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/RippleDrawable.java | 9 |
2 files changed, 22 insertions, 4 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleComponent.java b/graphics/java/android/graphics/drawable/RippleComponent.java index 0412e35..5ba2f93 100644 --- a/graphics/java/android/graphics/drawable/RippleComponent.java +++ b/graphics/java/android/graphics/drawable/RippleComponent.java @@ -57,14 +57,19 @@ abstract class RippleComponent { mBounds = bounds; } + public void onBoundsChange() { + if (!mHasMaxRadius) { + mTargetRadius = getTargetRadius(mBounds); + onTargetRadiusChanged(mTargetRadius); + } + } + public final void setup(float maxRadius, float density) { if (maxRadius >= 0) { mHasMaxRadius = true; mTargetRadius = maxRadius; } else { - final float halfWidth = mBounds.width() / 2.0f; - final float halfHeight = mBounds.height() / 2.0f; - mTargetRadius = (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight); + mTargetRadius = getTargetRadius(mBounds); } mDensity = density; @@ -72,6 +77,12 @@ abstract class RippleComponent { onTargetRadiusChanged(mTargetRadius); } + private static float getTargetRadius(Rect bounds) { + final float halfWidth = bounds.width() / 2.0f; + final float halfHeight = bounds.height() / 2.0f; + return (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight); + } + /** * Starts a ripple enter animation. * diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index efc171c..f7e8ed0 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -31,7 +31,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.ColorFilter; import android.graphics.Matrix; import android.graphics.Outline; import android.graphics.Paint; @@ -294,6 +293,14 @@ public class RippleDrawable extends LayerDrawable { onHotspotBoundsChanged(); } + if (mBackground != null) { + mBackground.onBoundsChange(); + } + + if (mRipple != null) { + mRipple.onBoundsChange(); + } + invalidateSelf(); } |