|
33 | 33 |
|
34 | 34 | /** This class draws the graphics for a loading indicator. */
|
35 | 35 | public final class LoadingIndicatorDrawable extends Drawable implements Drawable.Callback {
|
36 |
| - AnimatorDurationScaleProvider animatorDurationScaleProvider; |
37 | 36 |
|
38 | 37 | @NonNull private final Context context;
|
39 | 38 | @NonNull private final LoadingIndicatorSpec specs;
|
40 | 39 | @NonNull private LoadingIndicatorDrawingDelegate drawingDelegate;
|
41 | 40 | @NonNull private LoadingIndicatorAnimatorDelegate animatorDelegate;
|
42 | 41 |
|
43 | 42 | @NonNull Paint paint;
|
| 43 | + @NonNull AnimatorDurationScaleProvider animatorDurationScaleProvider; |
44 | 44 |
|
45 | 45 | @IntRange(from = 0, to = 255)
|
46 | 46 | int alpha;
|
@@ -68,6 +68,7 @@ public static LoadingIndicatorDrawable create(
|
68 | 68 | this.animatorDelegate = animatorDelegate;
|
69 | 69 |
|
70 | 70 | this.paint = new Paint();
|
| 71 | + this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider(); |
71 | 72 |
|
72 | 73 | animatorDelegate.registerDrawable(this);
|
73 | 74 | setAlpha(255);
|
@@ -187,13 +188,9 @@ public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
187 | 188 | // ******************* Utility functions *******************
|
188 | 189 |
|
189 | 190 | private boolean isSystemAnimatorDisabled() {
|
190 |
| - if (animatorDurationScaleProvider != null) { |
191 |
| - float systemAnimatorDurationScale = |
192 |
| - animatorDurationScaleProvider.getSystemAnimatorDurationScale( |
193 |
| - context.getContentResolver()); |
194 |
| - return systemAnimatorDurationScale == 0; |
195 |
| - } |
196 |
| - return false; |
| 191 | + float systemAnimatorDurationScale = |
| 192 | + animatorDurationScaleProvider.getSystemAnimatorDurationScale(context.getContentResolver()); |
| 193 | + return systemAnimatorDurationScale == 0; |
197 | 194 | }
|
198 | 195 |
|
199 | 196 | // ******************* Setter and getter *******************
|
|
0 commit comments