package androidx.appcompat.view; import android.view.View; import android.view.animation.Interpolator; import androidx.core.view.ViewPropertyAnimatorCompat; import androidx.core.view.ViewPropertyAnimatorListener; import androidx.core.view.ViewPropertyAnimatorListenerAdapter; import java.util.ArrayList; import java.util.Iterator; /* loaded from: classes.dex */ public class ViewPropertyAnimatorCompatSet { private Interpolator mInterpolator; private boolean mIsStarted; ViewPropertyAnimatorListener mListener; private long mDuration = -1; private final ViewPropertyAnimatorListenerAdapter mProxyListener = new ViewPropertyAnimatorListenerAdapter() { // from class: androidx.appcompat.view.ViewPropertyAnimatorCompatSet.1 private boolean mProxyStarted = false; private int mProxyEndCount = 0; @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener public void onAnimationStart(View view) { if (this.mProxyStarted) { return; } this.mProxyStarted = true; if (ViewPropertyAnimatorCompatSet.this.mListener != null) { ViewPropertyAnimatorCompatSet.this.mListener.onAnimationStart(null); } } void onEnd() { this.mProxyEndCount = 0; this.mProxyStarted = false; ViewPropertyAnimatorCompatSet.this.onAnimationsEnded(); } @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener public void onAnimationEnd(View view) { int i = this.mProxyEndCount + 1; this.mProxyEndCount = i; if (i == ViewPropertyAnimatorCompatSet.this.mAnimators.size()) { if (ViewPropertyAnimatorCompatSet.this.mListener != null) { ViewPropertyAnimatorCompatSet.this.mListener.onAnimationEnd(null); } onEnd(); } } }; final ArrayList mAnimators = new ArrayList<>(); void onAnimationsEnded() { this.mIsStarted = false; } public ViewPropertyAnimatorCompatSet setDuration(long j) { if (!this.mIsStarted) { this.mDuration = j; } return this; } public ViewPropertyAnimatorCompatSet setInterpolator(Interpolator interpolator) { if (!this.mIsStarted) { this.mInterpolator = interpolator; } return this; } public ViewPropertyAnimatorCompatSet setListener(ViewPropertyAnimatorListener viewPropertyAnimatorListener) { if (!this.mIsStarted) { this.mListener = viewPropertyAnimatorListener; } return this; } public ViewPropertyAnimatorCompatSet play(ViewPropertyAnimatorCompat viewPropertyAnimatorCompat) { if (!this.mIsStarted) { this.mAnimators.add(viewPropertyAnimatorCompat); } return this; } public ViewPropertyAnimatorCompatSet playSequentially(ViewPropertyAnimatorCompat viewPropertyAnimatorCompat, ViewPropertyAnimatorCompat viewPropertyAnimatorCompat2) { this.mAnimators.add(viewPropertyAnimatorCompat); viewPropertyAnimatorCompat2.setStartDelay(viewPropertyAnimatorCompat.getDuration()); this.mAnimators.add(viewPropertyAnimatorCompat2); return this; } public void start() { if (this.mIsStarted) { return; } Iterator it = this.mAnimators.iterator(); while (it.hasNext()) { ViewPropertyAnimatorCompat next = it.next(); long j = this.mDuration; if (j >= 0) { next.setDuration(j); } Interpolator interpolator = this.mInterpolator; if (interpolator != null) { next.setInterpolator(interpolator); } if (this.mListener != null) { next.setListener(this.mProxyListener); } next.start(); } this.mIsStarted = true; } public void cancel() { if (this.mIsStarted) { Iterator it = this.mAnimators.iterator(); while (it.hasNext()) { it.next().cancel(); } this.mIsStarted = false; } } }