package androidx.fragment.app; import android.graphics.Rect; import android.os.Build; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; import androidx.collection.ArrayMap; import androidx.core.app.SharedElementCallback; import androidx.core.view.ViewCompat; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; /* loaded from: classes.dex */ class FragmentTransition { private static final int[] a = {0, 3, 0, 1, 5, 4, 7, 6, 9, 8}; private static final FragmentTransitionImpl b; private static final FragmentTransitionImpl c; static class FragmentContainerTransition { public Fragment a; public boolean b; public BackStackRecord c; public Fragment d; public boolean e; public BackStackRecord f; FragmentContainerTransition() { } } static { b = Build.VERSION.SDK_INT >= 21 ? new FragmentTransitionCompat21() : null; c = a(); } private static FragmentTransitionImpl a() { try { return (FragmentTransitionImpl) Class.forName("androidx.transition.FragmentTransitionSupport").getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); } catch (Exception unused) { return null; } } private static void b(FragmentManagerImpl fragmentManagerImpl, int i, FragmentContainerTransition fragmentContainerTransition, View view, ArrayMap arrayMap) { Fragment fragment; Fragment fragment2; FragmentTransitionImpl a2; Object obj; ViewGroup viewGroup = fragmentManagerImpl.n.a() ? (ViewGroup) fragmentManagerImpl.n.a(i) : null; if (viewGroup == null || (a2 = a((fragment2 = fragmentContainerTransition.d), (fragment = fragmentContainerTransition.a))) == null) { return; } boolean z = fragmentContainerTransition.b; boolean z2 = fragmentContainerTransition.e; ArrayList arrayList = new ArrayList<>(); ArrayList arrayList2 = new ArrayList<>(); Object a3 = a(a2, fragment, z); Object b2 = b(a2, fragment2, z2); Object b3 = b(a2, viewGroup, view, arrayMap, fragmentContainerTransition, arrayList2, arrayList, a3, b2); if (a3 == null && b3 == null) { obj = b2; if (obj == null) { return; } } else { obj = b2; } ArrayList a4 = a(a2, obj, fragment2, arrayList2, view); ArrayList a5 = a(a2, a3, fragment, arrayList, view); a(a5, 4); Object a6 = a(a2, a3, obj, b3, fragment, z); if (a6 != null) { a(a2, obj, fragment2, a4); ArrayList a7 = a2.a(arrayList); a2.a(a6, a3, a5, obj, a4, b3, arrayList); a2.a(viewGroup, a6); a2.a(viewGroup, arrayList2, arrayList, a7, arrayMap); a(a5, 0); a2.b(b3, arrayList2, arrayList); } } static void a(FragmentManagerImpl fragmentManagerImpl, ArrayList arrayList, ArrayList arrayList2, int i, int i2, boolean z) { if (fragmentManagerImpl.l < 1) { return; } SparseArray sparseArray = new SparseArray(); for (int i3 = i; i3 < i2; i3++) { BackStackRecord backStackRecord = arrayList.get(i3); if (arrayList2.get(i3).booleanValue()) { b(backStackRecord, (SparseArray) sparseArray, z); } else { a(backStackRecord, (SparseArray) sparseArray, z); } } if (sparseArray.size() != 0) { View view = new View(fragmentManagerImpl.m.c()); int size = sparseArray.size(); for (int i4 = 0; i4 < size; i4++) { int keyAt = sparseArray.keyAt(i4); ArrayMap a2 = a(keyAt, arrayList, arrayList2, i, i2); FragmentContainerTransition fragmentContainerTransition = (FragmentContainerTransition) sparseArray.valueAt(i4); if (z) { b(fragmentManagerImpl, keyAt, fragmentContainerTransition, view, a2); } else { a(fragmentManagerImpl, keyAt, fragmentContainerTransition, view, a2); } } } } private static ArrayMap a(int i, ArrayList arrayList, ArrayList arrayList2, int i2, int i3) { ArrayList arrayList3; ArrayList arrayList4; ArrayMap arrayMap = new ArrayMap<>(); for (int i4 = i3 - 1; i4 >= i2; i4--) { BackStackRecord backStackRecord = arrayList.get(i4); if (backStackRecord.b(i)) { boolean booleanValue = arrayList2.get(i4).booleanValue(); ArrayList arrayList5 = backStackRecord.r; if (arrayList5 != null) { int size = arrayList5.size(); if (booleanValue) { arrayList3 = backStackRecord.r; arrayList4 = backStackRecord.s; } else { ArrayList arrayList6 = backStackRecord.r; arrayList3 = backStackRecord.s; arrayList4 = arrayList6; } for (int i5 = 0; i5 < size; i5++) { String str = arrayList4.get(i5); String str2 = arrayList3.get(i5); String remove = arrayMap.remove(str2); if (remove != null) { arrayMap.put(str, remove); } else { arrayMap.put(str, str2); } } } } } return arrayMap; } private static Object b(FragmentTransitionImpl fragmentTransitionImpl, Fragment fragment, boolean z) { Object exitTransition; if (fragment == null) { return null; } if (z) { exitTransition = fragment.getReturnTransition(); } else { exitTransition = fragment.getExitTransition(); } return fragmentTransitionImpl.b(exitTransition); } private static Object b(final FragmentTransitionImpl fragmentTransitionImpl, ViewGroup viewGroup, View view, ArrayMap arrayMap, FragmentContainerTransition fragmentContainerTransition, ArrayList arrayList, ArrayList arrayList2, Object obj, Object obj2) { Object obj3; final View view2; final Rect rect; final Fragment fragment = fragmentContainerTransition.a; final Fragment fragment2 = fragmentContainerTransition.d; if (fragment != null) { fragment.getView().setVisibility(0); } if (fragment == null || fragment2 == null) { return null; } final boolean z = fragmentContainerTransition.b; Object a2 = arrayMap.isEmpty() ? null : a(fragmentTransitionImpl, fragment, fragment2, z); ArrayMap b2 = b(fragmentTransitionImpl, arrayMap, a2, fragmentContainerTransition); final ArrayMap a3 = a(fragmentTransitionImpl, arrayMap, a2, fragmentContainerTransition); if (arrayMap.isEmpty()) { if (b2 != null) { b2.clear(); } if (a3 != null) { a3.clear(); } obj3 = null; } else { a(arrayList, b2, arrayMap.keySet()); a(arrayList2, a3, arrayMap.values()); obj3 = a2; } if (obj == null && obj2 == null && obj3 == null) { return null; } a(fragment, fragment2, z, b2, true); if (obj3 != null) { arrayList2.add(view); fragmentTransitionImpl.b(obj3, view, arrayList); a(fragmentTransitionImpl, obj3, obj2, b2, fragmentContainerTransition.e, fragmentContainerTransition.f); Rect rect2 = new Rect(); View a4 = a(a3, fragmentContainerTransition, obj, z); if (a4 != null) { fragmentTransitionImpl.a(obj, rect2); } rect = rect2; view2 = a4; } else { view2 = null; rect = null; } OneShotPreDrawListener.a(viewGroup, new Runnable() { // from class: androidx.fragment.app.FragmentTransition.3 @Override // java.lang.Runnable public void run() { FragmentTransition.a(Fragment.this, fragment2, z, (ArrayMap) a3, false); View view3 = view2; if (view3 != null) { fragmentTransitionImpl.a(view3, rect); } } }); return obj3; } private static void a(FragmentTransitionImpl fragmentTransitionImpl, Object obj, Fragment fragment, final ArrayList arrayList) { if (fragment != null && obj != null && fragment.mAdded && fragment.mHidden && fragment.mHiddenChanged) { fragment.setHideReplaced(true); fragmentTransitionImpl.a(obj, fragment.getView(), arrayList); OneShotPreDrawListener.a(fragment.mContainer, new Runnable() { // from class: androidx.fragment.app.FragmentTransition.1 @Override // java.lang.Runnable public void run() { FragmentTransition.a((ArrayList) arrayList, 4); } }); } } private static void a(FragmentManagerImpl fragmentManagerImpl, int i, FragmentContainerTransition fragmentContainerTransition, View view, ArrayMap arrayMap) { Fragment fragment; Fragment fragment2; FragmentTransitionImpl a2; Object obj; ViewGroup viewGroup = fragmentManagerImpl.n.a() ? (ViewGroup) fragmentManagerImpl.n.a(i) : null; if (viewGroup == null || (a2 = a((fragment2 = fragmentContainerTransition.d), (fragment = fragmentContainerTransition.a))) == null) { return; } boolean z = fragmentContainerTransition.b; boolean z2 = fragmentContainerTransition.e; Object a3 = a(a2, fragment, z); Object b2 = b(a2, fragment2, z2); ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList<>(); Object a4 = a(a2, viewGroup, view, arrayMap, fragmentContainerTransition, (ArrayList) arrayList, arrayList2, a3, b2); if (a3 == null && a4 == null) { obj = b2; if (obj == null) { return; } } else { obj = b2; } ArrayList a5 = a(a2, obj, fragment2, (ArrayList) arrayList, view); Object obj2 = (a5 == null || a5.isEmpty()) ? null : obj; a2.a(a3, view); Object a6 = a(a2, a3, obj2, a4, fragment, fragmentContainerTransition.b); if (a6 != null) { ArrayList arrayList3 = new ArrayList<>(); a2.a(a6, a3, arrayList3, obj2, a5, a4, arrayList2); a(a2, viewGroup, fragment, view, arrayList2, a3, arrayList3, obj2, a5); a2.a((View) viewGroup, arrayList2, (Map) arrayMap); a2.a(viewGroup, a6); a2.a(viewGroup, arrayList2, (Map) arrayMap); } } private static ArrayMap b(FragmentTransitionImpl fragmentTransitionImpl, ArrayMap arrayMap, Object obj, FragmentContainerTransition fragmentContainerTransition) { SharedElementCallback exitTransitionCallback; ArrayList arrayList; if (!arrayMap.isEmpty() && obj != null) { Fragment fragment = fragmentContainerTransition.d; ArrayMap arrayMap2 = new ArrayMap<>(); fragmentTransitionImpl.a((Map) arrayMap2, fragment.getView()); BackStackRecord backStackRecord = fragmentContainerTransition.f; if (fragmentContainerTransition.e) { exitTransitionCallback = fragment.getEnterTransitionCallback(); arrayList = backStackRecord.s; } else { exitTransitionCallback = fragment.getExitTransitionCallback(); arrayList = backStackRecord.r; } arrayMap2.a((Collection) arrayList); if (exitTransitionCallback != null) { exitTransitionCallback.a(arrayList, arrayMap2); for (int size = arrayList.size() - 1; size >= 0; size--) { String str = arrayList.get(size); View view = arrayMap2.get(str); if (view == null) { arrayMap.remove(str); } else if (!str.equals(ViewCompat.p(view))) { arrayMap.put(ViewCompat.p(view), arrayMap.remove(str)); } } } else { arrayMap.a((Collection) arrayMap2.keySet()); } return arrayMap2; } arrayMap.clear(); return null; } private static void a(final FragmentTransitionImpl fragmentTransitionImpl, ViewGroup viewGroup, final Fragment fragment, final View view, final ArrayList arrayList, final Object obj, final ArrayList arrayList2, final Object obj2, final ArrayList arrayList3) { OneShotPreDrawListener.a(viewGroup, new Runnable() { // from class: androidx.fragment.app.FragmentTransition.2 @Override // java.lang.Runnable public void run() { Object obj3 = obj; if (obj3 != null) { fragmentTransitionImpl.b(obj3, view); arrayList2.addAll(FragmentTransition.a(fragmentTransitionImpl, obj, fragment, (ArrayList) arrayList, view)); } if (arrayList3 != null) { if (obj2 != null) { ArrayList arrayList4 = new ArrayList<>(); arrayList4.add(view); fragmentTransitionImpl.a(obj2, arrayList3, arrayList4); } arrayList3.clear(); arrayList3.add(view); } } }); } private static FragmentTransitionImpl a(Fragment fragment, Fragment fragment2) { ArrayList arrayList = new ArrayList(); if (fragment != null) { Object exitTransition = fragment.getExitTransition(); if (exitTransition != null) { arrayList.add(exitTransition); } Object returnTransition = fragment.getReturnTransition(); if (returnTransition != null) { arrayList.add(returnTransition); } Object sharedElementReturnTransition = fragment.getSharedElementReturnTransition(); if (sharedElementReturnTransition != null) { arrayList.add(sharedElementReturnTransition); } } if (fragment2 != null) { Object enterTransition = fragment2.getEnterTransition(); if (enterTransition != null) { arrayList.add(enterTransition); } Object reenterTransition = fragment2.getReenterTransition(); if (reenterTransition != null) { arrayList.add(reenterTransition); } Object sharedElementEnterTransition = fragment2.getSharedElementEnterTransition(); if (sharedElementEnterTransition != null) { arrayList.add(sharedElementEnterTransition); } } if (arrayList.isEmpty()) { return null; } FragmentTransitionImpl fragmentTransitionImpl = b; if (fragmentTransitionImpl != null && a(fragmentTransitionImpl, arrayList)) { return b; } FragmentTransitionImpl fragmentTransitionImpl2 = c; if (fragmentTransitionImpl2 != null && a(fragmentTransitionImpl2, arrayList)) { return c; } if (b == null && c == null) { return null; } throw new IllegalArgumentException("Invalid Transition types"); } public static void b(BackStackRecord backStackRecord, SparseArray sparseArray, boolean z) { if (backStackRecord.a.n.a()) { for (int size = backStackRecord.b.size() - 1; size >= 0; size--) { a(backStackRecord, backStackRecord.b.get(size), sparseArray, true, z); } } } private static boolean a(FragmentTransitionImpl fragmentTransitionImpl, List list) { int size = list.size(); for (int i = 0; i < size; i++) { if (!fragmentTransitionImpl.a(list.get(i))) { return false; } } return true; } private static Object a(FragmentTransitionImpl fragmentTransitionImpl, Fragment fragment, Fragment fragment2, boolean z) { Object sharedElementEnterTransition; if (fragment == null || fragment2 == null) { return null; } if (z) { sharedElementEnterTransition = fragment2.getSharedElementReturnTransition(); } else { sharedElementEnterTransition = fragment.getSharedElementEnterTransition(); } return fragmentTransitionImpl.c(fragmentTransitionImpl.b(sharedElementEnterTransition)); } private static Object a(FragmentTransitionImpl fragmentTransitionImpl, Fragment fragment, boolean z) { Object enterTransition; if (fragment == null) { return null; } if (z) { enterTransition = fragment.getReenterTransition(); } else { enterTransition = fragment.getEnterTransition(); } return fragmentTransitionImpl.b(enterTransition); } private static void a(ArrayList arrayList, ArrayMap arrayMap, Collection collection) { for (int size = arrayMap.size() - 1; size >= 0; size--) { View d = arrayMap.d(size); if (collection.contains(ViewCompat.p(d))) { arrayList.add(d); } } } private static Object a(final FragmentTransitionImpl fragmentTransitionImpl, ViewGroup viewGroup, final View view, final ArrayMap arrayMap, final FragmentContainerTransition fragmentContainerTransition, final ArrayList arrayList, final ArrayList arrayList2, final Object obj, Object obj2) { Object a2; ArrayMap arrayMap2; Object obj3; Rect rect; final Fragment fragment = fragmentContainerTransition.a; final Fragment fragment2 = fragmentContainerTransition.d; if (fragment == null || fragment2 == null) { return null; } final boolean z = fragmentContainerTransition.b; if (arrayMap.isEmpty()) { arrayMap2 = arrayMap; a2 = null; } else { a2 = a(fragmentTransitionImpl, fragment, fragment2, z); arrayMap2 = arrayMap; } ArrayMap b2 = b(fragmentTransitionImpl, arrayMap2, a2, fragmentContainerTransition); if (arrayMap.isEmpty()) { obj3 = null; } else { arrayList.addAll(b2.values()); obj3 = a2; } if (obj == null && obj2 == null && obj3 == null) { return null; } a(fragment, fragment2, z, b2, true); if (obj3 != null) { rect = new Rect(); fragmentTransitionImpl.b(obj3, view, arrayList); a(fragmentTransitionImpl, obj3, obj2, b2, fragmentContainerTransition.e, fragmentContainerTransition.f); if (obj != null) { fragmentTransitionImpl.a(obj, rect); } } else { rect = null; } final Object obj4 = obj3; final Rect rect2 = rect; OneShotPreDrawListener.a(viewGroup, new Runnable() { // from class: androidx.fragment.app.FragmentTransition.4 @Override // java.lang.Runnable public void run() { ArrayMap a3 = FragmentTransition.a(FragmentTransitionImpl.this, (ArrayMap) arrayMap, obj4, fragmentContainerTransition); if (a3 != null) { arrayList2.addAll(a3.values()); arrayList2.add(view); } FragmentTransition.a(fragment, fragment2, z, a3, false); Object obj5 = obj4; if (obj5 != null) { FragmentTransitionImpl.this.b(obj5, arrayList, arrayList2); View a4 = FragmentTransition.a(a3, fragmentContainerTransition, obj, z); if (a4 != null) { FragmentTransitionImpl.this.a(a4, rect2); } } } }); return obj3; } static ArrayMap a(FragmentTransitionImpl fragmentTransitionImpl, ArrayMap arrayMap, Object obj, FragmentContainerTransition fragmentContainerTransition) { SharedElementCallback enterTransitionCallback; ArrayList arrayList; String a2; Fragment fragment = fragmentContainerTransition.a; View view = fragment.getView(); if (!arrayMap.isEmpty() && obj != null && view != null) { ArrayMap arrayMap2 = new ArrayMap<>(); fragmentTransitionImpl.a((Map) arrayMap2, view); BackStackRecord backStackRecord = fragmentContainerTransition.c; if (fragmentContainerTransition.b) { enterTransitionCallback = fragment.getExitTransitionCallback(); arrayList = backStackRecord.r; } else { enterTransitionCallback = fragment.getEnterTransitionCallback(); arrayList = backStackRecord.s; } if (arrayList != null) { arrayMap2.a((Collection) arrayList); arrayMap2.a((Collection) arrayMap.values()); } if (enterTransitionCallback != null) { enterTransitionCallback.a(arrayList, arrayMap2); for (int size = arrayList.size() - 1; size >= 0; size--) { String str = arrayList.get(size); View view2 = arrayMap2.get(str); if (view2 == null) { String a3 = a(arrayMap, str); if (a3 != null) { arrayMap.remove(a3); } } else if (!str.equals(ViewCompat.p(view2)) && (a2 = a(arrayMap, str)) != null) { arrayMap.put(a2, ViewCompat.p(view2)); } } } else { a(arrayMap, arrayMap2); } return arrayMap2; } arrayMap.clear(); return null; } private static String a(ArrayMap arrayMap, String str) { int size = arrayMap.size(); for (int i = 0; i < size; i++) { if (str.equals(arrayMap.d(i))) { return arrayMap.b(i); } } return null; } static View a(ArrayMap arrayMap, FragmentContainerTransition fragmentContainerTransition, Object obj, boolean z) { ArrayList arrayList; String str; BackStackRecord backStackRecord = fragmentContainerTransition.c; if (obj == null || arrayMap == null || (arrayList = backStackRecord.r) == null || arrayList.isEmpty()) { return null; } if (z) { str = backStackRecord.r.get(0); } else { str = backStackRecord.s.get(0); } return arrayMap.get(str); } private static void a(FragmentTransitionImpl fragmentTransitionImpl, Object obj, Object obj2, ArrayMap arrayMap, boolean z, BackStackRecord backStackRecord) { String str; ArrayList arrayList = backStackRecord.r; if (arrayList == null || arrayList.isEmpty()) { return; } if (z) { str = backStackRecord.s.get(0); } else { str = backStackRecord.r.get(0); } View view = arrayMap.get(str); fragmentTransitionImpl.c(obj, view); if (obj2 != null) { fragmentTransitionImpl.c(obj2, view); } } private static void a(ArrayMap arrayMap, ArrayMap arrayMap2) { for (int size = arrayMap.size() - 1; size >= 0; size--) { if (!arrayMap2.containsKey(arrayMap.d(size))) { arrayMap.c(size); } } } static void a(Fragment fragment, Fragment fragment2, boolean z, ArrayMap arrayMap, boolean z2) { SharedElementCallback enterTransitionCallback; if (z) { enterTransitionCallback = fragment2.getEnterTransitionCallback(); } else { enterTransitionCallback = fragment.getEnterTransitionCallback(); } if (enterTransitionCallback != null) { ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); int size = arrayMap == null ? 0 : arrayMap.size(); for (int i = 0; i < size; i++) { arrayList2.add(arrayMap.b(i)); arrayList.add(arrayMap.d(i)); } if (z2) { enterTransitionCallback.b(arrayList2, arrayList, null); } else { enterTransitionCallback.a(arrayList2, arrayList, (List) null); } } } static ArrayList a(FragmentTransitionImpl fragmentTransitionImpl, Object obj, Fragment fragment, ArrayList arrayList, View view) { if (obj == null) { return null; } ArrayList arrayList2 = new ArrayList<>(); View view2 = fragment.getView(); if (view2 != null) { fragmentTransitionImpl.a(arrayList2, view2); } if (arrayList != null) { arrayList2.removeAll(arrayList); } if (arrayList2.isEmpty()) { return arrayList2; } arrayList2.add(view); fragmentTransitionImpl.a(obj, arrayList2); return arrayList2; } static void a(ArrayList arrayList, int i) { if (arrayList == null) { return; } for (int size = arrayList.size() - 1; size >= 0; size--) { arrayList.get(size).setVisibility(i); } } private static Object a(FragmentTransitionImpl fragmentTransitionImpl, Object obj, Object obj2, Object obj3, Fragment fragment, boolean z) { boolean z2; if (obj == null || obj2 == null || fragment == null) { z2 = true; } else if (z) { z2 = fragment.getAllowReturnTransitionOverlap(); } else { z2 = fragment.getAllowEnterTransitionOverlap(); } if (z2) { return fragmentTransitionImpl.b(obj2, obj, obj3); } return fragmentTransitionImpl.a(obj2, obj, obj3); } public static void a(BackStackRecord backStackRecord, SparseArray sparseArray, boolean z) { int size = backStackRecord.b.size(); for (int i = 0; i < size; i++) { a(backStackRecord, backStackRecord.b.get(i), sparseArray, false, z); } } /* JADX WARN: Code restructure failed: missing block: B:100:0x0092, code lost: if (r10.mHidden == false) goto L70; */ /* JADX WARN: Code restructure failed: missing block: B:63:0x0041, code lost: if (r10.mAdded != false) goto L70; */ /* JADX WARN: Code restructure failed: missing block: B:64:0x0094, code lost: r1 = true; */ /* JADX WARN: Code restructure failed: missing block: B:75:0x0076, code lost: r1 = true; */ /* JADX WARN: Removed duplicated region for block: B:26:0x00a2 */ /* JADX WARN: Removed duplicated region for block: B:29:0x00b0 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:42:0x00d5 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:47:0x00e7 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:56:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private static void a(androidx.fragment.app.BackStackRecord r16, androidx.fragment.app.BackStackRecord.Op r17, android.util.SparseArray r18, boolean r19, boolean r20) { /* Method dump skipped, instructions count: 242 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.FragmentTransition.a(androidx.fragment.app.BackStackRecord, androidx.fragment.app.BackStackRecord$Op, android.util.SparseArray, boolean, boolean):void"); } private static FragmentContainerTransition a(FragmentContainerTransition fragmentContainerTransition, SparseArray sparseArray, int i) { if (fragmentContainerTransition != null) { return fragmentContainerTransition; } FragmentContainerTransition fragmentContainerTransition2 = new FragmentContainerTransition(); sparseArray.put(i, fragmentContainerTransition2); return fragmentContainerTransition2; } }