diff options
| -rw-r--r-- | graphics/java/android/graphics/drawable/RippleBackground.java | 21 | ||||
| -rw-r--r-- | graphics/java/android/graphics/drawable/RippleDrawable.java | 3 |
2 files changed, 18 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java index d313aa5b5f65..6bd2646f9299 100644 --- a/graphics/java/android/graphics/drawable/RippleBackground.java +++ b/graphics/java/android/graphics/drawable/RippleBackground.java @@ -33,6 +33,7 @@ import android.view.animation.LinearInterpolator; * Draws a ripple background. */ class RippleBackground extends RippleComponent { + private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); private static final int OPACITY_ENTER_DURATION = 600; @@ -48,8 +49,14 @@ class RippleBackground extends RippleComponent { // Software rendering properties. private float mOpacity = 0; - public RippleBackground(RippleDrawable owner, Rect bounds, boolean forceSoftware) { + /** Whether this ripple is bounded. */ + private boolean mIsBounded; + + public RippleBackground(RippleDrawable owner, Rect bounds, boolean isBounded, + boolean forceSoftware) { super(owner, bounds, forceSoftware); + + mIsBounded = isBounded; } public boolean isVisible() { @@ -105,7 +112,8 @@ class RippleBackground extends RippleComponent { final AnimatorSet.Builder builder = set.play(exit); // Linear "fast" enter based on current opacity. - final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); + final int fastEnterDuration = mIsBounded ? + (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; if (fastEnterDuration > 0) { final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1); enter.setInterpolator(LINEAR_INTERPOLATOR); @@ -131,15 +139,18 @@ class RippleBackground extends RippleComponent { mPropX = CanvasProperty.createFloat(0); mPropY = CanvasProperty.createFloat(0); - final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); + final int fastEnterDuration = mIsBounded ? + (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; // Linear exit after enter is completed. final RenderNodeAnimator exit = new RenderNodeAnimator( mPropPaint, RenderNodeAnimator.PAINT_ALPHA, 0); exit.setInterpolator(LINEAR_INTERPOLATOR); exit.setDuration(OPACITY_EXIT_DURATION); - exit.setStartDelay(fastEnterDuration); - exit.setStartValue(targetAlpha); + if (fastEnterDuration > 0) { + exit.setStartDelay(fastEnterDuration); + exit.setStartValue(targetAlpha); + } set.add(exit); // Linear "fast" enter based on current opacity. diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index 5213e10332c4..9c691e508535 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -540,7 +540,8 @@ public class RippleDrawable extends LayerDrawable { */ private void tryBackgroundEnter(boolean focused) { if (mBackground == null) { - mBackground = new RippleBackground(this, mHotspotBounds, mForceSoftware); + final boolean isBounded = isBounded(); + mBackground = new RippleBackground(this, mHotspotBounds, isBounded, mForceSoftware); } mBackground.setup(mState.mMaxRadius, mDensity); |