Skip to content

[LoadingIndicator] Teach LoadingIndicatorDrawable to get the animator duration scale #4765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public LoadingIndicator(
drawable.setCallback(this);

specs = drawable.getDrawingDelegate().specs;
setAnimatorDurationScaleProvider(new AnimatorDurationScaleProvider());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

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

@NonNull private final Context context;
@NonNull private final LoadingIndicatorSpec specs;
@NonNull private LoadingIndicatorDrawingDelegate drawingDelegate;
@NonNull private LoadingIndicatorAnimatorDelegate animatorDelegate;

@NonNull Paint paint;
@NonNull AnimatorDurationScaleProvider animatorDurationScaleProvider;

@IntRange(from = 0, to = 255)
int alpha;
Expand Down Expand Up @@ -68,6 +68,7 @@ public static LoadingIndicatorDrawable create(
this.animatorDelegate = animatorDelegate;

this.paint = new Paint();
this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider();

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

private boolean isSystemAnimatorDisabled() {
if (animatorDurationScaleProvider != null) {
float systemAnimatorDurationScale =
animatorDurationScaleProvider.getSystemAnimatorDurationScale(
context.getContentResolver());
return systemAnimatorDurationScale == 0;
}
return false;
float systemAnimatorDurationScale =
animatorDurationScaleProvider.getSystemAnimatorDurationScale(context.getContentResolver());
return systemAnimatorDurationScale == 0;
}

// ******************* Setter and getter *******************
Expand Down