ADD week 5
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AnimatorDurationScaleProvider {
|
||||
private static float defaultSystemAnimatorDurationScale = 1.0f;
|
||||
|
||||
public static void setDefaultSystemAnimatorDurationScale(float f) {
|
||||
defaultSystemAnimatorDurationScale = f;
|
||||
}
|
||||
|
||||
public float getSystemAnimatorDurationScale(ContentResolver contentResolver) {
|
||||
return Settings.Global.getFloat(contentResolver, "animator_duration_scale", 1.0f);
|
||||
}
|
||||
}
|
@ -0,0 +1,461 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.progressindicator.BaseProgressIndicatorSpec;
|
||||
import com.google.android.material.theme.overlay.MaterialThemeOverlay;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BaseProgressIndicator<S extends BaseProgressIndicatorSpec> extends ProgressBar {
|
||||
static final float DEFAULT_OPACITY = 0.2f;
|
||||
static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_ProgressIndicator;
|
||||
public static final int HIDE_INWARD = 2;
|
||||
public static final int HIDE_NONE = 0;
|
||||
public static final int HIDE_OUTWARD = 1;
|
||||
static final int MAX_ALPHA = 255;
|
||||
static final int MAX_HIDE_DELAY = 1000;
|
||||
public static final int SHOW_INWARD = 2;
|
||||
public static final int SHOW_NONE = 0;
|
||||
public static final int SHOW_OUTWARD = 1;
|
||||
AnimatorDurationScaleProvider animatorDurationScaleProvider;
|
||||
private final Runnable delayedHide;
|
||||
private final Runnable delayedShow;
|
||||
private final Animatable2Compat.AnimationCallback hideAnimationCallback;
|
||||
private boolean isIndeterminateModeChangeRequested;
|
||||
private boolean isParentDoneInitializing;
|
||||
private long lastShowStartTime;
|
||||
private final int minHideDelay;
|
||||
private final int showDelay;
|
||||
S spec;
|
||||
private int storedProgress;
|
||||
private boolean storedProgressAnimated;
|
||||
private final Animatable2Compat.AnimationCallback switchIndeterminateModeCallback;
|
||||
private int visibilityAfterHide;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface HideAnimationBehavior {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ShowAnimationBehavior {
|
||||
}
|
||||
|
||||
abstract S createSpec(Context context, AttributeSet attributeSet);
|
||||
|
||||
protected BaseProgressIndicator(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(MaterialThemeOverlay.wrap(context, attributeSet, i, DEF_STYLE_RES), attributeSet, i);
|
||||
this.lastShowStartTime = -1L;
|
||||
this.isIndeterminateModeChangeRequested = false;
|
||||
this.visibilityAfterHide = 4;
|
||||
this.delayedShow = new Runnable() { // from class: com.google.android.material.progressindicator.BaseProgressIndicator.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
BaseProgressIndicator.this.internalShow();
|
||||
}
|
||||
};
|
||||
this.delayedHide = new Runnable() { // from class: com.google.android.material.progressindicator.BaseProgressIndicator.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
BaseProgressIndicator.this.internalHide();
|
||||
BaseProgressIndicator.this.lastShowStartTime = -1L;
|
||||
}
|
||||
};
|
||||
this.switchIndeterminateModeCallback = new Animatable2Compat.AnimationCallback() { // from class: com.google.android.material.progressindicator.BaseProgressIndicator.3
|
||||
@Override // androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
BaseProgressIndicator.this.setIndeterminate(false);
|
||||
BaseProgressIndicator baseProgressIndicator = BaseProgressIndicator.this;
|
||||
baseProgressIndicator.setProgressCompat(baseProgressIndicator.storedProgress, BaseProgressIndicator.this.storedProgressAnimated);
|
||||
}
|
||||
};
|
||||
this.hideAnimationCallback = new Animatable2Compat.AnimationCallback() { // from class: com.google.android.material.progressindicator.BaseProgressIndicator.4
|
||||
@Override // androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
super.onAnimationEnd(drawable);
|
||||
if (BaseProgressIndicator.this.isIndeterminateModeChangeRequested) {
|
||||
return;
|
||||
}
|
||||
BaseProgressIndicator baseProgressIndicator = BaseProgressIndicator.this;
|
||||
baseProgressIndicator.setVisibility(baseProgressIndicator.visibilityAfterHide);
|
||||
}
|
||||
};
|
||||
Context context2 = getContext();
|
||||
this.spec = createSpec(context2, attributeSet);
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context2, attributeSet, R.styleable.BaseProgressIndicator, i, i2, new int[0]);
|
||||
this.showDelay = obtainStyledAttributes.getInt(R.styleable.BaseProgressIndicator_showDelay, -1);
|
||||
this.minHideDelay = Math.min(obtainStyledAttributes.getInt(R.styleable.BaseProgressIndicator_minHideDelay, -1), 1000);
|
||||
obtainStyledAttributes.recycle();
|
||||
this.animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
|
||||
this.isParentDoneInitializing = true;
|
||||
}
|
||||
|
||||
private void registerAnimationCallbacks() {
|
||||
if (getProgressDrawable() != null && getIndeterminateDrawable() != null) {
|
||||
getIndeterminateDrawable().getAnimatorDelegate().registerAnimatorsCompleteCallback(this.switchIndeterminateModeCallback);
|
||||
}
|
||||
if (getProgressDrawable() != null) {
|
||||
getProgressDrawable().registerAnimationCallback(this.hideAnimationCallback);
|
||||
}
|
||||
if (getIndeterminateDrawable() != null) {
|
||||
getIndeterminateDrawable().registerAnimationCallback(this.hideAnimationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterAnimationCallbacks() {
|
||||
if (getIndeterminateDrawable() != null) {
|
||||
getIndeterminateDrawable().unregisterAnimationCallback(this.hideAnimationCallback);
|
||||
getIndeterminateDrawable().getAnimatorDelegate().unregisterAnimatorsCompleteCallback();
|
||||
}
|
||||
if (getProgressDrawable() != null) {
|
||||
getProgressDrawable().unregisterAnimationCallback(this.hideAnimationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (this.showDelay > 0) {
|
||||
removeCallbacks(this.delayedShow);
|
||||
postDelayed(this.delayedShow, this.showDelay);
|
||||
} else {
|
||||
this.delayedShow.run();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void internalShow() {
|
||||
if (this.minHideDelay > 0) {
|
||||
this.lastShowStartTime = SystemClock.uptimeMillis();
|
||||
}
|
||||
setVisibility(0);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (getVisibility() != 0) {
|
||||
removeCallbacks(this.delayedShow);
|
||||
return;
|
||||
}
|
||||
removeCallbacks(this.delayedHide);
|
||||
long uptimeMillis = SystemClock.uptimeMillis() - this.lastShowStartTime;
|
||||
int i = this.minHideDelay;
|
||||
if (uptimeMillis >= i) {
|
||||
this.delayedHide.run();
|
||||
} else {
|
||||
postDelayed(this.delayedHide, i - uptimeMillis);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void internalHide() {
|
||||
((DrawableWithAnimatedVisibilityChange) getCurrentDrawable()).setVisible(false, false, true);
|
||||
if (isNoLongerNeedToBeVisible()) {
|
||||
setVisibility(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onVisibilityChanged(View view, int i) {
|
||||
super.onVisibilityChanged(view, i);
|
||||
applyNewVisibility(i == 0);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onWindowVisibilityChanged(int i) {
|
||||
super.onWindowVisibilityChanged(i);
|
||||
applyNewVisibility(false);
|
||||
}
|
||||
|
||||
protected void applyNewVisibility(boolean z) {
|
||||
if (this.isParentDoneInitializing) {
|
||||
((DrawableWithAnimatedVisibilityChange) getCurrentDrawable()).setVisible(visibleToUser(), false, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
registerAnimationCallbacks();
|
||||
if (visibleToUser()) {
|
||||
internalShow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
removeCallbacks(this.delayedHide);
|
||||
removeCallbacks(this.delayedShow);
|
||||
((DrawableWithAnimatedVisibilityChange) getCurrentDrawable()).hideNow();
|
||||
unregisterAnimationCallbacks();
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar, android.view.View
|
||||
protected synchronized void onDraw(Canvas canvas) {
|
||||
int save = canvas.save();
|
||||
if (getPaddingLeft() != 0 || getPaddingTop() != 0) {
|
||||
canvas.translate(getPaddingLeft(), getPaddingTop());
|
||||
}
|
||||
if (getPaddingRight() != 0 || getPaddingBottom() != 0) {
|
||||
canvas.clipRect(0, 0, getWidth() - (getPaddingLeft() + getPaddingRight()), getHeight() - (getPaddingTop() + getPaddingBottom()));
|
||||
}
|
||||
getCurrentDrawable().draw(canvas);
|
||||
canvas.restoreToCount(save);
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar, android.view.View
|
||||
protected synchronized void onMeasure(int i, int i2) {
|
||||
int preferredWidth;
|
||||
int preferredHeight;
|
||||
DrawingDelegate<S> currentDrawingDelegate = getCurrentDrawingDelegate();
|
||||
if (currentDrawingDelegate == null) {
|
||||
return;
|
||||
}
|
||||
if (currentDrawingDelegate.getPreferredWidth() < 0) {
|
||||
preferredWidth = getDefaultSize(getSuggestedMinimumWidth(), i);
|
||||
} else {
|
||||
preferredWidth = currentDrawingDelegate.getPreferredWidth() + getPaddingLeft() + getPaddingRight();
|
||||
}
|
||||
if (currentDrawingDelegate.getPreferredHeight() < 0) {
|
||||
preferredHeight = getDefaultSize(getSuggestedMinimumHeight(), i2);
|
||||
} else {
|
||||
preferredHeight = currentDrawingDelegate.getPreferredHeight() + getPaddingTop() + getPaddingBottom();
|
||||
}
|
||||
setMeasuredDimension(preferredWidth, preferredHeight);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
if (getCurrentDrawable() != null) {
|
||||
getCurrentDrawable().invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public Drawable getCurrentDrawable() {
|
||||
return isIndeterminate() ? getIndeterminateDrawable() : getProgressDrawable();
|
||||
}
|
||||
|
||||
private DrawingDelegate<S> getCurrentDrawingDelegate() {
|
||||
if (isIndeterminate()) {
|
||||
if (getIndeterminateDrawable() == null) {
|
||||
return null;
|
||||
}
|
||||
return getIndeterminateDrawable().getDrawingDelegate();
|
||||
}
|
||||
if (getProgressDrawable() == null) {
|
||||
return null;
|
||||
}
|
||||
return getProgressDrawable().getDrawingDelegate();
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public void setProgressDrawable(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
super.setProgressDrawable(null);
|
||||
} else {
|
||||
if (drawable instanceof DeterminateDrawable) {
|
||||
DeterminateDrawable determinateDrawable = (DeterminateDrawable) drawable;
|
||||
determinateDrawable.hideNow();
|
||||
super.setProgressDrawable(determinateDrawable);
|
||||
determinateDrawable.setLevelByFraction(getProgress() / getMax());
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot set framework drawable as progress drawable.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public void setIndeterminateDrawable(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
super.setIndeterminateDrawable(null);
|
||||
} else {
|
||||
if (drawable instanceof IndeterminateDrawable) {
|
||||
((DrawableWithAnimatedVisibilityChange) drawable).hideNow();
|
||||
super.setIndeterminateDrawable(drawable);
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot set framework drawable as indeterminate drawable.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public DeterminateDrawable<S> getProgressDrawable() {
|
||||
return (DeterminateDrawable) super.getProgressDrawable();
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public IndeterminateDrawable<S> getIndeterminateDrawable() {
|
||||
return (IndeterminateDrawable) super.getIndeterminateDrawable();
|
||||
}
|
||||
|
||||
boolean visibleToUser() {
|
||||
return ViewCompat.isAttachedToWindow(this) && getWindowVisibility() == 0 && isEffectivelyVisible();
|
||||
}
|
||||
|
||||
boolean isEffectivelyVisible() {
|
||||
View view = this;
|
||||
while (view.getVisibility() == 0) {
|
||||
Object parent = view.getParent();
|
||||
if (parent == null) {
|
||||
return getWindowVisibility() == 0;
|
||||
}
|
||||
if (!(parent instanceof View)) {
|
||||
return true;
|
||||
}
|
||||
view = (View) parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isNoLongerNeedToBeVisible() {
|
||||
return (getProgressDrawable() == null || !getProgressDrawable().isVisible()) && (getIndeterminateDrawable() == null || !getIndeterminateDrawable().isVisible());
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public synchronized void setIndeterminate(boolean z) {
|
||||
if (z == isIndeterminate()) {
|
||||
return;
|
||||
}
|
||||
DrawableWithAnimatedVisibilityChange drawableWithAnimatedVisibilityChange = (DrawableWithAnimatedVisibilityChange) getCurrentDrawable();
|
||||
if (drawableWithAnimatedVisibilityChange != null) {
|
||||
drawableWithAnimatedVisibilityChange.hideNow();
|
||||
}
|
||||
super.setIndeterminate(z);
|
||||
DrawableWithAnimatedVisibilityChange drawableWithAnimatedVisibilityChange2 = (DrawableWithAnimatedVisibilityChange) getCurrentDrawable();
|
||||
if (drawableWithAnimatedVisibilityChange2 != null) {
|
||||
drawableWithAnimatedVisibilityChange2.setVisible(visibleToUser(), false, false);
|
||||
}
|
||||
if ((drawableWithAnimatedVisibilityChange2 instanceof IndeterminateDrawable) && visibleToUser()) {
|
||||
((IndeterminateDrawable) drawableWithAnimatedVisibilityChange2).getAnimatorDelegate().startAnimator();
|
||||
}
|
||||
this.isIndeterminateModeChangeRequested = false;
|
||||
}
|
||||
|
||||
public int getTrackThickness() {
|
||||
return this.spec.trackThickness;
|
||||
}
|
||||
|
||||
public void setTrackThickness(int i) {
|
||||
if (this.spec.trackThickness != i) {
|
||||
this.spec.trackThickness = i;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getIndicatorColor() {
|
||||
return this.spec.indicatorColors;
|
||||
}
|
||||
|
||||
public void setIndicatorColor(int... iArr) {
|
||||
if (iArr.length == 0) {
|
||||
iArr = new int[]{MaterialColors.getColor(getContext(), R.attr.colorPrimary, -1)};
|
||||
}
|
||||
if (Arrays.equals(getIndicatorColor(), iArr)) {
|
||||
return;
|
||||
}
|
||||
this.spec.indicatorColors = iArr;
|
||||
getIndeterminateDrawable().getAnimatorDelegate().invalidateSpecValues();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getTrackColor() {
|
||||
return this.spec.trackColor;
|
||||
}
|
||||
|
||||
public void setTrackColor(int i) {
|
||||
if (this.spec.trackColor != i) {
|
||||
this.spec.trackColor = i;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int getTrackCornerRadius() {
|
||||
return this.spec.trackCornerRadius;
|
||||
}
|
||||
|
||||
public void setTrackCornerRadius(int i) {
|
||||
if (this.spec.trackCornerRadius != i) {
|
||||
S s = this.spec;
|
||||
s.trackCornerRadius = Math.min(i, s.trackThickness / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public int getShowAnimationBehavior() {
|
||||
return this.spec.showAnimationBehavior;
|
||||
}
|
||||
|
||||
public void setShowAnimationBehavior(int i) {
|
||||
this.spec.showAnimationBehavior = i;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getHideAnimationBehavior() {
|
||||
return this.spec.hideAnimationBehavior;
|
||||
}
|
||||
|
||||
public void setHideAnimationBehavior(int i) {
|
||||
this.spec.hideAnimationBehavior = i;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar
|
||||
public synchronized void setProgress(int i) {
|
||||
if (isIndeterminate()) {
|
||||
return;
|
||||
}
|
||||
setProgressCompat(i, false);
|
||||
}
|
||||
|
||||
public void setProgressCompat(int i, boolean z) {
|
||||
if (isIndeterminate()) {
|
||||
if (getProgressDrawable() != null) {
|
||||
this.storedProgress = i;
|
||||
this.storedProgressAnimated = z;
|
||||
this.isIndeterminateModeChangeRequested = true;
|
||||
if (!getIndeterminateDrawable().isVisible() || this.animatorDurationScaleProvider.getSystemAnimatorDurationScale(getContext().getContentResolver()) == 0.0f) {
|
||||
this.switchIndeterminateModeCallback.onAnimationEnd(getIndeterminateDrawable());
|
||||
return;
|
||||
} else {
|
||||
getIndeterminateDrawable().getAnimatorDelegate().requestCancelAnimatorAfterCurrentCycle();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.setProgress(i);
|
||||
if (getProgressDrawable() == null || z) {
|
||||
return;
|
||||
}
|
||||
getProgressDrawable().jumpToCurrentState();
|
||||
}
|
||||
|
||||
public void setVisibilityAfterHide(int i) {
|
||||
if (i != 0 && i != 4 && i != 8) {
|
||||
throw new IllegalArgumentException("The component's visibility must be one of VISIBLE, INVISIBLE, and GONE defined in View.");
|
||||
}
|
||||
this.visibilityAfterHide = i;
|
||||
}
|
||||
|
||||
public void setAnimatorDurationScaleProvider(AnimatorDurationScaleProvider animatorDurationScaleProvider) {
|
||||
this.animatorDurationScaleProvider = animatorDurationScaleProvider;
|
||||
if (getProgressDrawable() != null) {
|
||||
getProgressDrawable().animatorDurationScaleProvider = animatorDurationScaleProvider;
|
||||
}
|
||||
if (getIndeterminateDrawable() != null) {
|
||||
getIndeterminateDrawable().animatorDurationScaleProvider = animatorDurationScaleProvider;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BaseProgressIndicatorSpec {
|
||||
public int hideAnimationBehavior;
|
||||
public int[] indicatorColors = new int[0];
|
||||
public int showAnimationBehavior;
|
||||
public int trackColor;
|
||||
public int trackCornerRadius;
|
||||
public int trackThickness;
|
||||
|
||||
public boolean isHideAnimationEnabled() {
|
||||
return this.hideAnimationBehavior != 0;
|
||||
}
|
||||
|
||||
public boolean isShowAnimationEnabled() {
|
||||
return this.showAnimationBehavior != 0;
|
||||
}
|
||||
|
||||
abstract void validateSpec();
|
||||
|
||||
protected BaseProgressIndicatorSpec(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
int dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.mtrl_progress_track_thickness);
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.BaseProgressIndicator, i, i2, new int[0]);
|
||||
this.trackThickness = MaterialResources.getDimensionPixelSize(context, obtainStyledAttributes, R.styleable.BaseProgressIndicator_trackThickness, dimensionPixelSize);
|
||||
this.trackCornerRadius = Math.min(MaterialResources.getDimensionPixelSize(context, obtainStyledAttributes, R.styleable.BaseProgressIndicator_trackCornerRadius, 0), this.trackThickness / 2);
|
||||
this.showAnimationBehavior = obtainStyledAttributes.getInt(R.styleable.BaseProgressIndicator_showAnimationBehavior, 0);
|
||||
this.hideAnimationBehavior = obtainStyledAttributes.getInt(R.styleable.BaseProgressIndicator_hideAnimationBehavior, 0);
|
||||
loadIndicatorColors(context, obtainStyledAttributes);
|
||||
loadTrackColor(context, obtainStyledAttributes);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
private void loadIndicatorColors(Context context, TypedArray typedArray) {
|
||||
if (!typedArray.hasValue(R.styleable.BaseProgressIndicator_indicatorColor)) {
|
||||
this.indicatorColors = new int[]{MaterialColors.getColor(context, R.attr.colorPrimary, -1)};
|
||||
return;
|
||||
}
|
||||
if (typedArray.peekValue(R.styleable.BaseProgressIndicator_indicatorColor).type != 1) {
|
||||
this.indicatorColors = new int[]{typedArray.getColor(R.styleable.BaseProgressIndicator_indicatorColor, -1)};
|
||||
return;
|
||||
}
|
||||
int[] intArray = context.getResources().getIntArray(typedArray.getResourceId(R.styleable.BaseProgressIndicator_indicatorColor, -1));
|
||||
this.indicatorColors = intArray;
|
||||
if (intArray.length == 0) {
|
||||
throw new IllegalArgumentException("indicatorColors cannot be empty when indicatorColor is not used.");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTrackColor(Context context, TypedArray typedArray) {
|
||||
if (typedArray.hasValue(R.styleable.BaseProgressIndicator_trackColor)) {
|
||||
this.trackColor = typedArray.getColor(R.styleable.BaseProgressIndicator_trackColor, -1);
|
||||
return;
|
||||
}
|
||||
this.trackColor = this.indicatorColors[0];
|
||||
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{android.R.attr.disabledAlpha});
|
||||
float f = obtainStyledAttributes.getFloat(0, 0.2f);
|
||||
obtainStyledAttributes.recycle();
|
||||
this.trackColor = MaterialColors.compositeARGBWithAlpha(this.trackColor, (int) (f * 255.0f));
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class CircularDrawingDelegate extends DrawingDelegate<CircularProgressIndicatorSpec> {
|
||||
private float adjustedRadius;
|
||||
private int arcDirectionFactor;
|
||||
private float displayedCornerRadius;
|
||||
private float displayedTrackThickness;
|
||||
|
||||
public CircularDrawingDelegate(CircularProgressIndicatorSpec circularProgressIndicatorSpec) {
|
||||
super(circularProgressIndicatorSpec);
|
||||
this.arcDirectionFactor = 1;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public int getPreferredWidth() {
|
||||
return getSize();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public int getPreferredHeight() {
|
||||
return getSize();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public void adjustCanvas(Canvas canvas, Rect rect, float f) {
|
||||
float width = rect.width() / getPreferredWidth();
|
||||
float height = rect.height() / getPreferredHeight();
|
||||
float f2 = (((CircularProgressIndicatorSpec) this.spec).indicatorSize / 2.0f) + ((CircularProgressIndicatorSpec) this.spec).indicatorInset;
|
||||
canvas.translate((f2 * width) + rect.left, (f2 * height) + rect.top);
|
||||
canvas.scale(width, height);
|
||||
canvas.rotate(-90.0f);
|
||||
float f3 = -f2;
|
||||
canvas.clipRect(f3, f3, f2, f2);
|
||||
this.arcDirectionFactor = ((CircularProgressIndicatorSpec) this.spec).indicatorDirection == 0 ? 1 : -1;
|
||||
this.displayedTrackThickness = ((CircularProgressIndicatorSpec) this.spec).trackThickness * f;
|
||||
this.displayedCornerRadius = ((CircularProgressIndicatorSpec) this.spec).trackCornerRadius * f;
|
||||
this.adjustedRadius = (((CircularProgressIndicatorSpec) this.spec).indicatorSize - ((CircularProgressIndicatorSpec) this.spec).trackThickness) / 2.0f;
|
||||
if ((this.drawable.isShowing() && ((CircularProgressIndicatorSpec) this.spec).showAnimationBehavior == 2) || (this.drawable.isHiding() && ((CircularProgressIndicatorSpec) this.spec).hideAnimationBehavior == 1)) {
|
||||
this.adjustedRadius += ((1.0f - f) * ((CircularProgressIndicatorSpec) this.spec).trackThickness) / 2.0f;
|
||||
} else if ((this.drawable.isShowing() && ((CircularProgressIndicatorSpec) this.spec).showAnimationBehavior == 1) || (this.drawable.isHiding() && ((CircularProgressIndicatorSpec) this.spec).hideAnimationBehavior == 2)) {
|
||||
this.adjustedRadius -= ((1.0f - f) * ((CircularProgressIndicatorSpec) this.spec).trackThickness) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
void fillIndicator(Canvas canvas, Paint paint, float f, float f2, int i) {
|
||||
if (f == f2) {
|
||||
return;
|
||||
}
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeCap(Paint.Cap.BUTT);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(i);
|
||||
paint.setStrokeWidth(this.displayedTrackThickness);
|
||||
int i2 = this.arcDirectionFactor;
|
||||
float f3 = f * 360.0f * i2;
|
||||
float f4 = (f2 >= f ? f2 - f : (1.0f + f2) - f) * 360.0f * i2;
|
||||
float f5 = this.adjustedRadius;
|
||||
canvas.drawArc(new RectF(-f5, -f5, f5, f5), f3, f4, false, paint);
|
||||
if (this.displayedCornerRadius <= 0.0f || Math.abs(f4) >= 360.0f) {
|
||||
return;
|
||||
}
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
drawRoundedEnd(canvas, paint, this.displayedTrackThickness, this.displayedCornerRadius, f3);
|
||||
drawRoundedEnd(canvas, paint, this.displayedTrackThickness, this.displayedCornerRadius, f3 + f4);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
void fillTrack(Canvas canvas, Paint paint) {
|
||||
int compositeARGBWithAlpha = MaterialColors.compositeARGBWithAlpha(((CircularProgressIndicatorSpec) this.spec).trackColor, this.drawable.getAlpha());
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeCap(Paint.Cap.BUTT);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(compositeARGBWithAlpha);
|
||||
paint.setStrokeWidth(this.displayedTrackThickness);
|
||||
float f = this.adjustedRadius;
|
||||
canvas.drawArc(new RectF(-f, -f, f, f), 0.0f, 360.0f, false, paint);
|
||||
}
|
||||
|
||||
private int getSize() {
|
||||
return ((CircularProgressIndicatorSpec) this.spec).indicatorSize + (((CircularProgressIndicatorSpec) this.spec).indicatorInset * 2);
|
||||
}
|
||||
|
||||
private void drawRoundedEnd(Canvas canvas, Paint paint, float f, float f2, float f3) {
|
||||
canvas.save();
|
||||
canvas.rotate(f3);
|
||||
float f4 = this.adjustedRadius;
|
||||
float f5 = f / 2.0f;
|
||||
canvas.drawRoundRect(new RectF(f4 - f5, f2, f4 + f5, -f2), f2, f2, paint);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
@ -0,0 +1,203 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.util.Property;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.animation.ArgbEvaluatorCompat;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class CircularIndeterminateAnimatorDelegate extends IndeterminateAnimatorDelegate<ObjectAnimator> {
|
||||
private static final int CONSTANT_ROTATION_DEGREES = 1520;
|
||||
private static final int DURATION_TO_COLLAPSE_IN_MS = 667;
|
||||
private static final int DURATION_TO_COMPLETE_END_IN_MS = 333;
|
||||
private static final int DURATION_TO_EXPAND_IN_MS = 667;
|
||||
private static final int DURATION_TO_FADE_IN_MS = 333;
|
||||
private static final int EXTRA_DEGREES_PER_CYCLE = 250;
|
||||
private static final int TAIL_DEGREES_OFFSET = -20;
|
||||
private static final int TOTAL_CYCLES = 4;
|
||||
private static final int TOTAL_DURATION_IN_MS = 5400;
|
||||
private float animationFraction;
|
||||
private ObjectAnimator animator;
|
||||
Animatable2Compat.AnimationCallback animatorCompleteCallback;
|
||||
private final BaseProgressIndicatorSpec baseSpec;
|
||||
private ObjectAnimator completeEndAnimator;
|
||||
private float completeEndFraction;
|
||||
private int indicatorColorIndexOffset;
|
||||
private final FastOutSlowInInterpolator interpolator;
|
||||
private static final int[] DELAY_TO_EXPAND_IN_MS = {0, 1350, 2700, 4050};
|
||||
private static final int[] DELAY_TO_COLLAPSE_IN_MS = {667, 2017, 3367, 4717};
|
||||
private static final int[] DELAY_TO_FADE_IN_MS = {1000, 2350, 3700, 5050};
|
||||
private static final Property<CircularIndeterminateAnimatorDelegate, Float> ANIMATION_FRACTION = new Property<CircularIndeterminateAnimatorDelegate, Float>(Float.class, "animationFraction") { // from class: com.google.android.material.progressindicator.CircularIndeterminateAnimatorDelegate.3
|
||||
@Override // android.util.Property
|
||||
public Float get(CircularIndeterminateAnimatorDelegate circularIndeterminateAnimatorDelegate) {
|
||||
return Float.valueOf(circularIndeterminateAnimatorDelegate.getAnimationFraction());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(CircularIndeterminateAnimatorDelegate circularIndeterminateAnimatorDelegate, Float f) {
|
||||
circularIndeterminateAnimatorDelegate.setAnimationFraction(f.floatValue());
|
||||
}
|
||||
};
|
||||
private static final Property<CircularIndeterminateAnimatorDelegate, Float> COMPLETE_END_FRACTION = new Property<CircularIndeterminateAnimatorDelegate, Float>(Float.class, "completeEndFraction") { // from class: com.google.android.material.progressindicator.CircularIndeterminateAnimatorDelegate.4
|
||||
@Override // android.util.Property
|
||||
public Float get(CircularIndeterminateAnimatorDelegate circularIndeterminateAnimatorDelegate) {
|
||||
return Float.valueOf(circularIndeterminateAnimatorDelegate.getCompleteEndFraction());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(CircularIndeterminateAnimatorDelegate circularIndeterminateAnimatorDelegate, Float f) {
|
||||
circularIndeterminateAnimatorDelegate.setCompleteEndFraction(f.floatValue());
|
||||
}
|
||||
};
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getAnimationFraction() {
|
||||
return this.animationFraction;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getCompleteEndFraction() {
|
||||
return this.completeEndFraction;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setCompleteEndFraction(float f) {
|
||||
this.completeEndFraction = f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void registerAnimatorsCompleteCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
this.animatorCompleteCallback = animationCallback;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void unregisterAnimatorsCompleteCallback() {
|
||||
this.animatorCompleteCallback = null;
|
||||
}
|
||||
|
||||
public CircularIndeterminateAnimatorDelegate(CircularProgressIndicatorSpec circularProgressIndicatorSpec) {
|
||||
super(1);
|
||||
this.indicatorColorIndexOffset = 0;
|
||||
this.animatorCompleteCallback = null;
|
||||
this.baseSpec = circularProgressIndicatorSpec;
|
||||
this.interpolator = new FastOutSlowInInterpolator();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
void startAnimator() {
|
||||
maybeInitializeAnimators();
|
||||
resetPropertiesForNewStart();
|
||||
this.animator.start();
|
||||
}
|
||||
|
||||
private void maybeInitializeAnimators() {
|
||||
if (this.animator == null) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, ANIMATION_FRACTION, 0.0f, 1.0f);
|
||||
this.animator = ofFloat;
|
||||
ofFloat.setDuration(5400L);
|
||||
this.animator.setInterpolator(null);
|
||||
this.animator.setRepeatCount(-1);
|
||||
this.animator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.CircularIndeterminateAnimatorDelegate.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
super.onAnimationRepeat(animator);
|
||||
CircularIndeterminateAnimatorDelegate circularIndeterminateAnimatorDelegate = CircularIndeterminateAnimatorDelegate.this;
|
||||
circularIndeterminateAnimatorDelegate.indicatorColorIndexOffset = (circularIndeterminateAnimatorDelegate.indicatorColorIndexOffset + 4) % CircularIndeterminateAnimatorDelegate.this.baseSpec.indicatorColors.length;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.completeEndAnimator == null) {
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this, COMPLETE_END_FRACTION, 0.0f, 1.0f);
|
||||
this.completeEndAnimator = ofFloat2;
|
||||
ofFloat2.setDuration(333L);
|
||||
this.completeEndAnimator.setInterpolator(this.interpolator);
|
||||
this.completeEndAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.CircularIndeterminateAnimatorDelegate.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
super.onAnimationEnd(animator);
|
||||
CircularIndeterminateAnimatorDelegate.this.cancelAnimatorImmediately();
|
||||
if (CircularIndeterminateAnimatorDelegate.this.animatorCompleteCallback != null) {
|
||||
CircularIndeterminateAnimatorDelegate.this.animatorCompleteCallback.onAnimationEnd(CircularIndeterminateAnimatorDelegate.this.drawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
void cancelAnimatorImmediately() {
|
||||
ObjectAnimator objectAnimator = this.animator;
|
||||
if (objectAnimator != null) {
|
||||
objectAnimator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
void requestCancelAnimatorAfterCurrentCycle() {
|
||||
ObjectAnimator objectAnimator = this.completeEndAnimator;
|
||||
if (objectAnimator == null || objectAnimator.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (this.drawable.isVisible()) {
|
||||
this.completeEndAnimator.start();
|
||||
} else {
|
||||
cancelAnimatorImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void invalidateSpecValues() {
|
||||
resetPropertiesForNewStart();
|
||||
}
|
||||
|
||||
private void updateSegmentPositions(int i) {
|
||||
this.segmentPositions[0] = (this.animationFraction * 1520.0f) - 20.0f;
|
||||
this.segmentPositions[1] = this.animationFraction * 1520.0f;
|
||||
for (int i2 = 0; i2 < 4; i2++) {
|
||||
float fractionInRange = getFractionInRange(i, DELAY_TO_EXPAND_IN_MS[i2], 667);
|
||||
float[] fArr = this.segmentPositions;
|
||||
fArr[1] = fArr[1] + (this.interpolator.getInterpolation(fractionInRange) * 250.0f);
|
||||
float fractionInRange2 = getFractionInRange(i, DELAY_TO_COLLAPSE_IN_MS[i2], 667);
|
||||
float[] fArr2 = this.segmentPositions;
|
||||
fArr2[0] = fArr2[0] + (this.interpolator.getInterpolation(fractionInRange2) * 250.0f);
|
||||
}
|
||||
float[] fArr3 = this.segmentPositions;
|
||||
fArr3[0] = fArr3[0] + ((this.segmentPositions[1] - this.segmentPositions[0]) * this.completeEndFraction);
|
||||
float[] fArr4 = this.segmentPositions;
|
||||
fArr4[0] = fArr4[0] / 360.0f;
|
||||
float[] fArr5 = this.segmentPositions;
|
||||
fArr5[1] = fArr5[1] / 360.0f;
|
||||
}
|
||||
|
||||
private void maybeUpdateSegmentColors(int i) {
|
||||
for (int i2 = 0; i2 < 4; i2++) {
|
||||
float fractionInRange = getFractionInRange(i, DELAY_TO_FADE_IN_MS[i2], 333);
|
||||
if (fractionInRange >= 0.0f && fractionInRange <= 1.0f) {
|
||||
int length = (i2 + this.indicatorColorIndexOffset) % this.baseSpec.indicatorColors.length;
|
||||
int length2 = (length + 1) % this.baseSpec.indicatorColors.length;
|
||||
int compositeARGBWithAlpha = MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[length], this.drawable.getAlpha());
|
||||
int compositeARGBWithAlpha2 = MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[length2], this.drawable.getAlpha());
|
||||
this.segmentColors[0] = ArgbEvaluatorCompat.getInstance().evaluate(this.interpolator.getInterpolation(fractionInRange), Integer.valueOf(compositeARGBWithAlpha), Integer.valueOf(compositeARGBWithAlpha2)).intValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resetPropertiesForNewStart() {
|
||||
this.indicatorColorIndexOffset = 0;
|
||||
this.segmentColors[0] = MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[0], this.drawable.getAlpha());
|
||||
this.completeEndFraction = 0.0f;
|
||||
}
|
||||
|
||||
void setAnimationFraction(float f) {
|
||||
this.animationFraction = f;
|
||||
int i = (int) (f * 5400.0f);
|
||||
updateSegmentPositions(i);
|
||||
maybeUpdateSegmentColors(i);
|
||||
this.drawable.invalidateSelf();
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.R;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularProgressIndicator extends BaseProgressIndicator<CircularProgressIndicatorSpec> {
|
||||
public static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_CircularProgressIndicator;
|
||||
public static final int INDICATOR_DIRECTION_CLOCKWISE = 0;
|
||||
public static final int INDICATOR_DIRECTION_COUNTERCLOCKWISE = 1;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface IndicatorDirection {
|
||||
}
|
||||
|
||||
public CircularProgressIndicator(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularProgressIndicator(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.circularProgressIndicatorStyle);
|
||||
}
|
||||
|
||||
public CircularProgressIndicator(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i, DEF_STYLE_RES);
|
||||
initializeDrawables();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public CircularProgressIndicatorSpec createSpec(Context context, AttributeSet attributeSet) {
|
||||
return new CircularProgressIndicatorSpec(context, attributeSet);
|
||||
}
|
||||
|
||||
private void initializeDrawables() {
|
||||
setIndeterminateDrawable(IndeterminateDrawable.createCircularDrawable(getContext(), (CircularProgressIndicatorSpec) this.spec));
|
||||
setProgressDrawable(DeterminateDrawable.createCircularDrawable(getContext(), (CircularProgressIndicatorSpec) this.spec));
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public void setTrackThickness(int i) {
|
||||
super.setTrackThickness(i);
|
||||
((CircularProgressIndicatorSpec) this.spec).validateSpec();
|
||||
}
|
||||
|
||||
public int getIndicatorInset() {
|
||||
return ((CircularProgressIndicatorSpec) this.spec).indicatorInset;
|
||||
}
|
||||
|
||||
public void setIndicatorInset(int i) {
|
||||
if (((CircularProgressIndicatorSpec) this.spec).indicatorInset != i) {
|
||||
((CircularProgressIndicatorSpec) this.spec).indicatorInset = i;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndicatorSize() {
|
||||
return ((CircularProgressIndicatorSpec) this.spec).indicatorSize;
|
||||
}
|
||||
|
||||
public void setIndicatorSize(int i) {
|
||||
int max = Math.max(i, getTrackThickness() * 2);
|
||||
if (((CircularProgressIndicatorSpec) this.spec).indicatorSize != max) {
|
||||
((CircularProgressIndicatorSpec) this.spec).indicatorSize = max;
|
||||
((CircularProgressIndicatorSpec) this.spec).validateSpec();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndicatorDirection() {
|
||||
return ((CircularProgressIndicatorSpec) this.spec).indicatorDirection;
|
||||
}
|
||||
|
||||
public void setIndicatorDirection(int i) {
|
||||
((CircularProgressIndicatorSpec) this.spec).indicatorDirection = i;
|
||||
invalidate();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CircularProgressIndicatorSpec extends BaseProgressIndicatorSpec {
|
||||
public int indicatorDirection;
|
||||
public int indicatorInset;
|
||||
public int indicatorSize;
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicatorSpec
|
||||
void validateSpec() {
|
||||
}
|
||||
|
||||
public CircularProgressIndicatorSpec(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.circularProgressIndicatorStyle);
|
||||
}
|
||||
|
||||
public CircularProgressIndicatorSpec(Context context, AttributeSet attributeSet, int i) {
|
||||
this(context, attributeSet, i, CircularProgressIndicator.DEF_STYLE_RES);
|
||||
}
|
||||
|
||||
public CircularProgressIndicatorSpec(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
int dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.mtrl_progress_circular_size_medium);
|
||||
int dimensionPixelSize2 = context.getResources().getDimensionPixelSize(R.dimen.mtrl_progress_circular_inset_medium);
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.CircularProgressIndicator, i, i2, new int[0]);
|
||||
this.indicatorSize = Math.max(MaterialResources.getDimensionPixelSize(context, obtainStyledAttributes, R.styleable.CircularProgressIndicator_indicatorSize, dimensionPixelSize), this.trackThickness * 2);
|
||||
this.indicatorInset = MaterialResources.getDimensionPixelSize(context, obtainStyledAttributes, R.styleable.CircularProgressIndicator_indicatorInset, dimensionPixelSize2);
|
||||
this.indicatorDirection = obtainStyledAttributes.getInt(R.styleable.CircularProgressIndicator_indicatorDirectionCircular, 0);
|
||||
obtainStyledAttributes.recycle();
|
||||
validateSpec();
|
||||
}
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import androidx.dynamicanimation.animation.DynamicAnimation;
|
||||
import androidx.dynamicanimation.animation.FloatPropertyCompat;
|
||||
import androidx.dynamicanimation.animation.SpringAnimation;
|
||||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.progressindicator.BaseProgressIndicatorSpec;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DeterminateDrawable<S extends BaseProgressIndicatorSpec> extends DrawableWithAnimatedVisibilityChange {
|
||||
private static final FloatPropertyCompat<DeterminateDrawable> INDICATOR_LENGTH_IN_LEVEL = new FloatPropertyCompat<DeterminateDrawable>("indicatorLevel") { // from class: com.google.android.material.progressindicator.DeterminateDrawable.1
|
||||
@Override // androidx.dynamicanimation.animation.FloatPropertyCompat
|
||||
public float getValue(DeterminateDrawable determinateDrawable) {
|
||||
return determinateDrawable.getIndicatorFraction() * 10000.0f;
|
||||
}
|
||||
|
||||
@Override // androidx.dynamicanimation.animation.FloatPropertyCompat
|
||||
public void setValue(DeterminateDrawable determinateDrawable, float f) {
|
||||
determinateDrawable.setIndicatorFraction(f / 10000.0f);
|
||||
}
|
||||
};
|
||||
private static final int MAX_DRAWABLE_LEVEL = 10000;
|
||||
private static final float SPRING_FORCE_STIFFNESS = 50.0f;
|
||||
private DrawingDelegate<S> drawingDelegate;
|
||||
private float indicatorFraction;
|
||||
private boolean skipAnimationOnLevelChange;
|
||||
private final SpringAnimation springAnimation;
|
||||
private final SpringForce springForce;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getIndicatorFraction() {
|
||||
return this.indicatorFraction;
|
||||
}
|
||||
|
||||
DrawingDelegate<S> getDrawingDelegate() {
|
||||
return this.drawingDelegate;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ void clearAnimationCallbacks() {
|
||||
super.clearAnimationCallbacks();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ int getAlpha() {
|
||||
return super.getAlpha();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ int getOpacity() {
|
||||
return super.getOpacity();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean hideNow() {
|
||||
return super.hideNow();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean isHiding() {
|
||||
return super.isHiding();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ boolean isRunning() {
|
||||
return super.isRunning();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean isShowing() {
|
||||
return super.isShowing();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ void registerAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
super.registerAnimationCallback(animationCallback);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ void setAlpha(int i) {
|
||||
super.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ void setColorFilter(ColorFilter colorFilter) {
|
||||
super.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ boolean setVisible(boolean z, boolean z2) {
|
||||
return super.setVisible(z, z2);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean setVisible(boolean z, boolean z2, boolean z3) {
|
||||
return super.setVisible(z, z2, z3);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ void start() {
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ void stop() {
|
||||
super.stop();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ boolean unregisterAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
return super.unregisterAnimationCallback(animationCallback);
|
||||
}
|
||||
|
||||
DeterminateDrawable(Context context, BaseProgressIndicatorSpec baseProgressIndicatorSpec, DrawingDelegate<S> drawingDelegate) {
|
||||
super(context, baseProgressIndicatorSpec);
|
||||
this.skipAnimationOnLevelChange = false;
|
||||
setDrawingDelegate(drawingDelegate);
|
||||
SpringForce springForce = new SpringForce();
|
||||
this.springForce = springForce;
|
||||
springForce.setDampingRatio(1.0f);
|
||||
springForce.setStiffness(50.0f);
|
||||
SpringAnimation springAnimation = new SpringAnimation(this, INDICATOR_LENGTH_IN_LEVEL);
|
||||
this.springAnimation = springAnimation;
|
||||
springAnimation.setSpring(springForce);
|
||||
setGrowFraction(1.0f);
|
||||
}
|
||||
|
||||
public static DeterminateDrawable<LinearProgressIndicatorSpec> createLinearDrawable(Context context, LinearProgressIndicatorSpec linearProgressIndicatorSpec) {
|
||||
return new DeterminateDrawable<>(context, linearProgressIndicatorSpec, new LinearDrawingDelegate(linearProgressIndicatorSpec));
|
||||
}
|
||||
|
||||
public static DeterminateDrawable<CircularProgressIndicatorSpec> createCircularDrawable(Context context, CircularProgressIndicatorSpec circularProgressIndicatorSpec) {
|
||||
return new DeterminateDrawable<>(context, circularProgressIndicatorSpec, new CircularDrawingDelegate(circularProgressIndicatorSpec));
|
||||
}
|
||||
|
||||
public void addSpringAnimationEndListener(DynamicAnimation.OnAnimationEndListener onAnimationEndListener) {
|
||||
this.springAnimation.addEndListener(onAnimationEndListener);
|
||||
}
|
||||
|
||||
public void removeSpringAnimationEndListener(DynamicAnimation.OnAnimationEndListener onAnimationEndListener) {
|
||||
this.springAnimation.removeEndListener(onAnimationEndListener);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
boolean setVisibleInternal(boolean z, boolean z2, boolean z3) {
|
||||
boolean visibleInternal = super.setVisibleInternal(z, z2, z3);
|
||||
float systemAnimatorDurationScale = this.animatorDurationScaleProvider.getSystemAnimatorDurationScale(this.context.getContentResolver());
|
||||
if (systemAnimatorDurationScale == 0.0f) {
|
||||
this.skipAnimationOnLevelChange = true;
|
||||
} else {
|
||||
this.skipAnimationOnLevelChange = false;
|
||||
this.springForce.setStiffness(50.0f / systemAnimatorDurationScale);
|
||||
}
|
||||
return visibleInternal;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void jumpToCurrentState() {
|
||||
this.springAnimation.skipToEnd();
|
||||
setIndicatorFraction(getLevel() / 10000.0f);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
protected boolean onLevelChange(int i) {
|
||||
if (this.skipAnimationOnLevelChange) {
|
||||
this.springAnimation.skipToEnd();
|
||||
setIndicatorFraction(i / 10000.0f);
|
||||
return true;
|
||||
}
|
||||
this.springAnimation.setStartValue(getIndicatorFraction() * 10000.0f);
|
||||
this.springAnimation.animateToFinalPosition(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicWidth() {
|
||||
return this.drawingDelegate.getPreferredWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicHeight() {
|
||||
return this.drawingDelegate.getPreferredHeight();
|
||||
}
|
||||
|
||||
void setLevelByFraction(float f) {
|
||||
setLevel((int) (f * 10000.0f));
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
Rect rect = new Rect();
|
||||
if (!getBounds().isEmpty() && isVisible() && canvas.getClipBounds(rect)) {
|
||||
canvas.save();
|
||||
this.drawingDelegate.validateSpecAndAdjustCanvas(canvas, getBounds(), getGrowFraction());
|
||||
this.drawingDelegate.fillTrack(canvas, this.paint);
|
||||
this.drawingDelegate.fillIndicator(canvas, this.paint, 0.0f, getIndicatorFraction(), MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[0], getAlpha()));
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setIndicatorFraction(float f) {
|
||||
this.indicatorFraction = f;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
void setDrawingDelegate(DrawingDelegate<S> drawingDelegate) {
|
||||
this.drawingDelegate = drawingDelegate;
|
||||
drawingDelegate.registerDrawable(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,302 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Property;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class DrawableWithAnimatedVisibilityChange extends Drawable implements Animatable2Compat {
|
||||
private static final boolean DEFAULT_DRAWABLE_RESTART = false;
|
||||
private static final int GROW_DURATION = 500;
|
||||
private static final Property<DrawableWithAnimatedVisibilityChange, Float> GROW_FRACTION = new Property<DrawableWithAnimatedVisibilityChange, Float>(Float.class, "growFraction") { // from class: com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.3
|
||||
@Override // android.util.Property
|
||||
public Float get(DrawableWithAnimatedVisibilityChange drawableWithAnimatedVisibilityChange) {
|
||||
return Float.valueOf(drawableWithAnimatedVisibilityChange.getGrowFraction());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(DrawableWithAnimatedVisibilityChange drawableWithAnimatedVisibilityChange, Float f) {
|
||||
drawableWithAnimatedVisibilityChange.setGrowFraction(f.floatValue());
|
||||
}
|
||||
};
|
||||
private List<Animatable2Compat.AnimationCallback> animationCallbacks;
|
||||
final BaseProgressIndicatorSpec baseSpec;
|
||||
final Context context;
|
||||
private float growFraction;
|
||||
private ValueAnimator hideAnimator;
|
||||
private boolean ignoreCallbacks;
|
||||
private Animatable2Compat.AnimationCallback internalAnimationCallback;
|
||||
private float mockGrowFraction;
|
||||
private boolean mockHideAnimationRunning;
|
||||
private boolean mockShowAnimationRunning;
|
||||
private ValueAnimator showAnimator;
|
||||
private int totalAlpha;
|
||||
final Paint paint = new Paint();
|
||||
AnimatorDurationScaleProvider animatorDurationScaleProvider = new AnimatorDurationScaleProvider();
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getAlpha() {
|
||||
return this.totalAlpha;
|
||||
}
|
||||
|
||||
ValueAnimator getHideAnimator() {
|
||||
return this.hideAnimator;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getOpacity() {
|
||||
return -3;
|
||||
}
|
||||
|
||||
void setInternalAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
this.internalAnimationCallback = animationCallback;
|
||||
}
|
||||
|
||||
void setMockHideAnimationRunning(boolean z, float f) {
|
||||
this.mockHideAnimationRunning = z;
|
||||
this.mockGrowFraction = f;
|
||||
}
|
||||
|
||||
void setMockShowAnimationRunning(boolean z, float f) {
|
||||
this.mockShowAnimationRunning = z;
|
||||
this.mockGrowFraction = f;
|
||||
}
|
||||
|
||||
DrawableWithAnimatedVisibilityChange(Context context, BaseProgressIndicatorSpec baseProgressIndicatorSpec) {
|
||||
this.context = context;
|
||||
this.baseSpec = baseProgressIndicatorSpec;
|
||||
setAlpha(255);
|
||||
}
|
||||
|
||||
private void maybeInitializeAnimators() {
|
||||
if (this.showAnimator == null) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, GROW_FRACTION, 0.0f, 1.0f);
|
||||
this.showAnimator = ofFloat;
|
||||
ofFloat.setDuration(500L);
|
||||
this.showAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
setShowAnimator(this.showAnimator);
|
||||
}
|
||||
if (this.hideAnimator == null) {
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this, GROW_FRACTION, 1.0f, 0.0f);
|
||||
this.hideAnimator = ofFloat2;
|
||||
ofFloat2.setDuration(500L);
|
||||
this.hideAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
setHideAnimator(this.hideAnimator);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
if (this.animationCallbacks == null) {
|
||||
this.animationCallbacks = new ArrayList();
|
||||
}
|
||||
if (this.animationCallbacks.contains(animationCallback)) {
|
||||
return;
|
||||
}
|
||||
this.animationCallbacks.add(animationCallback);
|
||||
}
|
||||
|
||||
public boolean unregisterAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
List<Animatable2Compat.AnimationCallback> list = this.animationCallbacks;
|
||||
if (list == null || !list.contains(animationCallback)) {
|
||||
return false;
|
||||
}
|
||||
this.animationCallbacks.remove(animationCallback);
|
||||
if (!this.animationCallbacks.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
this.animationCallbacks = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearAnimationCallbacks() {
|
||||
this.animationCallbacks.clear();
|
||||
this.animationCallbacks = null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dispatchAnimationStart() {
|
||||
Animatable2Compat.AnimationCallback animationCallback = this.internalAnimationCallback;
|
||||
if (animationCallback != null) {
|
||||
animationCallback.onAnimationStart(this);
|
||||
}
|
||||
List<Animatable2Compat.AnimationCallback> list = this.animationCallbacks;
|
||||
if (list == null || this.ignoreCallbacks) {
|
||||
return;
|
||||
}
|
||||
Iterator<Animatable2Compat.AnimationCallback> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onAnimationStart(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dispatchAnimationEnd() {
|
||||
Animatable2Compat.AnimationCallback animationCallback = this.internalAnimationCallback;
|
||||
if (animationCallback != null) {
|
||||
animationCallback.onAnimationEnd(this);
|
||||
}
|
||||
List<Animatable2Compat.AnimationCallback> list = this.animationCallbacks;
|
||||
if (list == null || this.ignoreCallbacks) {
|
||||
return;
|
||||
}
|
||||
Iterator<Animatable2Compat.AnimationCallback> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
setVisibleInternal(true, true, false);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
setVisibleInternal(false, true, false);
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return isShowing() || isHiding();
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
ValueAnimator valueAnimator = this.showAnimator;
|
||||
return (valueAnimator != null && valueAnimator.isRunning()) || this.mockShowAnimationRunning;
|
||||
}
|
||||
|
||||
public boolean isHiding() {
|
||||
ValueAnimator valueAnimator = this.hideAnimator;
|
||||
return (valueAnimator != null && valueAnimator.isRunning()) || this.mockHideAnimationRunning;
|
||||
}
|
||||
|
||||
public boolean hideNow() {
|
||||
return setVisible(false, false, false);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean setVisible(boolean z, boolean z2) {
|
||||
return setVisible(z, z2, true);
|
||||
}
|
||||
|
||||
public boolean setVisible(boolean z, boolean z2, boolean z3) {
|
||||
return setVisibleInternal(z, z2, z3 && this.animatorDurationScaleProvider.getSystemAnimatorDurationScale(this.context.getContentResolver()) > 0.0f);
|
||||
}
|
||||
|
||||
boolean setVisibleInternal(boolean z, boolean z2, boolean z3) {
|
||||
maybeInitializeAnimators();
|
||||
if (!isVisible() && !z) {
|
||||
return false;
|
||||
}
|
||||
ValueAnimator valueAnimator = z ? this.showAnimator : this.hideAnimator;
|
||||
ValueAnimator valueAnimator2 = z ? this.hideAnimator : this.showAnimator;
|
||||
if (!z3) {
|
||||
if (valueAnimator2.isRunning()) {
|
||||
cancelAnimatorsWithoutCallbacks(valueAnimator2);
|
||||
}
|
||||
if (valueAnimator.isRunning()) {
|
||||
valueAnimator.end();
|
||||
} else {
|
||||
endAnimatorsWithoutCallbacks(valueAnimator);
|
||||
}
|
||||
return super.setVisible(z, false);
|
||||
}
|
||||
if (z3 && valueAnimator.isRunning()) {
|
||||
return false;
|
||||
}
|
||||
boolean z4 = !z || super.setVisible(z, false);
|
||||
if (!(z ? this.baseSpec.isShowAnimationEnabled() : this.baseSpec.isHideAnimationEnabled())) {
|
||||
endAnimatorsWithoutCallbacks(valueAnimator);
|
||||
return z4;
|
||||
}
|
||||
if (z2 || !valueAnimator.isPaused()) {
|
||||
valueAnimator.start();
|
||||
} else {
|
||||
valueAnimator.resume();
|
||||
}
|
||||
return z4;
|
||||
}
|
||||
|
||||
private void cancelAnimatorsWithoutCallbacks(ValueAnimator... valueAnimatorArr) {
|
||||
boolean z = this.ignoreCallbacks;
|
||||
this.ignoreCallbacks = true;
|
||||
for (ValueAnimator valueAnimator : valueAnimatorArr) {
|
||||
valueAnimator.cancel();
|
||||
}
|
||||
this.ignoreCallbacks = z;
|
||||
}
|
||||
|
||||
private void endAnimatorsWithoutCallbacks(ValueAnimator... valueAnimatorArr) {
|
||||
boolean z = this.ignoreCallbacks;
|
||||
this.ignoreCallbacks = true;
|
||||
for (ValueAnimator valueAnimator : valueAnimatorArr) {
|
||||
valueAnimator.end();
|
||||
}
|
||||
this.ignoreCallbacks = z;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAlpha(int i) {
|
||||
this.totalAlpha = i;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
this.paint.setColorFilter(colorFilter);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
private void setShowAnimator(ValueAnimator valueAnimator) {
|
||||
ValueAnimator valueAnimator2 = this.showAnimator;
|
||||
if (valueAnimator2 != null && valueAnimator2.isRunning()) {
|
||||
throw new IllegalArgumentException("Cannot set showAnimator while the current showAnimator is running.");
|
||||
}
|
||||
this.showAnimator = valueAnimator;
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
super.onAnimationStart(animator);
|
||||
DrawableWithAnimatedVisibilityChange.this.dispatchAnimationStart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setHideAnimator(ValueAnimator valueAnimator) {
|
||||
ValueAnimator valueAnimator2 = this.hideAnimator;
|
||||
if (valueAnimator2 != null && valueAnimator2.isRunning()) {
|
||||
throw new IllegalArgumentException("Cannot set hideAnimator while the current hideAnimator is running.");
|
||||
}
|
||||
this.hideAnimator = valueAnimator;
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
super.onAnimationEnd(animator);
|
||||
DrawableWithAnimatedVisibilityChange.super.setVisible(false, false);
|
||||
DrawableWithAnimatedVisibilityChange.this.dispatchAnimationEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
float getGrowFraction() {
|
||||
if (this.baseSpec.isShowAnimationEnabled() || this.baseSpec.isHideAnimationEnabled()) {
|
||||
return (this.mockHideAnimationRunning || this.mockShowAnimationRunning) ? this.mockGrowFraction : this.growFraction;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void setGrowFraction(float f) {
|
||||
if (this.growFraction != f) {
|
||||
this.growFraction = f;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import com.google.android.material.progressindicator.BaseProgressIndicatorSpec;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class DrawingDelegate<S extends BaseProgressIndicatorSpec> {
|
||||
protected DrawableWithAnimatedVisibilityChange drawable;
|
||||
S spec;
|
||||
|
||||
abstract void adjustCanvas(Canvas canvas, Rect rect, float f);
|
||||
|
||||
abstract void fillIndicator(Canvas canvas, Paint paint, float f, float f2, int i);
|
||||
|
||||
abstract void fillTrack(Canvas canvas, Paint paint);
|
||||
|
||||
abstract int getPreferredHeight();
|
||||
|
||||
abstract int getPreferredWidth();
|
||||
|
||||
protected void registerDrawable(DrawableWithAnimatedVisibilityChange drawableWithAnimatedVisibilityChange) {
|
||||
this.drawable = drawableWithAnimatedVisibilityChange;
|
||||
}
|
||||
|
||||
public DrawingDelegate(S s) {
|
||||
this.spec = s;
|
||||
}
|
||||
|
||||
void validateSpecAndAdjustCanvas(Canvas canvas, Rect rect, float f) {
|
||||
this.spec.validateSpec();
|
||||
adjustCanvas(canvas, rect, f);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.Animator;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class IndeterminateAnimatorDelegate<T extends Animator> {
|
||||
protected IndeterminateDrawable drawable;
|
||||
protected final int[] segmentColors;
|
||||
protected final float[] segmentPositions;
|
||||
|
||||
abstract void cancelAnimatorImmediately();
|
||||
|
||||
protected float getFractionInRange(int i, int i2, int i3) {
|
||||
return (i - i2) / i3;
|
||||
}
|
||||
|
||||
public abstract void invalidateSpecValues();
|
||||
|
||||
public abstract void registerAnimatorsCompleteCallback(Animatable2Compat.AnimationCallback animationCallback);
|
||||
|
||||
protected void registerDrawable(IndeterminateDrawable indeterminateDrawable) {
|
||||
this.drawable = indeterminateDrawable;
|
||||
}
|
||||
|
||||
abstract void requestCancelAnimatorAfterCurrentCycle();
|
||||
|
||||
abstract void startAnimator();
|
||||
|
||||
public abstract void unregisterAnimatorsCompleteCallback();
|
||||
|
||||
protected IndeterminateAnimatorDelegate(int i) {
|
||||
this.segmentPositions = new float[i * 2];
|
||||
this.segmentColors = new int[i];
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.progressindicator.BaseProgressIndicatorSpec;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class IndeterminateDrawable<S extends BaseProgressIndicatorSpec> extends DrawableWithAnimatedVisibilityChange {
|
||||
private IndeterminateAnimatorDelegate<ObjectAnimator> animatorDelegate;
|
||||
private DrawingDelegate<S> drawingDelegate;
|
||||
|
||||
IndeterminateAnimatorDelegate<ObjectAnimator> getAnimatorDelegate() {
|
||||
return this.animatorDelegate;
|
||||
}
|
||||
|
||||
DrawingDelegate<S> getDrawingDelegate() {
|
||||
return this.drawingDelegate;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ void clearAnimationCallbacks() {
|
||||
super.clearAnimationCallbacks();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ int getAlpha() {
|
||||
return super.getAlpha();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ int getOpacity() {
|
||||
return super.getOpacity();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean hideNow() {
|
||||
return super.hideNow();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean isHiding() {
|
||||
return super.isHiding();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ boolean isRunning() {
|
||||
return super.isRunning();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean isShowing() {
|
||||
return super.isShowing();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ void registerAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
super.registerAnimationCallback(animationCallback);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ void setAlpha(int i) {
|
||||
super.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ void setColorFilter(ColorFilter colorFilter) {
|
||||
super.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Drawable
|
||||
public /* bridge */ /* synthetic */ boolean setVisible(boolean z, boolean z2) {
|
||||
return super.setVisible(z, z2);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
public /* bridge */ /* synthetic */ boolean setVisible(boolean z, boolean z2, boolean z3) {
|
||||
return super.setVisible(z, z2, z3);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ void start() {
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, android.graphics.drawable.Animatable
|
||||
public /* bridge */ /* synthetic */ void stop() {
|
||||
super.stop();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange, androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
public /* bridge */ /* synthetic */ boolean unregisterAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
return super.unregisterAnimationCallback(animationCallback);
|
||||
}
|
||||
|
||||
IndeterminateDrawable(Context context, BaseProgressIndicatorSpec baseProgressIndicatorSpec, DrawingDelegate<S> drawingDelegate, IndeterminateAnimatorDelegate<ObjectAnimator> indeterminateAnimatorDelegate) {
|
||||
super(context, baseProgressIndicatorSpec);
|
||||
setDrawingDelegate(drawingDelegate);
|
||||
setAnimatorDelegate(indeterminateAnimatorDelegate);
|
||||
}
|
||||
|
||||
public static IndeterminateDrawable<LinearProgressIndicatorSpec> createLinearDrawable(Context context, LinearProgressIndicatorSpec linearProgressIndicatorSpec) {
|
||||
IndeterminateAnimatorDelegate linearIndeterminateDisjointAnimatorDelegate;
|
||||
LinearDrawingDelegate linearDrawingDelegate = new LinearDrawingDelegate(linearProgressIndicatorSpec);
|
||||
if (linearProgressIndicatorSpec.indeterminateAnimationType == 0) {
|
||||
linearIndeterminateDisjointAnimatorDelegate = new LinearIndeterminateContiguousAnimatorDelegate(linearProgressIndicatorSpec);
|
||||
} else {
|
||||
linearIndeterminateDisjointAnimatorDelegate = new LinearIndeterminateDisjointAnimatorDelegate(context, linearProgressIndicatorSpec);
|
||||
}
|
||||
return new IndeterminateDrawable<>(context, linearProgressIndicatorSpec, linearDrawingDelegate, linearIndeterminateDisjointAnimatorDelegate);
|
||||
}
|
||||
|
||||
public static IndeterminateDrawable<CircularProgressIndicatorSpec> createCircularDrawable(Context context, CircularProgressIndicatorSpec circularProgressIndicatorSpec) {
|
||||
return new IndeterminateDrawable<>(context, circularProgressIndicatorSpec, new CircularDrawingDelegate(circularProgressIndicatorSpec), new CircularIndeterminateAnimatorDelegate(circularProgressIndicatorSpec));
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange
|
||||
boolean setVisibleInternal(boolean z, boolean z2, boolean z3) {
|
||||
boolean visibleInternal = super.setVisibleInternal(z, z2, z3);
|
||||
if (!isRunning()) {
|
||||
this.animatorDelegate.cancelAnimatorImmediately();
|
||||
}
|
||||
float systemAnimatorDurationScale = this.animatorDurationScaleProvider.getSystemAnimatorDurationScale(this.context.getContentResolver());
|
||||
if (z && (z3 || (Build.VERSION.SDK_INT <= 22 && systemAnimatorDurationScale > 0.0f))) {
|
||||
this.animatorDelegate.startAnimator();
|
||||
}
|
||||
return visibleInternal;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicWidth() {
|
||||
return this.drawingDelegate.getPreferredWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicHeight() {
|
||||
return this.drawingDelegate.getPreferredHeight();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
Rect rect = new Rect();
|
||||
if (!getBounds().isEmpty() && isVisible() && canvas.getClipBounds(rect)) {
|
||||
canvas.save();
|
||||
this.drawingDelegate.validateSpecAndAdjustCanvas(canvas, getBounds(), getGrowFraction());
|
||||
this.drawingDelegate.fillTrack(canvas, this.paint);
|
||||
for (int i = 0; i < this.animatorDelegate.segmentColors.length; i++) {
|
||||
int i2 = i * 2;
|
||||
this.drawingDelegate.fillIndicator(canvas, this.paint, this.animatorDelegate.segmentPositions[i2], this.animatorDelegate.segmentPositions[i2 + 1], this.animatorDelegate.segmentColors[i]);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
void setAnimatorDelegate(IndeterminateAnimatorDelegate<ObjectAnimator> indeterminateAnimatorDelegate) {
|
||||
this.animatorDelegate = indeterminateAnimatorDelegate;
|
||||
indeterminateAnimatorDelegate.registerDrawable(this);
|
||||
}
|
||||
|
||||
void setDrawingDelegate(DrawingDelegate<S> drawingDelegate) {
|
||||
this.drawingDelegate = drawingDelegate;
|
||||
drawingDelegate.registerDrawable(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class LinearDrawingDelegate extends DrawingDelegate<LinearProgressIndicatorSpec> {
|
||||
private float displayedCornerRadius;
|
||||
private Path displayedTrackPath;
|
||||
private float displayedTrackThickness;
|
||||
private float trackLength;
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public int getPreferredWidth() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public LinearDrawingDelegate(LinearProgressIndicatorSpec linearProgressIndicatorSpec) {
|
||||
super(linearProgressIndicatorSpec);
|
||||
this.trackLength = 300.0f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public int getPreferredHeight() {
|
||||
return ((LinearProgressIndicatorSpec) this.spec).trackThickness;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public void adjustCanvas(Canvas canvas, Rect rect, float f) {
|
||||
this.trackLength = rect.width();
|
||||
float f2 = ((LinearProgressIndicatorSpec) this.spec).trackThickness;
|
||||
canvas.translate(rect.left + (rect.width() / 2.0f), rect.top + (rect.height() / 2.0f) + Math.max(0.0f, (rect.height() - ((LinearProgressIndicatorSpec) this.spec).trackThickness) / 2.0f));
|
||||
if (((LinearProgressIndicatorSpec) this.spec).drawHorizontallyInverse) {
|
||||
canvas.scale(-1.0f, 1.0f);
|
||||
}
|
||||
if ((this.drawable.isShowing() && ((LinearProgressIndicatorSpec) this.spec).showAnimationBehavior == 1) || (this.drawable.isHiding() && ((LinearProgressIndicatorSpec) this.spec).hideAnimationBehavior == 2)) {
|
||||
canvas.scale(1.0f, -1.0f);
|
||||
}
|
||||
if (this.drawable.isShowing() || this.drawable.isHiding()) {
|
||||
canvas.translate(0.0f, (((LinearProgressIndicatorSpec) this.spec).trackThickness * (f - 1.0f)) / 2.0f);
|
||||
}
|
||||
float f3 = this.trackLength;
|
||||
canvas.clipRect((-f3) / 2.0f, (-f2) / 2.0f, f3 / 2.0f, f2 / 2.0f);
|
||||
this.displayedTrackThickness = ((LinearProgressIndicatorSpec) this.spec).trackThickness * f;
|
||||
this.displayedCornerRadius = ((LinearProgressIndicatorSpec) this.spec).trackCornerRadius * f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
public void fillIndicator(Canvas canvas, Paint paint, float f, float f2, int i) {
|
||||
if (f == f2) {
|
||||
return;
|
||||
}
|
||||
float f3 = this.trackLength;
|
||||
float f4 = (-f3) / 2.0f;
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(i);
|
||||
canvas.save();
|
||||
canvas.clipPath(this.displayedTrackPath);
|
||||
float f5 = this.displayedTrackThickness;
|
||||
RectF rectF = new RectF(((f * f3) + f4) - (this.displayedCornerRadius * 2.0f), (-f5) / 2.0f, f4 + (f2 * f3), f5 / 2.0f);
|
||||
float f6 = this.displayedCornerRadius;
|
||||
canvas.drawRoundRect(rectF, f6, f6, paint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.DrawingDelegate
|
||||
void fillTrack(Canvas canvas, Paint paint) {
|
||||
int compositeARGBWithAlpha = MaterialColors.compositeARGBWithAlpha(((LinearProgressIndicatorSpec) this.spec).trackColor, this.drawable.getAlpha());
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(compositeARGBWithAlpha);
|
||||
Path path = new Path();
|
||||
this.displayedTrackPath = path;
|
||||
float f = this.trackLength;
|
||||
float f2 = this.displayedTrackThickness;
|
||||
RectF rectF = new RectF((-f) / 2.0f, (-f2) / 2.0f, f / 2.0f, f2 / 2.0f);
|
||||
float f3 = this.displayedCornerRadius;
|
||||
path.addRoundRect(rectF, f3, f3, Path.Direction.CCW);
|
||||
canvas.drawPath(this.displayedTrackPath, paint);
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.util.Property;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class LinearIndeterminateContiguousAnimatorDelegate extends IndeterminateAnimatorDelegate<ObjectAnimator> {
|
||||
private static final Property<LinearIndeterminateContiguousAnimatorDelegate, Float> ANIMATION_FRACTION = new Property<LinearIndeterminateContiguousAnimatorDelegate, Float>(Float.class, "animationFraction") { // from class: com.google.android.material.progressindicator.LinearIndeterminateContiguousAnimatorDelegate.2
|
||||
@Override // android.util.Property
|
||||
public Float get(LinearIndeterminateContiguousAnimatorDelegate linearIndeterminateContiguousAnimatorDelegate) {
|
||||
return Float.valueOf(linearIndeterminateContiguousAnimatorDelegate.getAnimationFraction());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(LinearIndeterminateContiguousAnimatorDelegate linearIndeterminateContiguousAnimatorDelegate, Float f) {
|
||||
linearIndeterminateContiguousAnimatorDelegate.setAnimationFraction(f.floatValue());
|
||||
}
|
||||
};
|
||||
private static final int DURATION_PER_CYCLE_IN_MS = 333;
|
||||
private static final int TOTAL_DURATION_IN_MS = 667;
|
||||
private float animationFraction;
|
||||
private ObjectAnimator animator;
|
||||
private final BaseProgressIndicatorSpec baseSpec;
|
||||
private boolean dirtyColors;
|
||||
private FastOutSlowInInterpolator interpolator;
|
||||
private int newIndicatorColorIndex;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getAnimationFraction() {
|
||||
return this.animationFraction;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void registerAnimatorsCompleteCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void requestCancelAnimatorAfterCurrentCycle() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void unregisterAnimatorsCompleteCallback() {
|
||||
}
|
||||
|
||||
public LinearIndeterminateContiguousAnimatorDelegate(LinearProgressIndicatorSpec linearProgressIndicatorSpec) {
|
||||
super(3);
|
||||
this.newIndicatorColorIndex = 1;
|
||||
this.baseSpec = linearProgressIndicatorSpec;
|
||||
this.interpolator = new FastOutSlowInInterpolator();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void startAnimator() {
|
||||
maybeInitializeAnimators();
|
||||
resetPropertiesForNewStart();
|
||||
this.animator.start();
|
||||
}
|
||||
|
||||
private void maybeInitializeAnimators() {
|
||||
if (this.animator == null) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, ANIMATION_FRACTION, 0.0f, 1.0f);
|
||||
this.animator = ofFloat;
|
||||
ofFloat.setDuration(333L);
|
||||
this.animator.setInterpolator(null);
|
||||
this.animator.setRepeatCount(-1);
|
||||
this.animator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.LinearIndeterminateContiguousAnimatorDelegate.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
super.onAnimationRepeat(animator);
|
||||
LinearIndeterminateContiguousAnimatorDelegate linearIndeterminateContiguousAnimatorDelegate = LinearIndeterminateContiguousAnimatorDelegate.this;
|
||||
linearIndeterminateContiguousAnimatorDelegate.newIndicatorColorIndex = (linearIndeterminateContiguousAnimatorDelegate.newIndicatorColorIndex + 1) % LinearIndeterminateContiguousAnimatorDelegate.this.baseSpec.indicatorColors.length;
|
||||
LinearIndeterminateContiguousAnimatorDelegate.this.dirtyColors = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void cancelAnimatorImmediately() {
|
||||
ObjectAnimator objectAnimator = this.animator;
|
||||
if (objectAnimator != null) {
|
||||
objectAnimator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void invalidateSpecValues() {
|
||||
resetPropertiesForNewStart();
|
||||
}
|
||||
|
||||
private void updateSegmentPositions(int i) {
|
||||
this.segmentPositions[0] = 0.0f;
|
||||
float fractionInRange = getFractionInRange(i, 0, TOTAL_DURATION_IN_MS);
|
||||
float[] fArr = this.segmentPositions;
|
||||
float[] fArr2 = this.segmentPositions;
|
||||
float interpolation = this.interpolator.getInterpolation(fractionInRange);
|
||||
fArr2[2] = interpolation;
|
||||
fArr[1] = interpolation;
|
||||
float[] fArr3 = this.segmentPositions;
|
||||
float[] fArr4 = this.segmentPositions;
|
||||
float interpolation2 = this.interpolator.getInterpolation(fractionInRange + 0.49925038f);
|
||||
fArr4[4] = interpolation2;
|
||||
fArr3[3] = interpolation2;
|
||||
this.segmentPositions[5] = 1.0f;
|
||||
}
|
||||
|
||||
private void maybeUpdateSegmentColors() {
|
||||
if (!this.dirtyColors || this.segmentPositions[3] >= 1.0f) {
|
||||
return;
|
||||
}
|
||||
this.segmentColors[2] = this.segmentColors[1];
|
||||
this.segmentColors[1] = this.segmentColors[0];
|
||||
this.segmentColors[0] = MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[this.newIndicatorColorIndex], this.drawable.getAlpha());
|
||||
this.dirtyColors = false;
|
||||
}
|
||||
|
||||
void resetPropertiesForNewStart() {
|
||||
this.dirtyColors = true;
|
||||
this.newIndicatorColorIndex = 1;
|
||||
Arrays.fill(this.segmentColors, MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[0], this.drawable.getAlpha()));
|
||||
}
|
||||
|
||||
void setAnimationFraction(float f) {
|
||||
this.animationFraction = f;
|
||||
updateSegmentPositions((int) (f * 333.0f));
|
||||
maybeUpdateSegmentColors();
|
||||
this.drawable.invalidateSelf();
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.Property;
|
||||
import android.view.animation.Interpolator;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import androidx.vectordrawable.graphics.drawable.AnimationUtilsCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class LinearIndeterminateDisjointAnimatorDelegate extends IndeterminateAnimatorDelegate<ObjectAnimator> {
|
||||
private static final int TOTAL_DURATION_IN_MS = 1800;
|
||||
private float animationFraction;
|
||||
private ObjectAnimator animator;
|
||||
Animatable2Compat.AnimationCallback animatorCompleteCallback;
|
||||
private final BaseProgressIndicatorSpec baseSpec;
|
||||
private ObjectAnimator completeEndAnimator;
|
||||
private boolean dirtyColors;
|
||||
private int indicatorColorIndex;
|
||||
private final Interpolator[] interpolatorArray;
|
||||
private static final int[] DURATION_TO_MOVE_SEGMENT_ENDS = {533, 567, 850, 750};
|
||||
private static final int[] DELAY_TO_MOVE_SEGMENT_ENDS = {1267, 1000, 333, 0};
|
||||
private static final Property<LinearIndeterminateDisjointAnimatorDelegate, Float> ANIMATION_FRACTION = new Property<LinearIndeterminateDisjointAnimatorDelegate, Float>(Float.class, "animationFraction") { // from class: com.google.android.material.progressindicator.LinearIndeterminateDisjointAnimatorDelegate.3
|
||||
@Override // android.util.Property
|
||||
public Float get(LinearIndeterminateDisjointAnimatorDelegate linearIndeterminateDisjointAnimatorDelegate) {
|
||||
return Float.valueOf(linearIndeterminateDisjointAnimatorDelegate.getAnimationFraction());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(LinearIndeterminateDisjointAnimatorDelegate linearIndeterminateDisjointAnimatorDelegate, Float f) {
|
||||
linearIndeterminateDisjointAnimatorDelegate.setAnimationFraction(f.floatValue());
|
||||
}
|
||||
};
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getAnimationFraction() {
|
||||
return this.animationFraction;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void registerAnimatorsCompleteCallback(Animatable2Compat.AnimationCallback animationCallback) {
|
||||
this.animatorCompleteCallback = animationCallback;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void unregisterAnimatorsCompleteCallback() {
|
||||
this.animatorCompleteCallback = null;
|
||||
}
|
||||
|
||||
public LinearIndeterminateDisjointAnimatorDelegate(Context context, LinearProgressIndicatorSpec linearProgressIndicatorSpec) {
|
||||
super(2);
|
||||
this.indicatorColorIndex = 0;
|
||||
this.animatorCompleteCallback = null;
|
||||
this.baseSpec = linearProgressIndicatorSpec;
|
||||
this.interpolatorArray = new Interpolator[]{AnimationUtilsCompat.loadInterpolator(context, R.anim.linear_indeterminate_line1_head_interpolator), AnimationUtilsCompat.loadInterpolator(context, R.anim.linear_indeterminate_line1_tail_interpolator), AnimationUtilsCompat.loadInterpolator(context, R.anim.linear_indeterminate_line2_head_interpolator), AnimationUtilsCompat.loadInterpolator(context, R.anim.linear_indeterminate_line2_tail_interpolator)};
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void startAnimator() {
|
||||
maybeInitializeAnimators();
|
||||
resetPropertiesForNewStart();
|
||||
this.animator.start();
|
||||
}
|
||||
|
||||
private void maybeInitializeAnimators() {
|
||||
if (this.animator == null) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, ANIMATION_FRACTION, 0.0f, 1.0f);
|
||||
this.animator = ofFloat;
|
||||
ofFloat.setDuration(1800L);
|
||||
this.animator.setInterpolator(null);
|
||||
this.animator.setRepeatCount(-1);
|
||||
this.animator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.LinearIndeterminateDisjointAnimatorDelegate.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
super.onAnimationRepeat(animator);
|
||||
LinearIndeterminateDisjointAnimatorDelegate linearIndeterminateDisjointAnimatorDelegate = LinearIndeterminateDisjointAnimatorDelegate.this;
|
||||
linearIndeterminateDisjointAnimatorDelegate.indicatorColorIndex = (linearIndeterminateDisjointAnimatorDelegate.indicatorColorIndex + 1) % LinearIndeterminateDisjointAnimatorDelegate.this.baseSpec.indicatorColors.length;
|
||||
LinearIndeterminateDisjointAnimatorDelegate.this.dirtyColors = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.completeEndAnimator == null) {
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this, ANIMATION_FRACTION, 1.0f);
|
||||
this.completeEndAnimator = ofFloat2;
|
||||
ofFloat2.setDuration(1800L);
|
||||
this.completeEndAnimator.setInterpolator(null);
|
||||
this.completeEndAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.progressindicator.LinearIndeterminateDisjointAnimatorDelegate.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
super.onAnimationEnd(animator);
|
||||
LinearIndeterminateDisjointAnimatorDelegate.this.cancelAnimatorImmediately();
|
||||
if (LinearIndeterminateDisjointAnimatorDelegate.this.animatorCompleteCallback != null) {
|
||||
LinearIndeterminateDisjointAnimatorDelegate.this.animatorCompleteCallback.onAnimationEnd(LinearIndeterminateDisjointAnimatorDelegate.this.drawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void cancelAnimatorImmediately() {
|
||||
ObjectAnimator objectAnimator = this.animator;
|
||||
if (objectAnimator != null) {
|
||||
objectAnimator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void requestCancelAnimatorAfterCurrentCycle() {
|
||||
ObjectAnimator objectAnimator = this.completeEndAnimator;
|
||||
if (objectAnimator == null || objectAnimator.isRunning()) {
|
||||
return;
|
||||
}
|
||||
cancelAnimatorImmediately();
|
||||
if (this.drawable.isVisible()) {
|
||||
this.completeEndAnimator.setFloatValues(this.animationFraction, 1.0f);
|
||||
this.completeEndAnimator.setDuration((long) ((1.0f - this.animationFraction) * 1800.0f));
|
||||
this.completeEndAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.IndeterminateAnimatorDelegate
|
||||
public void invalidateSpecValues() {
|
||||
resetPropertiesForNewStart();
|
||||
}
|
||||
|
||||
private void updateSegmentPositions(int i) {
|
||||
for (int i2 = 0; i2 < 4; i2++) {
|
||||
this.segmentPositions[i2] = Math.max(0.0f, Math.min(1.0f, this.interpolatorArray[i2].getInterpolation(getFractionInRange(i, DELAY_TO_MOVE_SEGMENT_ENDS[i2], DURATION_TO_MOVE_SEGMENT_ENDS[i2]))));
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeUpdateSegmentColors() {
|
||||
if (this.dirtyColors) {
|
||||
Arrays.fill(this.segmentColors, MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[this.indicatorColorIndex], this.drawable.getAlpha()));
|
||||
this.dirtyColors = false;
|
||||
}
|
||||
}
|
||||
|
||||
void resetPropertiesForNewStart() {
|
||||
this.indicatorColorIndex = 0;
|
||||
int compositeARGBWithAlpha = MaterialColors.compositeARGBWithAlpha(this.baseSpec.indicatorColors[0], this.drawable.getAlpha());
|
||||
this.segmentColors[0] = compositeARGBWithAlpha;
|
||||
this.segmentColors[1] = compositeARGBWithAlpha;
|
||||
}
|
||||
|
||||
void setAnimationFraction(float f) {
|
||||
this.animationFraction = f;
|
||||
updateSegmentPositions((int) (f * 1800.0f));
|
||||
maybeUpdateSegmentColors();
|
||||
this.drawable.invalidateSelf();
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LinearProgressIndicator extends BaseProgressIndicator<LinearProgressIndicatorSpec> {
|
||||
public static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_LinearProgressIndicator;
|
||||
public static final int INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS = 0;
|
||||
public static final int INDETERMINATE_ANIMATION_TYPE_DISJOINT = 1;
|
||||
public static final int INDICATOR_DIRECTION_END_TO_START = 3;
|
||||
public static final int INDICATOR_DIRECTION_LEFT_TO_RIGHT = 0;
|
||||
public static final int INDICATOR_DIRECTION_RIGHT_TO_LEFT = 1;
|
||||
public static final int INDICATOR_DIRECTION_START_TO_END = 2;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface IndeterminateAnimationType {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface IndicatorDirection {
|
||||
}
|
||||
|
||||
public LinearProgressIndicator(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public LinearProgressIndicator(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.linearProgressIndicatorStyle);
|
||||
}
|
||||
|
||||
public LinearProgressIndicator(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i, DEF_STYLE_RES);
|
||||
initializeDrawables();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public LinearProgressIndicatorSpec createSpec(Context context, AttributeSet attributeSet) {
|
||||
return new LinearProgressIndicatorSpec(context, attributeSet);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
super.onLayout(z, i, i2, i3, i4);
|
||||
LinearProgressIndicatorSpec linearProgressIndicatorSpec = (LinearProgressIndicatorSpec) this.spec;
|
||||
boolean z2 = true;
|
||||
if (((LinearProgressIndicatorSpec) this.spec).indicatorDirection != 1 && ((ViewCompat.getLayoutDirection(this) != 1 || ((LinearProgressIndicatorSpec) this.spec).indicatorDirection != 2) && (ViewCompat.getLayoutDirection(this) != 0 || ((LinearProgressIndicatorSpec) this.spec).indicatorDirection != 3))) {
|
||||
z2 = false;
|
||||
}
|
||||
linearProgressIndicatorSpec.drawHorizontallyInverse = z2;
|
||||
}
|
||||
|
||||
@Override // android.widget.ProgressBar, android.view.View
|
||||
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||||
int paddingLeft = i - (getPaddingLeft() + getPaddingRight());
|
||||
int paddingTop = i2 - (getPaddingTop() + getPaddingBottom());
|
||||
IndeterminateDrawable indeterminateDrawable = getIndeterminateDrawable();
|
||||
if (indeterminateDrawable != null) {
|
||||
indeterminateDrawable.setBounds(0, 0, paddingLeft, paddingTop);
|
||||
}
|
||||
DeterminateDrawable progressDrawable = getProgressDrawable();
|
||||
if (progressDrawable != null) {
|
||||
progressDrawable.setBounds(0, 0, paddingLeft, paddingTop);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeDrawables() {
|
||||
setIndeterminateDrawable(IndeterminateDrawable.createLinearDrawable(getContext(), (LinearProgressIndicatorSpec) this.spec));
|
||||
setProgressDrawable(DeterminateDrawable.createLinearDrawable(getContext(), (LinearProgressIndicatorSpec) this.spec));
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public void setIndicatorColor(int... iArr) {
|
||||
super.setIndicatorColor(iArr);
|
||||
((LinearProgressIndicatorSpec) this.spec).validateSpec();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public void setTrackCornerRadius(int i) {
|
||||
super.setTrackCornerRadius(i);
|
||||
((LinearProgressIndicatorSpec) this.spec).validateSpec();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getIndeterminateAnimationType() {
|
||||
return ((LinearProgressIndicatorSpec) this.spec).indeterminateAnimationType;
|
||||
}
|
||||
|
||||
public void setIndeterminateAnimationType(int i) {
|
||||
if (((LinearProgressIndicatorSpec) this.spec).indeterminateAnimationType == i) {
|
||||
return;
|
||||
}
|
||||
if (visibleToUser() && isIndeterminate()) {
|
||||
throw new IllegalStateException("Cannot change indeterminate animation type while the progress indicator is show in indeterminate mode.");
|
||||
}
|
||||
((LinearProgressIndicatorSpec) this.spec).indeterminateAnimationType = i;
|
||||
((LinearProgressIndicatorSpec) this.spec).validateSpec();
|
||||
if (i == 0) {
|
||||
getIndeterminateDrawable().setAnimatorDelegate(new LinearIndeterminateContiguousAnimatorDelegate((LinearProgressIndicatorSpec) this.spec));
|
||||
} else {
|
||||
getIndeterminateDrawable().setAnimatorDelegate(new LinearIndeterminateDisjointAnimatorDelegate(getContext(), (LinearProgressIndicatorSpec) this.spec));
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getIndicatorDirection() {
|
||||
return ((LinearProgressIndicatorSpec) this.spec).indicatorDirection;
|
||||
}
|
||||
|
||||
public void setIndicatorDirection(int i) {
|
||||
((LinearProgressIndicatorSpec) this.spec).indicatorDirection = i;
|
||||
LinearProgressIndicatorSpec linearProgressIndicatorSpec = (LinearProgressIndicatorSpec) this.spec;
|
||||
boolean z = true;
|
||||
if (i != 1 && ((ViewCompat.getLayoutDirection(this) != 1 || ((LinearProgressIndicatorSpec) this.spec).indicatorDirection != 2) && (ViewCompat.getLayoutDirection(this) != 0 || i != 3))) {
|
||||
z = false;
|
||||
}
|
||||
linearProgressIndicatorSpec.drawHorizontallyInverse = z;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicator
|
||||
public void setProgressCompat(int i, boolean z) {
|
||||
if (this.spec != 0 && ((LinearProgressIndicatorSpec) this.spec).indeterminateAnimationType == 0 && isIndeterminate()) {
|
||||
return;
|
||||
}
|
||||
super.setProgressCompat(i, z);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.google.android.material.progressindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class LinearProgressIndicatorSpec extends BaseProgressIndicatorSpec {
|
||||
boolean drawHorizontallyInverse;
|
||||
public int indeterminateAnimationType;
|
||||
public int indicatorDirection;
|
||||
|
||||
public LinearProgressIndicatorSpec(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.linearProgressIndicatorStyle);
|
||||
}
|
||||
|
||||
public LinearProgressIndicatorSpec(Context context, AttributeSet attributeSet, int i) {
|
||||
this(context, attributeSet, i, LinearProgressIndicator.DEF_STYLE_RES);
|
||||
}
|
||||
|
||||
public LinearProgressIndicatorSpec(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.LinearProgressIndicator, R.attr.linearProgressIndicatorStyle, LinearProgressIndicator.DEF_STYLE_RES, new int[0]);
|
||||
this.indeterminateAnimationType = obtainStyledAttributes.getInt(R.styleable.LinearProgressIndicator_indeterminateAnimationType, 1);
|
||||
this.indicatorDirection = obtainStyledAttributes.getInt(R.styleable.LinearProgressIndicator_indicatorDirectionLinear, 0);
|
||||
obtainStyledAttributes.recycle();
|
||||
validateSpec();
|
||||
this.drawHorizontallyInverse = this.indicatorDirection == 1;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.progressindicator.BaseProgressIndicatorSpec
|
||||
void validateSpec() {
|
||||
if (this.indeterminateAnimationType == 0) {
|
||||
if (this.trackCornerRadius > 0) {
|
||||
throw new IllegalArgumentException("Rounded corners are not supported in contiguous indeterminate animation.");
|
||||
}
|
||||
if (this.indicatorColors.length < 3) {
|
||||
throw new IllegalArgumentException("Contiguous indeterminate animation must be used with 3 or more indicator colors.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user