Skip to content

Commit 0f3975d

Browse files
pekingmepaulfthomas
authored andcommitted
[ProgressIndicator] Fixed that the wavy path isn't cached correctly when initializing with 0 progress.
PiperOrigin-RevId: 648845270
1 parent cd0a0f0 commit 0f3975d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/java/com/google/android/material/progressindicator/CircularDrawingDelegate.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ private void drawArc(
326326
center.moveAcross(-adjustedRadius);
327327
} else {
328328
float centerDistance = centerDegree / 360 * activePathMeasure.getLength() / 2;
329+
float amplitude = displayedAmplitude * amplitudeFraction;
330+
if (adjustedRadius != cachedRadius || amplitude != cachedAmplitude) {
331+
cachedAmplitude = amplitude;
332+
cachedRadius = adjustedRadius;
333+
invalidateCachedPaths();
334+
}
329335
activePathMeasure.getPosTan(centerDistance, center.posVec, center.tanVec);
330336
}
331337
paint.setStyle(Style.FILL);
@@ -509,10 +515,10 @@ private Pair<PathPoint, PathPoint> getDisplayedPath(
509515
float span,
510516
float amplitudeFraction,
511517
float phaseFraction) {
518+
float amplitude = displayedAmplitude * amplitudeFraction;
512519
if (adjustedRadius != cachedRadius
513-
|| (pathMeasure == activePathMeasure
514-
&& displayedAmplitude * amplitudeFraction != cachedAmplitude)) {
515-
cachedAmplitude = displayedAmplitude * amplitudeFraction;
520+
|| (pathMeasure == activePathMeasure && amplitude != cachedAmplitude)) {
521+
cachedAmplitude = amplitude;
516522
cachedRadius = adjustedRadius;
517523
invalidateCachedPaths();
518524
}

lib/java/com/google/android/material/progressindicator/DeterminateDrawable.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ private void maybeStartAmplitudeAnimator(int level) {
297297
if (!baseSpec.hasWavyEffect()) {
298298
return;
299299
}
300+
maybeInitializeAmplitudeAnimator();
300301
float newAmplitudeFraction = getAmplitudeFractionFromLevel(level);
301302
if (newAmplitudeFraction != targetAmplitudeFraction) {
302-
maybeInitializeAmplitudeAnimator();
303303
if (amplitudeAnimator.isRunning()) {
304304
amplitudeAnimator.cancel();
305305
}
@@ -311,6 +311,8 @@ private void maybeStartAmplitudeAnimator(int level) {
311311
amplitudeInterpolator = amplitudeOffInterpolator;
312312
amplitudeAnimator.reverse();
313313
}
314+
} else if (!amplitudeAnimator.isRunning()) {
315+
setAmplitudeFraction(newAmplitudeFraction);
314316
}
315317
}
316318

0 commit comments

Comments
 (0)