package androidx.fragment.app; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.collection.ArrayMap; import androidx.core.app.SharedElementCallback; import androidx.core.os.CancellationSignal; import androidx.core.util.Preconditions; import androidx.core.view.OneShotPreDrawListener; import androidx.core.view.ViewCompat; import androidx.core.view.ViewGroupCompat; import androidx.fragment.app.FragmentAnim; import androidx.fragment.app.SpecialEffectsController; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /* loaded from: classes.dex */ class DefaultSpecialEffectsController extends SpecialEffectsController { public DefaultSpecialEffectsController(@NonNull ViewGroup viewGroup) { super(viewGroup); } @Override // androidx.fragment.app.SpecialEffectsController public void executeOperations(@NonNull List list, boolean z) { SpecialEffectsController.Operation operation = null; SpecialEffectsController.Operation operation2 = null; for (SpecialEffectsController.Operation operation3 : list) { SpecialEffectsController.Operation.State from = SpecialEffectsController.Operation.State.from(operation3.getFragment().mView); int i = AnonymousClass10.$SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State[operation3.getFinalState().ordinal()]; if (i == 1 || i == 2 || i == 3) { if (from == SpecialEffectsController.Operation.State.VISIBLE && operation == null) { operation = operation3; } } else if (i == 4 && from != SpecialEffectsController.Operation.State.VISIBLE) { operation2 = operation3; } } if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb = new StringBuilder(); sb.append("Executing operations from "); sb.append(operation); sb.append(" to "); sb.append(operation2); } ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); final ArrayList arrayList3 = new ArrayList(list); syncAnimations(list); for (final SpecialEffectsController.Operation operation4 : list) { CancellationSignal cancellationSignal = new CancellationSignal(); operation4.markStartedSpecialEffect(cancellationSignal); arrayList.add(new AnimationInfo(operation4, cancellationSignal, z)); CancellationSignal cancellationSignal2 = new CancellationSignal(); operation4.markStartedSpecialEffect(cancellationSignal2); boolean z2 = false; if (z) { if (operation4 != operation) { arrayList2.add(new TransitionInfo(operation4, cancellationSignal2, z, z2)); operation4.addCompletionListener(new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.1 @Override // java.lang.Runnable public void run() { if (arrayList3.contains(operation4)) { arrayList3.remove(operation4); DefaultSpecialEffectsController.this.applyContainerChanges(operation4); } } }); } z2 = true; arrayList2.add(new TransitionInfo(operation4, cancellationSignal2, z, z2)); operation4.addCompletionListener(new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.1 @Override // java.lang.Runnable public void run() { if (arrayList3.contains(operation4)) { arrayList3.remove(operation4); DefaultSpecialEffectsController.this.applyContainerChanges(operation4); } } }); } else { if (operation4 != operation2) { arrayList2.add(new TransitionInfo(operation4, cancellationSignal2, z, z2)); operation4.addCompletionListener(new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.1 @Override // java.lang.Runnable public void run() { if (arrayList3.contains(operation4)) { arrayList3.remove(operation4); DefaultSpecialEffectsController.this.applyContainerChanges(operation4); } } }); } z2 = true; arrayList2.add(new TransitionInfo(operation4, cancellationSignal2, z, z2)); operation4.addCompletionListener(new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.1 @Override // java.lang.Runnable public void run() { if (arrayList3.contains(operation4)) { arrayList3.remove(operation4); DefaultSpecialEffectsController.this.applyContainerChanges(operation4); } } }); } } Map startTransitions = startTransitions(arrayList2, arrayList3, z, operation, operation2); startAnimations(arrayList, arrayList3, startTransitions.containsValue(Boolean.TRUE), startTransitions); Iterator it = arrayList3.iterator(); while (it.hasNext()) { applyContainerChanges(it.next()); } arrayList3.clear(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb2 = new StringBuilder(); sb2.append("Completed executing operations from "); sb2.append(operation); sb2.append(" to "); sb2.append(operation2); } } /* renamed from: androidx.fragment.app.DefaultSpecialEffectsController$10, reason: invalid class name */ public static /* synthetic */ class AnonymousClass10 { static final /* synthetic */ int[] $SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State; static { int[] iArr = new int[SpecialEffectsController.Operation.State.values().length]; $SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State = iArr; try { iArr[SpecialEffectsController.Operation.State.GONE.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State[SpecialEffectsController.Operation.State.INVISIBLE.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State[SpecialEffectsController.Operation.State.REMOVED.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$androidx$fragment$app$SpecialEffectsController$Operation$State[SpecialEffectsController.Operation.State.VISIBLE.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } private void syncAnimations(@NonNull List list) { Fragment fragment = list.get(list.size() - 1).getFragment(); for (SpecialEffectsController.Operation operation : list) { operation.getFragment().mAnimationInfo.mEnterAnim = fragment.mAnimationInfo.mEnterAnim; operation.getFragment().mAnimationInfo.mExitAnim = fragment.mAnimationInfo.mExitAnim; operation.getFragment().mAnimationInfo.mPopEnterAnim = fragment.mAnimationInfo.mPopEnterAnim; operation.getFragment().mAnimationInfo.mPopExitAnim = fragment.mAnimationInfo.mPopExitAnim; } } private void startAnimations(@NonNull List list, @NonNull List list2, boolean z, @NonNull Map map) { int i; boolean z2; int i2; final SpecialEffectsController.Operation operation; final ViewGroup container = getContainer(); Context context = container.getContext(); ArrayList arrayList = new ArrayList(); Iterator it = list.iterator(); boolean z3 = false; while (true) { i = 2; if (!it.hasNext()) { break; } final AnimationInfo next = it.next(); if (next.isVisibilityUnchanged()) { next.completeSpecialEffect(); } else { FragmentAnim.AnimationOrAnimator animation = next.getAnimation(context); if (animation == null) { next.completeSpecialEffect(); } else { final Animator animator = animation.animator; if (animator == null) { arrayList.add(next); } else { final SpecialEffectsController.Operation operation2 = next.getOperation(); Fragment fragment = operation2.getFragment(); if (Boolean.TRUE.equals(map.get(operation2))) { if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb = new StringBuilder(); sb.append("Ignoring Animator set on "); sb.append(fragment); sb.append(" as this Fragment was involved in a Transition."); } next.completeSpecialEffect(); } else { boolean z4 = operation2.getFinalState() == SpecialEffectsController.Operation.State.GONE; if (z4) { list2.remove(operation2); } final View view = fragment.mView; container.startViewTransition(view); final boolean z5 = z4; animator.addListener(new AnimatorListenerAdapter() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.2 @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator2) { container.endViewTransition(view); if (z5) { operation2.getFinalState().applyState(view); } next.completeSpecialEffect(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb2 = new StringBuilder(); sb2.append("Animator from operation "); sb2.append(operation2); sb2.append(" has ended."); } } }); animator.setTarget(view); animator.start(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb2 = new StringBuilder(); sb2.append("Animator from operation "); operation = operation2; sb2.append(operation); sb2.append(" has started."); } else { operation = operation2; } next.getSignal().setOnCancelListener(new CancellationSignal.OnCancelListener() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.3 @Override // androidx.core.os.CancellationSignal.OnCancelListener public void onCancel() { animator.end(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb3 = new StringBuilder(); sb3.append("Animator from operation "); sb3.append(operation); sb3.append(" has been canceled."); } } }); z3 = true; } } } } } Iterator it2 = arrayList.iterator(); while (it2.hasNext()) { final AnimationInfo animationInfo = (AnimationInfo) it2.next(); final SpecialEffectsController.Operation operation3 = animationInfo.getOperation(); Fragment fragment2 = operation3.getFragment(); if (z) { if (FragmentManager.isLoggingEnabled(i)) { StringBuilder sb3 = new StringBuilder(); sb3.append("Ignoring Animation set on "); sb3.append(fragment2); sb3.append(" as Animations cannot run alongside Transitions."); } animationInfo.completeSpecialEffect(); } else if (z3) { if (FragmentManager.isLoggingEnabled(i)) { StringBuilder sb4 = new StringBuilder(); sb4.append("Ignoring Animation set on "); sb4.append(fragment2); sb4.append(" as Animations cannot run alongside Animators."); } animationInfo.completeSpecialEffect(); } else { final View view2 = fragment2.mView; Animation animation2 = (Animation) Preconditions.checkNotNull(((FragmentAnim.AnimationOrAnimator) Preconditions.checkNotNull(animationInfo.getAnimation(context))).animation); if (operation3.getFinalState() != SpecialEffectsController.Operation.State.REMOVED) { view2.startAnimation(animation2); animationInfo.completeSpecialEffect(); z2 = z3; i2 = i; } else { container.startViewTransition(view2); FragmentAnim.EndViewTransitionAnimation endViewTransitionAnimation = new FragmentAnim.EndViewTransitionAnimation(animation2, container, view2); z2 = z3; endViewTransitionAnimation.setAnimationListener(new Animation.AnimationListener() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.4 @Override // android.view.animation.Animation.AnimationListener public void onAnimationRepeat(Animation animation3) { } @Override // android.view.animation.Animation.AnimationListener public void onAnimationStart(Animation animation3) { if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb5 = new StringBuilder(); sb5.append("Animation from operation "); sb5.append(operation3); sb5.append(" has reached onAnimationStart."); } } @Override // android.view.animation.Animation.AnimationListener public void onAnimationEnd(Animation animation3) { container.post(new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.4.1 @Override // java.lang.Runnable public void run() { AnonymousClass4 anonymousClass4 = AnonymousClass4.this; container.endViewTransition(view2); animationInfo.completeSpecialEffect(); } }); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb5 = new StringBuilder(); sb5.append("Animation from operation "); sb5.append(operation3); sb5.append(" has ended."); } } }); view2.startAnimation(endViewTransitionAnimation); i2 = 2; if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb5 = new StringBuilder(); sb5.append("Animation from operation "); sb5.append(operation3); sb5.append(" has started."); } } animationInfo.getSignal().setOnCancelListener(new CancellationSignal.OnCancelListener() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.5 @Override // androidx.core.os.CancellationSignal.OnCancelListener public void onCancel() { view2.clearAnimation(); container.endViewTransition(view2); animationInfo.completeSpecialEffect(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb6 = new StringBuilder(); sb6.append("Animation from operation "); sb6.append(operation3); sb6.append(" has been cancelled."); } } }); i = i2; z3 = z2; } } } @NonNull private Map startTransitions(@NonNull List list, @NonNull List list2, final boolean z, @Nullable final SpecialEffectsController.Operation operation, @Nullable final SpecialEffectsController.Operation operation2) { Iterator it; View view; Object obj; ArrayList arrayList; Object obj2; ArrayList arrayList2; SpecialEffectsController.Operation operation3; SpecialEffectsController.Operation operation4; View view2; Object mergeTransitionsTogether; ArrayMap arrayMap; ArrayList arrayList3; DefaultSpecialEffectsController defaultSpecialEffectsController; SpecialEffectsController.Operation operation5; ArrayList arrayList4; Rect rect; FragmentTransitionImpl fragmentTransitionImpl; SpecialEffectsController.Operation operation6; View view3; SharedElementCallback enterTransitionCallback; SharedElementCallback exitTransitionCallback; ArrayList arrayList5; final View view4; String findKeyForValue; ArrayList arrayList6; DefaultSpecialEffectsController defaultSpecialEffectsController2 = this; boolean z2 = z; SpecialEffectsController.Operation operation7 = operation; SpecialEffectsController.Operation operation8 = operation2; HashMap hashMap = new HashMap(); final FragmentTransitionImpl fragmentTransitionImpl2 = null; for (TransitionInfo transitionInfo : list) { if (!transitionInfo.isVisibilityUnchanged()) { FragmentTransitionImpl handlingImpl = transitionInfo.getHandlingImpl(); if (fragmentTransitionImpl2 == null) { fragmentTransitionImpl2 = handlingImpl; } else if (handlingImpl != null && fragmentTransitionImpl2 != handlingImpl) { throw new IllegalArgumentException("Mixing framework transitions and AndroidX transitions is not allowed. Fragment " + transitionInfo.getOperation().getFragment() + " returned Transition " + transitionInfo.getTransition() + " which uses a different Transition type than other Fragments."); } } } if (fragmentTransitionImpl2 == null) { for (TransitionInfo transitionInfo2 : list) { hashMap.put(transitionInfo2.getOperation(), Boolean.FALSE); transitionInfo2.completeSpecialEffect(); } return hashMap; } View view5 = new View(getContainer().getContext()); final Rect rect2 = new Rect(); ArrayList arrayList7 = new ArrayList<>(); ArrayList arrayList8 = new ArrayList<>(); ArrayMap arrayMap2 = new ArrayMap(); Object obj3 = null; View view6 = null; boolean z3 = false; for (TransitionInfo transitionInfo3 : list) { if (!transitionInfo3.hasSharedElementTransition() || operation7 == null || operation8 == null) { arrayMap = arrayMap2; arrayList3 = arrayList8; defaultSpecialEffectsController = defaultSpecialEffectsController2; operation5 = operation7; arrayList4 = arrayList7; rect = rect2; fragmentTransitionImpl = fragmentTransitionImpl2; operation6 = operation8; view3 = view5; view6 = view6; } else { Object wrapTransitionInSet = fragmentTransitionImpl2.wrapTransitionInSet(fragmentTransitionImpl2.cloneTransition(transitionInfo3.getSharedElementTransition())); ArrayList sharedElementSourceNames = operation2.getFragment().getSharedElementSourceNames(); ArrayList sharedElementSourceNames2 = operation.getFragment().getSharedElementSourceNames(); ArrayList sharedElementTargetNames = operation.getFragment().getSharedElementTargetNames(); View view7 = view6; int i = 0; while (i < sharedElementTargetNames.size()) { int indexOf = sharedElementSourceNames.indexOf(sharedElementTargetNames.get(i)); ArrayList arrayList9 = sharedElementTargetNames; if (indexOf != -1) { sharedElementSourceNames.set(indexOf, sharedElementSourceNames2.get(i)); } i++; sharedElementTargetNames = arrayList9; } ArrayList sharedElementTargetNames2 = operation2.getFragment().getSharedElementTargetNames(); if (!z2) { enterTransitionCallback = operation.getFragment().getExitTransitionCallback(); exitTransitionCallback = operation2.getFragment().getEnterTransitionCallback(); } else { enterTransitionCallback = operation.getFragment().getEnterTransitionCallback(); exitTransitionCallback = operation2.getFragment().getExitTransitionCallback(); } int size = sharedElementSourceNames.size(); HashMap hashMap2 = hashMap; int i2 = 0; while (i2 < size) { arrayMap2.put(sharedElementSourceNames.get(i2), sharedElementTargetNames2.get(i2)); i2++; size = size; view5 = view5; } View view8 = view5; if (FragmentManager.isLoggingEnabled(2)) { Iterator it2 = sharedElementTargetNames2.iterator(); while (it2.hasNext()) { String next = it2.next(); Iterator it3 = it2; StringBuilder sb = new StringBuilder(); sb.append("Name: "); sb.append(next); it2 = it3; } Iterator it4 = sharedElementSourceNames.iterator(); while (it4.hasNext()) { String next2 = it4.next(); Iterator it5 = it4; StringBuilder sb2 = new StringBuilder(); sb2.append("Name: "); sb2.append(next2); it4 = it5; } } ArrayMap arrayMap3 = new ArrayMap<>(); defaultSpecialEffectsController2.findNamedViews(arrayMap3, operation.getFragment().mView); arrayMap3.retainAll(sharedElementSourceNames); if (enterTransitionCallback != null) { if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb3 = new StringBuilder(); sb3.append("Executing exit callback for operation "); sb3.append(operation7); } enterTransitionCallback.onMapSharedElements(sharedElementSourceNames, arrayMap3); int size2 = sharedElementSourceNames.size() - 1; while (size2 >= 0) { String str = sharedElementSourceNames.get(size2); View view9 = arrayMap3.get(str); if (view9 == null) { arrayMap2.remove(str); arrayList6 = sharedElementSourceNames; } else { arrayList6 = sharedElementSourceNames; if (!str.equals(ViewCompat.getTransitionName(view9))) { arrayMap2.put(ViewCompat.getTransitionName(view9), (String) arrayMap2.remove(str)); } } size2--; sharedElementSourceNames = arrayList6; } arrayList5 = sharedElementSourceNames; } else { arrayList5 = sharedElementSourceNames; arrayMap2.retainAll(arrayMap3.keySet()); } final ArrayMap arrayMap4 = new ArrayMap<>(); defaultSpecialEffectsController2.findNamedViews(arrayMap4, operation2.getFragment().mView); arrayMap4.retainAll(sharedElementTargetNames2); arrayMap4.retainAll(arrayMap2.values()); if (exitTransitionCallback != null) { if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb4 = new StringBuilder(); sb4.append("Executing enter callback for operation "); sb4.append(operation8); } exitTransitionCallback.onMapSharedElements(sharedElementTargetNames2, arrayMap4); for (int size3 = sharedElementTargetNames2.size() - 1; size3 >= 0; size3--) { String str2 = sharedElementTargetNames2.get(size3); View view10 = arrayMap4.get(str2); if (view10 == null) { String findKeyForValue2 = FragmentTransition.findKeyForValue(arrayMap2, str2); if (findKeyForValue2 != null) { arrayMap2.remove(findKeyForValue2); } } else if (!str2.equals(ViewCompat.getTransitionName(view10)) && (findKeyForValue = FragmentTransition.findKeyForValue(arrayMap2, str2)) != null) { arrayMap2.put(findKeyForValue, ViewCompat.getTransitionName(view10)); } } } else { FragmentTransition.retainValues(arrayMap2, arrayMap4); } defaultSpecialEffectsController2.retainMatchingViews(arrayMap3, arrayMap2.keySet()); defaultSpecialEffectsController2.retainMatchingViews(arrayMap4, arrayMap2.values()); if (arrayMap2.isEmpty()) { arrayList7.clear(); arrayList8.clear(); arrayMap = arrayMap2; arrayList3 = arrayList8; defaultSpecialEffectsController = defaultSpecialEffectsController2; operation5 = operation7; arrayList4 = arrayList7; rect = rect2; fragmentTransitionImpl = fragmentTransitionImpl2; view6 = view7; hashMap = hashMap2; obj3 = null; operation6 = operation8; view3 = view8; } else { FragmentTransition.callSharedElementStartEnd(operation2.getFragment(), operation.getFragment(), z2, arrayMap3, true); ArrayList arrayList10 = arrayList5; arrayMap = arrayMap2; ArrayList arrayList11 = arrayList8; OneShotPreDrawListener.add(getContainer(), new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.6 @Override // java.lang.Runnable public void run() { FragmentTransition.callSharedElementStartEnd(operation2.getFragment(), operation.getFragment(), z, arrayMap4, false); } }); arrayList7.addAll(arrayMap3.values()); if (arrayList10.isEmpty()) { view6 = view7; } else { view6 = arrayMap3.get(arrayList10.get(0)); fragmentTransitionImpl2.setEpicenter(wrapTransitionInSet, view6); } arrayList3 = arrayList11; arrayList3.addAll(arrayMap4.values()); if (sharedElementTargetNames2.isEmpty() || (view4 = arrayMap4.get(sharedElementTargetNames2.get(0))) == null) { defaultSpecialEffectsController = this; } else { defaultSpecialEffectsController = this; OneShotPreDrawListener.add(getContainer(), new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.7 @Override // java.lang.Runnable public void run() { fragmentTransitionImpl2.getBoundsOnScreen(view4, rect2); } }); z3 = true; } fragmentTransitionImpl2.setSharedElementTargets(wrapTransitionInSet, view8, arrayList7); arrayList4 = arrayList7; rect = rect2; view3 = view8; fragmentTransitionImpl = fragmentTransitionImpl2; fragmentTransitionImpl2.scheduleRemoveTargets(wrapTransitionInSet, null, null, null, null, wrapTransitionInSet, arrayList3); Boolean bool = Boolean.TRUE; operation5 = operation; hashMap = hashMap2; hashMap.put(operation5, bool); operation6 = operation2; hashMap.put(operation6, bool); obj3 = wrapTransitionInSet; } } z2 = z; arrayList7 = arrayList4; defaultSpecialEffectsController2 = defaultSpecialEffectsController; rect2 = rect; view5 = view3; operation8 = operation6; arrayMap2 = arrayMap; arrayList8 = arrayList3; operation7 = operation5; fragmentTransitionImpl2 = fragmentTransitionImpl; } View view11 = view6; ArrayMap arrayMap5 = arrayMap2; ArrayList arrayList12 = arrayList8; DefaultSpecialEffectsController defaultSpecialEffectsController3 = defaultSpecialEffectsController2; SpecialEffectsController.Operation operation9 = operation7; ArrayList arrayList13 = arrayList7; Rect rect3 = rect2; FragmentTransitionImpl fragmentTransitionImpl3 = fragmentTransitionImpl2; SpecialEffectsController.Operation operation10 = operation8; View view12 = view5; ArrayList arrayList14 = new ArrayList(); Iterator it6 = list.iterator(); Object obj4 = null; Object obj5 = null; while (it6.hasNext()) { TransitionInfo next3 = it6.next(); if (next3.isVisibilityUnchanged()) { hashMap.put(next3.getOperation(), Boolean.FALSE); next3.completeSpecialEffect(); } else { Object cloneTransition = fragmentTransitionImpl3.cloneTransition(next3.getTransition()); SpecialEffectsController.Operation operation11 = next3.getOperation(); boolean z4 = obj3 != null && (operation11 == operation9 || operation11 == operation10); if (cloneTransition == null) { if (!z4) { hashMap.put(operation11, Boolean.FALSE); next3.completeSpecialEffect(); } arrayList2 = arrayList12; arrayList = arrayList13; it = it6; view = view12; mergeTransitionsTogether = obj4; operation3 = operation10; view2 = view11; } else { it = it6; final ArrayList arrayList15 = new ArrayList<>(); Object obj6 = obj4; defaultSpecialEffectsController3.captureTransitioningViews(arrayList15, operation11.getFragment().mView); if (z4) { if (operation11 == operation9) { arrayList15.removeAll(arrayList13); } else { arrayList15.removeAll(arrayList12); } } if (arrayList15.isEmpty()) { fragmentTransitionImpl3.addTarget(cloneTransition, view12); arrayList2 = arrayList12; arrayList = arrayList13; view = view12; operation4 = operation11; obj2 = obj5; operation3 = operation10; obj = obj6; } else { fragmentTransitionImpl3.addTargets(cloneTransition, arrayList15); view = view12; obj = obj6; arrayList = arrayList13; obj2 = obj5; arrayList2 = arrayList12; operation3 = operation10; fragmentTransitionImpl3.scheduleRemoveTargets(cloneTransition, cloneTransition, arrayList15, null, null, null, null); if (operation11.getFinalState() == SpecialEffectsController.Operation.State.GONE) { operation4 = operation11; list2.remove(operation4); ArrayList arrayList16 = new ArrayList<>(arrayList15); arrayList16.remove(operation4.getFragment().mView); fragmentTransitionImpl3.scheduleHideFragmentView(cloneTransition, operation4.getFragment().mView, arrayList16); OneShotPreDrawListener.add(getContainer(), new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.8 @Override // java.lang.Runnable public void run() { FragmentTransition.setViewVisibility(arrayList15, 4); } }); } else { operation4 = operation11; } } if (operation4.getFinalState() == SpecialEffectsController.Operation.State.VISIBLE) { arrayList14.addAll(arrayList15); if (z3) { fragmentTransitionImpl3.setEpicenter(cloneTransition, rect3); } view2 = view11; } else { view2 = view11; fragmentTransitionImpl3.setEpicenter(cloneTransition, view2); } hashMap.put(operation4, Boolean.TRUE); if (next3.isOverlapAllowed()) { obj5 = fragmentTransitionImpl3.mergeTransitionsTogether(obj2, cloneTransition, null); mergeTransitionsTogether = obj; } else { mergeTransitionsTogether = fragmentTransitionImpl3.mergeTransitionsTogether(obj, cloneTransition, null); obj5 = obj2; } } operation10 = operation3; obj4 = mergeTransitionsTogether; view11 = view2; view12 = view; arrayList13 = arrayList; arrayList12 = arrayList2; it6 = it; } } ArrayList arrayList17 = arrayList12; ArrayList arrayList18 = arrayList13; SpecialEffectsController.Operation operation12 = operation10; Object mergeTransitionsInSequence = fragmentTransitionImpl3.mergeTransitionsInSequence(obj5, obj4, obj3); if (mergeTransitionsInSequence == null) { return hashMap; } for (final TransitionInfo transitionInfo4 : list) { if (!transitionInfo4.isVisibilityUnchanged()) { Object transition = transitionInfo4.getTransition(); final SpecialEffectsController.Operation operation13 = transitionInfo4.getOperation(); boolean z5 = obj3 != null && (operation13 == operation9 || operation13 == operation12); if (transition != null || z5) { if (!ViewCompat.isLaidOut(getContainer())) { if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb5 = new StringBuilder(); sb5.append("SpecialEffectsController: Container "); sb5.append(getContainer()); sb5.append(" has not been laid out. Completing operation "); sb5.append(operation13); } transitionInfo4.completeSpecialEffect(); } else { fragmentTransitionImpl3.setListenerForTransitionEnd(transitionInfo4.getOperation().getFragment(), mergeTransitionsInSequence, transitionInfo4.getSignal(), new Runnable() { // from class: androidx.fragment.app.DefaultSpecialEffectsController.9 @Override // java.lang.Runnable public void run() { transitionInfo4.completeSpecialEffect(); if (FragmentManager.isLoggingEnabled(2)) { StringBuilder sb6 = new StringBuilder(); sb6.append("Transition for operation "); sb6.append(operation13); sb6.append("has completed"); } } }); } } } } if (!ViewCompat.isLaidOut(getContainer())) { return hashMap; } FragmentTransition.setViewVisibility(arrayList14, 4); ArrayList prepareSetNameOverridesReordered = fragmentTransitionImpl3.prepareSetNameOverridesReordered(arrayList17); if (FragmentManager.isLoggingEnabled(2)) { Iterator it7 = arrayList18.iterator(); while (it7.hasNext()) { View next4 = it7.next(); StringBuilder sb6 = new StringBuilder(); sb6.append("View: "); sb6.append(next4); sb6.append(" Name: "); sb6.append(ViewCompat.getTransitionName(next4)); } Iterator it8 = arrayList17.iterator(); while (it8.hasNext()) { View next5 = it8.next(); StringBuilder sb7 = new StringBuilder(); sb7.append("View: "); sb7.append(next5); sb7.append(" Name: "); sb7.append(ViewCompat.getTransitionName(next5)); } } fragmentTransitionImpl3.beginDelayedTransition(getContainer(), mergeTransitionsInSequence); fragmentTransitionImpl3.setNameOverridesReordered(getContainer(), arrayList18, arrayList17, prepareSetNameOverridesReordered, arrayMap5); FragmentTransition.setViewVisibility(arrayList14, 0); fragmentTransitionImpl3.swapSharedElementTargets(obj3, arrayList18, arrayList17); return hashMap; } public void retainMatchingViews(@NonNull ArrayMap arrayMap, @NonNull Collection collection) { Iterator> it = arrayMap.entrySet().iterator(); while (it.hasNext()) { if (!collection.contains(ViewCompat.getTransitionName(it.next().getValue()))) { it.remove(); } } } public void captureTransitioningViews(ArrayList arrayList, View view) { if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; if (ViewGroupCompat.isTransitionGroup(viewGroup)) { if (arrayList.contains(view)) { return; } arrayList.add(viewGroup); return; } int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = viewGroup.getChildAt(i); if (childAt.getVisibility() == 0) { captureTransitioningViews(arrayList, childAt); } } return; } if (arrayList.contains(view)) { return; } arrayList.add(view); } public void findNamedViews(Map map, @NonNull View view) { String transitionName = ViewCompat.getTransitionName(view); if (transitionName != null) { map.put(transitionName, view); } if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = viewGroup.getChildAt(i); if (childAt.getVisibility() == 0) { findNamedViews(map, childAt); } } } } public void applyContainerChanges(@NonNull SpecialEffectsController.Operation operation) { operation.getFinalState().applyState(operation.getFragment().mView); } public static class SpecialEffectsInfo { @NonNull private final SpecialEffectsController.Operation mOperation; @NonNull private final CancellationSignal mSignal; @NonNull public SpecialEffectsController.Operation getOperation() { return this.mOperation; } @NonNull public CancellationSignal getSignal() { return this.mSignal; } public SpecialEffectsInfo(@NonNull SpecialEffectsController.Operation operation, @NonNull CancellationSignal cancellationSignal) { this.mOperation = operation; this.mSignal = cancellationSignal; } public boolean isVisibilityUnchanged() { SpecialEffectsController.Operation.State state; SpecialEffectsController.Operation.State from = SpecialEffectsController.Operation.State.from(this.mOperation.getFragment().mView); SpecialEffectsController.Operation.State finalState = this.mOperation.getFinalState(); return from == finalState || !(from == (state = SpecialEffectsController.Operation.State.VISIBLE) || finalState == state); } public void completeSpecialEffect() { this.mOperation.completeSpecialEffect(this.mSignal); } } public static class AnimationInfo extends SpecialEffectsInfo { @Nullable private FragmentAnim.AnimationOrAnimator mAnimation; private boolean mIsPop; private boolean mLoadedAnim; public AnimationInfo(@NonNull SpecialEffectsController.Operation operation, @NonNull CancellationSignal cancellationSignal, boolean z) { super(operation, cancellationSignal); this.mLoadedAnim = false; this.mIsPop = z; } @Nullable public FragmentAnim.AnimationOrAnimator getAnimation(@NonNull Context context) { if (this.mLoadedAnim) { return this.mAnimation; } FragmentAnim.AnimationOrAnimator loadAnimation = FragmentAnim.loadAnimation(context, getOperation().getFragment(), getOperation().getFinalState() == SpecialEffectsController.Operation.State.VISIBLE, this.mIsPop); this.mAnimation = loadAnimation; this.mLoadedAnim = true; return loadAnimation; } } public static class TransitionInfo extends SpecialEffectsInfo { private final boolean mOverlapAllowed; @Nullable private final Object mSharedElementTransition; @Nullable private final Object mTransition; @Nullable public Object getSharedElementTransition() { return this.mSharedElementTransition; } @Nullable public Object getTransition() { return this.mTransition; } public boolean hasSharedElementTransition() { return this.mSharedElementTransition != null; } public boolean isOverlapAllowed() { return this.mOverlapAllowed; } public TransitionInfo(@NonNull SpecialEffectsController.Operation operation, @NonNull CancellationSignal cancellationSignal, boolean z, boolean z2) { super(operation, cancellationSignal); Object exitTransition; Object enterTransition; boolean allowEnterTransitionOverlap; if (operation.getFinalState() == SpecialEffectsController.Operation.State.VISIBLE) { if (z) { enterTransition = operation.getFragment().getReenterTransition(); } else { enterTransition = operation.getFragment().getEnterTransition(); } this.mTransition = enterTransition; if (z) { allowEnterTransitionOverlap = operation.getFragment().getAllowReturnTransitionOverlap(); } else { allowEnterTransitionOverlap = operation.getFragment().getAllowEnterTransitionOverlap(); } this.mOverlapAllowed = allowEnterTransitionOverlap; } else { if (z) { exitTransition = operation.getFragment().getReturnTransition(); } else { exitTransition = operation.getFragment().getExitTransition(); } this.mTransition = exitTransition; this.mOverlapAllowed = true; } if (!z2) { this.mSharedElementTransition = null; } else if (z) { this.mSharedElementTransition = operation.getFragment().getSharedElementReturnTransition(); } else { this.mSharedElementTransition = operation.getFragment().getSharedElementEnterTransition(); } } @Nullable public FragmentTransitionImpl getHandlingImpl() { FragmentTransitionImpl handlingImpl = getHandlingImpl(this.mTransition); FragmentTransitionImpl handlingImpl2 = getHandlingImpl(this.mSharedElementTransition); if (handlingImpl == null || handlingImpl2 == null || handlingImpl == handlingImpl2) { return handlingImpl != null ? handlingImpl : handlingImpl2; } throw new IllegalArgumentException("Mixing framework transitions and AndroidX transitions is not allowed. Fragment " + getOperation().getFragment() + " returned Transition " + this.mTransition + " which uses a different Transition type than its shared element transition " + this.mSharedElementTransition); } @Nullable private FragmentTransitionImpl getHandlingImpl(Object obj) { if (obj == null) { return null; } FragmentTransitionImpl fragmentTransitionImpl = FragmentTransition.PLATFORM_IMPL; if (fragmentTransitionImpl != null && fragmentTransitionImpl.canHandle(obj)) { return fragmentTransitionImpl; } FragmentTransitionImpl fragmentTransitionImpl2 = FragmentTransition.SUPPORT_IMPL; if (fragmentTransitionImpl2 != null && fragmentTransitionImpl2.canHandle(obj)) { return fragmentTransitionImpl2; } throw new IllegalArgumentException("Transition " + obj + " for fragment " + getOperation().getFragment() + " is not a valid framework Transition or AndroidX Transition"); } } }