|
1 | 1 | /* |
2 | | - * Copyright (C) 2020 The Android Open Source Project |
| 2 | + * Copyright (C) 2024 The Android Open Source Project |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
29 | 29 |
|
30 | 30 | /** |
31 | 31 | * This is the implementation class for drawing progress indicator in the circular indeterminate |
32 | | - * mode. |
| 32 | + * mode with an animation that grows the active segment by modifying the end point and shrinks it by |
| 33 | + * modifying the start point. |
33 | 34 | */ |
34 | | -final class CircularIndeterminateAnimatorDelegate |
| 35 | +final class CircularIndeterminateAdvanceAnimatorDelegate |
35 | 36 | extends IndeterminateAnimatorDelegate<ObjectAnimator> { |
36 | 37 |
|
37 | 38 | // Constants for animation timing. |
@@ -63,7 +64,7 @@ final class CircularIndeterminateAnimatorDelegate |
63 | 64 | private float completeEndFraction; |
64 | 65 | AnimationCallback animatorCompleteCallback = null; |
65 | 66 |
|
66 | | - public CircularIndeterminateAnimatorDelegate(@NonNull CircularProgressIndicatorSpec spec) { |
| 67 | + public CircularIndeterminateAdvanceAnimatorDelegate(@NonNull CircularProgressIndicatorSpec spec) { |
67 | 68 | super(/* indicatorCount= */ 1); |
68 | 69 |
|
69 | 70 | baseSpec = spec; |
@@ -189,7 +190,7 @@ private void maybeUpdateSegmentColors(int playtime) { |
189 | 190 | for (int cycleIndex = 0; cycleIndex < TOTAL_CYCLES; cycleIndex++) { |
190 | 191 | float timeFraction = |
191 | 192 | getFractionInRange(playtime, DELAY_TO_FADE_IN_MS[cycleIndex], DURATION_TO_FADE_IN_MS); |
192 | | - if (timeFraction >= 0 && timeFraction <= 1) { |
| 193 | + if (timeFraction > 0 && timeFraction < 1) { |
193 | 194 | int startColorIndex = |
194 | 195 | (cycleIndex + indicatorColorIndexOffset) % baseSpec.indicatorColors.length; |
195 | 196 | int endColorIndex = (startColorIndex + 1) % baseSpec.indicatorColors.length; |
@@ -237,30 +238,32 @@ private void setCompleteEndFraction(float fraction) { |
237 | 238 |
|
238 | 239 | // ******************* Properties ******************* |
239 | 240 |
|
240 | | - private static final Property<CircularIndeterminateAnimatorDelegate, Float> ANIMATION_FRACTION = |
241 | | - new Property<CircularIndeterminateAnimatorDelegate, Float>(Float.class, "animationFraction") { |
242 | | - @Override |
243 | | - public Float get(CircularIndeterminateAnimatorDelegate delegate) { |
244 | | - return delegate.getAnimationFraction(); |
245 | | - } |
| 241 | + private static final Property<CircularIndeterminateAdvanceAnimatorDelegate, Float> |
| 242 | + ANIMATION_FRACTION = |
| 243 | + new Property<CircularIndeterminateAdvanceAnimatorDelegate, Float>( |
| 244 | + Float.class, "animationFraction") { |
| 245 | + @Override |
| 246 | + public Float get(CircularIndeterminateAdvanceAnimatorDelegate delegate) { |
| 247 | + return delegate.getAnimationFraction(); |
| 248 | + } |
246 | 249 |
|
247 | | - @Override |
248 | | - public void set(CircularIndeterminateAnimatorDelegate delegate, Float value) { |
249 | | - delegate.setAnimationFraction(value); |
250 | | - } |
251 | | - }; |
| 250 | + @Override |
| 251 | + public void set(CircularIndeterminateAdvanceAnimatorDelegate delegate, Float value) { |
| 252 | + delegate.setAnimationFraction(value); |
| 253 | + } |
| 254 | + }; |
252 | 255 |
|
253 | | - private static final Property<CircularIndeterminateAnimatorDelegate, Float> |
| 256 | + private static final Property<CircularIndeterminateAdvanceAnimatorDelegate, Float> |
254 | 257 | COMPLETE_END_FRACTION = |
255 | | - new Property<CircularIndeterminateAnimatorDelegate, Float>( |
| 258 | + new Property<CircularIndeterminateAdvanceAnimatorDelegate, Float>( |
256 | 259 | Float.class, "completeEndFraction") { |
257 | 260 | @Override |
258 | | - public Float get(CircularIndeterminateAnimatorDelegate delegate) { |
| 261 | + public Float get(CircularIndeterminateAdvanceAnimatorDelegate delegate) { |
259 | 262 | return delegate.getCompleteEndFraction(); |
260 | 263 | } |
261 | 264 |
|
262 | 265 | @Override |
263 | | - public void set(CircularIndeterminateAnimatorDelegate delegate, Float value) { |
| 266 | + public void set(CircularIndeterminateAdvanceAnimatorDelegate delegate, Float value) { |
264 | 267 | delegate.setCompleteEndFraction(value); |
265 | 268 | } |
266 | 269 | }; |
|
0 commit comments