Skip to content

Commit dc92d19

Browse files
committed
[LoadingIndicator] Teach LoadingIndicatorDrawable to get the animator duration scale
1 parent c2051db commit dc92d19

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public LoadingIndicator(
109109
int minHideDelayUncapped = a.getInt(R.styleable.LoadingIndicator_minHideDelay, -1);
110110
minHideDelay = min(minHideDelayUncapped, MAX_HIDE_DELAY);
111111
a.recycle();
112-
113-
setAnimatorDurationScaleProvider(new AnimatorDurationScaleProvider());
114112
}
115113

116114
/**

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

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

3737
/** This class draws the graphics for a loading indicator. */
3838
public final class LoadingIndicatorDrawable extends Drawable implements Drawable.Callback {
39-
AnimatorDurationScaleProvider animatorDurationScaleProvider;
4039

4140
@NonNull private final Context context;
4241
@NonNull private final LoadingIndicatorSpec specs;
4342
@NonNull private LoadingIndicatorDrawingDelegate drawingDelegate;
4443
@NonNull private LoadingIndicatorAnimatorDelegate animatorDelegate;
4544

4645
@NonNull Paint paint;
46+
@NonNull AnimatorDurationScaleProvider animatorDurationScaleProvider;
4747

4848
@IntRange(from = 0, to = 255)
4949
int alpha;
@@ -76,6 +76,7 @@ public static LoadingIndicatorDrawable create(
7676
animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
7777

7878
this.paint = new Paint();
79+
this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
7980

8081
animatorDelegate.registerDrawable(this);
8182
setAlpha(255);
@@ -195,13 +196,9 @@ public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
195196
// ******************* Utility functions *******************
196197

197198
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;
205202
}
206203

207204
// ******************* Setter and getter *******************

0 commit comments

Comments
 (0)