package androidx.transition; import android.animation.TimeInterpolator; import android.content.Context; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.util.AndroidRuntimeException; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import androidx.core.content.res.TypedArrayUtils; import androidx.transition.Transition; import java.util.ArrayList; import java.util.Iterator; /* loaded from: classes2.dex */ public class TransitionSet extends Transition { private static final int FLAG_CHANGE_EPICENTER = 8; private static final int FLAG_CHANGE_INTERPOLATOR = 1; private static final int FLAG_CHANGE_PATH_MOTION = 4; private static final int FLAG_CHANGE_PROPAGATION = 2; public static final int ORDERING_SEQUENTIAL = 1; public static final int ORDERING_TOGETHER = 0; private int mChangeFlags; int mCurrentListeners; private boolean mPlayTogether; boolean mStarted; private ArrayList mTransitions; public int getOrdering() { return !this.mPlayTogether ? 1 : 0; } @Override // androidx.transition.Transition public /* bridge */ /* synthetic */ Transition addTarget(Class cls) { return addTarget((Class) cls); } @Override // androidx.transition.Transition public /* bridge */ /* synthetic */ Transition removeTarget(Class cls) { return removeTarget((Class) cls); } public TransitionSet() { this.mTransitions = new ArrayList<>(); this.mPlayTogether = true; this.mStarted = false; this.mChangeFlags = 0; } public TransitionSet(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.mTransitions = new ArrayList<>(); this.mPlayTogether = true; this.mStarted = false; this.mChangeFlags = 0; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Styleable.TRANSITION_SET); setOrdering(TypedArrayUtils.getNamedInt(obtainStyledAttributes, (XmlResourceParser) attributeSet, "transitionOrdering", 0, 0)); obtainStyledAttributes.recycle(); } public TransitionSet setOrdering(int i) { if (i == 0) { this.mPlayTogether = true; } else { if (i != 1) { throw new AndroidRuntimeException("Invalid parameter for TransitionSet ordering: " + i); } this.mPlayTogether = false; } return this; } public TransitionSet addTransition(Transition transition) { addTransitionInternal(transition); if (this.mDuration >= 0) { transition.setDuration(this.mDuration); } if ((this.mChangeFlags & 1) != 0) { transition.setInterpolator(getInterpolator()); } if ((this.mChangeFlags & 2) != 0) { transition.setPropagation(getPropagation()); } if ((this.mChangeFlags & 4) != 0) { transition.setPathMotion(getPathMotion()); } if ((this.mChangeFlags & 8) != 0) { transition.setEpicenterCallback(getEpicenterCallback()); } return this; } private void addTransitionInternal(Transition transition) { this.mTransitions.add(transition); transition.mParent = this; } public int getTransitionCount() { return this.mTransitions.size(); } public Transition getTransitionAt(int i) { if (i < 0 || i >= this.mTransitions.size()) { return null; } return this.mTransitions.get(i); } @Override // androidx.transition.Transition public TransitionSet setDuration(long j) { ArrayList arrayList; super.setDuration(j); if (this.mDuration >= 0 && (arrayList = this.mTransitions) != null) { int size = arrayList.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).setDuration(j); } } return this; } @Override // androidx.transition.Transition public TransitionSet setStartDelay(long j) { return (TransitionSet) super.setStartDelay(j); } @Override // androidx.transition.Transition public TransitionSet setInterpolator(TimeInterpolator timeInterpolator) { this.mChangeFlags |= 1; ArrayList arrayList = this.mTransitions; if (arrayList != null) { int size = arrayList.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).setInterpolator(timeInterpolator); } } return (TransitionSet) super.setInterpolator(timeInterpolator); } @Override // androidx.transition.Transition public TransitionSet addTarget(View view) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).addTarget(view); } return (TransitionSet) super.addTarget(view); } @Override // androidx.transition.Transition public TransitionSet addTarget(int i) { for (int i2 = 0; i2 < this.mTransitions.size(); i2++) { this.mTransitions.get(i2).addTarget(i); } return (TransitionSet) super.addTarget(i); } @Override // androidx.transition.Transition public TransitionSet addTarget(String str) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).addTarget(str); } return (TransitionSet) super.addTarget(str); } @Override // androidx.transition.Transition public TransitionSet addTarget(Class cls) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).addTarget(cls); } return (TransitionSet) super.addTarget(cls); } @Override // androidx.transition.Transition public TransitionSet addListener(Transition.TransitionListener transitionListener) { return (TransitionSet) super.addListener(transitionListener); } @Override // androidx.transition.Transition public TransitionSet removeTarget(int i) { for (int i2 = 0; i2 < this.mTransitions.size(); i2++) { this.mTransitions.get(i2).removeTarget(i); } return (TransitionSet) super.removeTarget(i); } @Override // androidx.transition.Transition public TransitionSet removeTarget(View view) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).removeTarget(view); } return (TransitionSet) super.removeTarget(view); } @Override // androidx.transition.Transition public TransitionSet removeTarget(Class cls) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).removeTarget(cls); } return (TransitionSet) super.removeTarget(cls); } @Override // androidx.transition.Transition public TransitionSet removeTarget(String str) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).removeTarget(str); } return (TransitionSet) super.removeTarget(str); } @Override // androidx.transition.Transition public Transition excludeTarget(View view, boolean z) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).excludeTarget(view, z); } return super.excludeTarget(view, z); } @Override // androidx.transition.Transition public Transition excludeTarget(String str, boolean z) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).excludeTarget(str, z); } return super.excludeTarget(str, z); } @Override // androidx.transition.Transition public Transition excludeTarget(int i, boolean z) { for (int i2 = 0; i2 < this.mTransitions.size(); i2++) { this.mTransitions.get(i2).excludeTarget(i, z); } return super.excludeTarget(i, z); } @Override // androidx.transition.Transition public Transition excludeTarget(Class cls, boolean z) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).excludeTarget(cls, z); } return super.excludeTarget(cls, z); } @Override // androidx.transition.Transition public TransitionSet removeListener(Transition.TransitionListener transitionListener) { return (TransitionSet) super.removeListener(transitionListener); } @Override // androidx.transition.Transition public void setPathMotion(PathMotion pathMotion) { super.setPathMotion(pathMotion); this.mChangeFlags |= 4; if (this.mTransitions != null) { for (int i = 0; i < this.mTransitions.size(); i++) { this.mTransitions.get(i).setPathMotion(pathMotion); } } } public TransitionSet removeTransition(Transition transition) { this.mTransitions.remove(transition); transition.mParent = null; return this; } private void setupStartEndListeners() { TransitionSetListener transitionSetListener = new TransitionSetListener(this); Iterator it = this.mTransitions.iterator(); while (it.hasNext()) { it.next().addListener(transitionSetListener); } this.mCurrentListeners = this.mTransitions.size(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class TransitionSetListener extends TransitionListenerAdapter { TransitionSet mTransitionSet; TransitionSetListener(TransitionSet transitionSet) { this.mTransitionSet = transitionSet; } @Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener public void onTransitionStart(Transition transition) { if (this.mTransitionSet.mStarted) { return; } this.mTransitionSet.start(); this.mTransitionSet.mStarted = true; } @Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener public void onTransitionEnd(Transition transition) { TransitionSet transitionSet = this.mTransitionSet; transitionSet.mCurrentListeners--; if (this.mTransitionSet.mCurrentListeners == 0) { this.mTransitionSet.mStarted = false; this.mTransitionSet.end(); } transition.removeListener(this); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // androidx.transition.Transition public void createAnimators(ViewGroup viewGroup, TransitionValuesMaps transitionValuesMaps, TransitionValuesMaps transitionValuesMaps2, ArrayList arrayList, ArrayList arrayList2) { long startDelay = getStartDelay(); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { Transition transition = this.mTransitions.get(i); if (startDelay > 0 && (this.mPlayTogether || i == 0)) { long startDelay2 = transition.getStartDelay(); if (startDelay2 > 0) { transition.setStartDelay(startDelay2 + startDelay); } else { transition.setStartDelay(startDelay); } } transition.createAnimators(viewGroup, transitionValuesMaps, transitionValuesMaps2, arrayList, arrayList2); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // androidx.transition.Transition public void runAnimators() { if (this.mTransitions.isEmpty()) { start(); end(); return; } setupStartEndListeners(); if (!this.mPlayTogether) { for (int i = 1; i < this.mTransitions.size(); i++) { Transition transition = this.mTransitions.get(i - 1); final Transition transition2 = this.mTransitions.get(i); transition.addListener(new TransitionListenerAdapter() { // from class: androidx.transition.TransitionSet.1 @Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener public void onTransitionEnd(Transition transition3) { transition2.runAnimators(); transition3.removeListener(this); } }); } Transition transition3 = this.mTransitions.get(0); if (transition3 != null) { transition3.runAnimators(); return; } return; } Iterator it = this.mTransitions.iterator(); while (it.hasNext()) { it.next().runAnimators(); } } @Override // androidx.transition.Transition public void captureStartValues(TransitionValues transitionValues) { if (isValidTarget(transitionValues.view)) { Iterator it = this.mTransitions.iterator(); while (it.hasNext()) { Transition next = it.next(); if (next.isValidTarget(transitionValues.view)) { next.captureStartValues(transitionValues); transitionValues.mTargetedTransitions.add(next); } } } } @Override // androidx.transition.Transition public void captureEndValues(TransitionValues transitionValues) { if (isValidTarget(transitionValues.view)) { Iterator it = this.mTransitions.iterator(); while (it.hasNext()) { Transition next = it.next(); if (next.isValidTarget(transitionValues.view)) { next.captureEndValues(transitionValues); transitionValues.mTargetedTransitions.add(next); } } } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // androidx.transition.Transition public void capturePropagationValues(TransitionValues transitionValues) { super.capturePropagationValues(transitionValues); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).capturePropagationValues(transitionValues); } } @Override // androidx.transition.Transition public void pause(View view) { super.pause(view); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).pause(view); } } @Override // androidx.transition.Transition public void resume(View view) { super.resume(view); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).resume(view); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // androidx.transition.Transition public void cancel() { super.cancel(); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).cancel(); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // androidx.transition.Transition public void forceToEnd(ViewGroup viewGroup) { super.forceToEnd(viewGroup); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).forceToEnd(viewGroup); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // androidx.transition.Transition public void setCanRemoveViews(boolean z) { super.setCanRemoveViews(z); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).setCanRemoveViews(z); } } @Override // androidx.transition.Transition public void setPropagation(TransitionPropagation transitionPropagation) { super.setPropagation(transitionPropagation); this.mChangeFlags |= 2; int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).setPropagation(transitionPropagation); } } @Override // androidx.transition.Transition public void setEpicenterCallback(Transition.EpicenterCallback epicenterCallback) { super.setEpicenterCallback(epicenterCallback); this.mChangeFlags |= 8; int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { this.mTransitions.get(i).setEpicenterCallback(epicenterCallback); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // androidx.transition.Transition public String toString(String str) { String transition = super.toString(str); for (int i = 0; i < this.mTransitions.size(); i++) { transition = transition + "\n" + this.mTransitions.get(i).toString(str + " "); } return transition; } @Override // androidx.transition.Transition /* renamed from: clone */ public Transition mo5320clone() { TransitionSet transitionSet = (TransitionSet) super.mo5320clone(); transitionSet.mTransitions = new ArrayList<>(); int size = this.mTransitions.size(); for (int i = 0; i < size; i++) { transitionSet.addTransitionInternal(this.mTransitions.get(i).mo5320clone()); } return transitionSet; } }