Merge "Fix ripples not going away" into sc-dev

This commit is contained in:
John Reck
2021-06-16 21:47:34 +00:00
committed by Android (Google) Code Review

View File

@@ -221,6 +221,7 @@ public class RippleDrawable extends LayerDrawable {
private boolean mForceSoftware; private boolean mForceSoftware;
// Patterned // Patterned
private boolean mAddRipple = false;
private float mTargetBackgroundOpacity; private float mTargetBackgroundOpacity;
private ValueAnimator mBackgroundAnimation; private ValueAnimator mBackgroundAnimation;
private float mBackgroundOpacity; private float mBackgroundOpacity;
@@ -716,6 +717,7 @@ public class RippleDrawable extends LayerDrawable {
} }
cancelExitingRipples(); cancelExitingRipples();
exitPatternedAnimation();
} }
@Override @Override
@@ -807,7 +809,7 @@ public class RippleDrawable extends LayerDrawable {
} }
private void startPatternedAnimation() { private void startPatternedAnimation() {
mRippleActive = true; mAddRipple = true;
invalidateSelf(false); invalidateSelf(false);
} }
@@ -862,17 +864,17 @@ public class RippleDrawable extends LayerDrawable {
h = bounds.height(); h = bounds.height();
w = bounds.width(); w = bounds.width();
} }
boolean shouldAnimate = mRippleActive; boolean addRipple = mAddRipple;
boolean shouldExit = mExitingAnimation; boolean shouldExit = mExitingAnimation;
mRippleActive = false;
mExitingAnimation = false; mExitingAnimation = false;
if (mRunningAnimations.size() > 0 && !shouldAnimate) { mAddRipple = false;
if (mRunningAnimations.size() > 0 && !addRipple) {
// update paint when view is invalidated // update paint when view is invalidated
getRipplePaint(); getRipplePaint();
} }
drawContent(canvas); drawContent(canvas);
drawPatternedBackground(canvas, cx, cy); drawPatternedBackground(canvas, cx, cy);
if (shouldAnimate && mRunningAnimations.size() <= MAX_RIPPLES) { if (addRipple && mRunningAnimations.size() <= MAX_RIPPLES) {
RippleAnimationSession.AnimationProperties<Float, Paint> properties = RippleAnimationSession.AnimationProperties<Float, Paint> properties =
createAnimationProperties(x, y, cx, cy, w, h); createAnimationProperties(x, y, cx, cy, w, h);
mRunningAnimations.add(new RippleAnimationSession(properties, !useCanvasProps) mRunningAnimations.add(new RippleAnimationSession(properties, !useCanvasProps)