|
36 | 36 |
|
37 | 37 | /** This class draws the graphics for a loading indicator. */
|
38 | 38 | public final class LoadingIndicatorDrawable extends Drawable implements Drawable.Callback {
|
39 |
| - AnimatorDurationScaleProvider animatorDurationScaleProvider; |
40 | 39 |
|
41 | 40 | @NonNull private final Context context;
|
42 | 41 | @NonNull private final LoadingIndicatorSpec specs;
|
43 | 42 | @NonNull private LoadingIndicatorDrawingDelegate drawingDelegate;
|
44 | 43 | @NonNull private LoadingIndicatorAnimatorDelegate animatorDelegate;
|
45 | 44 |
|
46 | 45 | @NonNull Paint paint;
|
| 46 | + @NonNull AnimatorDurationScaleProvider animatorDurationScaleProvider; |
47 | 47 |
|
48 | 48 | @IntRange(from = 0, to = 255)
|
49 | 49 | int alpha;
|
@@ -76,6 +76,7 @@ public static LoadingIndicatorDrawable create(
|
76 | 76 | animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
|
77 | 77 |
|
78 | 78 | this.paint = new Paint();
|
| 79 | + this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider(); |
79 | 80 |
|
80 | 81 | animatorDelegate.registerDrawable(this);
|
81 | 82 | setAlpha(255);
|
@@ -195,13 +196,9 @@ public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
195 | 196 | // ******************* Utility functions *******************
|
196 | 197 |
|
197 | 198 | private boolean isSystemAnimatorDisabled() {
|
198 |
| - if (animatorDurationScaleProvider != null) { |
199 |
| - float systemAnimatorDurationScale = |
200 |
| - animatorDurationScaleProvider.getSystemAnimatorDurationScale( |
201 |
| - context.getContentResolver()); |
202 |
| - return systemAnimatorDurationScale == 0; |
203 |
| - } |
204 |
| - return false; |
| 199 | + float systemAnimatorDurationScale = |
| 200 | + animatorDurationScaleProvider.getSystemAnimatorDurationScale(context.getContentResolver()); |
| 201 | + return systemAnimatorDurationScale == 0; |
205 | 202 | }
|
206 | 203 |
|
207 | 204 | // ******************* Setter and getter *******************
|
|
0 commit comments