Skip to content

Commit 6deaaaa

Browse files
committed
[LoadingIndicator] Teach LoadingIndicatorDrawable to get the animator duration scale
1 parent 7ae12b5 commit 6deaaaa

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/java/com/google/android/material/loadingindicator/LoadingIndicator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public LoadingIndicator(
7474
drawable.setCallback(this);
7575

7676
specs = drawable.getDrawingDelegate().specs;
77-
setAnimatorDurationScaleProvider(new AnimatorDurationScaleProvider());
7877
}
7978

8079
@Override

lib/java/com/google/android/material/loadingindicator/LoadingIndicatorDrawable.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434
/** This class draws the graphics for a loading indicator. */
3535
public final class LoadingIndicatorDrawable extends Drawable implements Drawable.Callback {
36-
AnimatorDurationScaleProvider animatorDurationScaleProvider;
3736

3837
@NonNull private final Context context;
3938
@NonNull private final LoadingIndicatorSpec specs;
4039
@NonNull private LoadingIndicatorDrawingDelegate drawingDelegate;
4140
@NonNull private LoadingIndicatorAnimatorDelegate animatorDelegate;
4241

4342
@NonNull Paint paint;
43+
@NonNull AnimatorDurationScaleProvider animatorDurationScaleProvider;
4444

4545
@IntRange(from = 0, to = 255)
4646
int alpha;
@@ -68,6 +68,7 @@ public static LoadingIndicatorDrawable create(
6868
this.animatorDelegate = animatorDelegate;
6969

7070
this.paint = new Paint();
71+
this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
7172

7273
animatorDelegate.registerDrawable(this);
7374
setAlpha(255);
@@ -187,13 +188,9 @@ public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
187188
// ******************* Utility functions *******************
188189

189190
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;
197194
}
198195

199196
// ******************* Setter and getter *******************

0 commit comments

Comments
 (0)