package androidx.fragment.app; import android.app.Activity; import android.content.res.Resources; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import androidx.core.view.n0; import androidx.fragment.app.b0; import androidx.lifecycle.e; /* loaded from: classes.dex */ class t { /* renamed from: a, reason: collision with root package name */ private final m f1921a; /* renamed from: b, reason: collision with root package name */ private final u f1922b; /* renamed from: c, reason: collision with root package name */ private final Fragment f1923c; /* renamed from: d, reason: collision with root package name */ private boolean f1924d = false; /* renamed from: e, reason: collision with root package name */ private int f1925e = -1; class a implements View.OnAttachStateChangeListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ View f1926a; a(View view) { this.f1926a = view; } @Override // android.view.View.OnAttachStateChangeListener public void onViewAttachedToWindow(View view) { this.f1926a.removeOnAttachStateChangeListener(this); n0.k0(this.f1926a); } @Override // android.view.View.OnAttachStateChangeListener public void onViewDetachedFromWindow(View view) { } } static /* synthetic */ class b { /* renamed from: a, reason: collision with root package name */ static final /* synthetic */ int[] f1928a; static { int[] iArr = new int[e.c.values().length]; f1928a = iArr; try { iArr[e.c.RESUMED.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { f1928a[e.c.STARTED.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { f1928a[e.c.CREATED.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { f1928a[e.c.INITIALIZED.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } t(m mVar, u uVar, Fragment fragment) { this.f1921a = mVar; this.f1922b = uVar; this.f1923c = fragment; } private boolean l(View view) { if (view == this.f1923c.mView) { return true; } for (ViewParent parent = view.getParent(); parent != null; parent = parent.getParent()) { if (parent == this.f1923c.mView) { return true; } } return false; } private Bundle q() { Bundle bundle = new Bundle(); this.f1923c.performSaveInstanceState(bundle); this.f1921a.j(this.f1923c, bundle, false); if (bundle.isEmpty()) { bundle = null; } if (this.f1923c.mView != null) { s(); } if (this.f1923c.mSavedViewState != null) { if (bundle == null) { bundle = new Bundle(); } bundle.putSparseParcelableArray("android:view_state", this.f1923c.mSavedViewState); } if (this.f1923c.mSavedViewRegistryState != null) { if (bundle == null) { bundle = new Bundle(); } bundle.putBundle("android:view_registry_state", this.f1923c.mSavedViewRegistryState); } if (!this.f1923c.mUserVisibleHint) { if (bundle == null) { bundle = new Bundle(); } bundle.putBoolean("android:user_visible_hint", this.f1923c.mUserVisibleHint); } return bundle; } void a() { if (n.E0(3)) { Log.d("FragmentManager", "moveto ACTIVITY_CREATED: " + this.f1923c); } Fragment fragment = this.f1923c; fragment.performActivityCreated(fragment.mSavedFragmentState); m mVar = this.f1921a; Fragment fragment2 = this.f1923c; mVar.a(fragment2, fragment2.mSavedFragmentState, false); } void b() { int j10 = this.f1922b.j(this.f1923c); Fragment fragment = this.f1923c; fragment.mContainer.addView(fragment.mView, j10); } void c() { if (n.E0(3)) { Log.d("FragmentManager", "moveto ATTACHED: " + this.f1923c); } Fragment fragment = this.f1923c; Fragment fragment2 = fragment.mTarget; t tVar = null; if (fragment2 != null) { t m10 = this.f1922b.m(fragment2.mWho); if (m10 == null) { throw new IllegalStateException("Fragment " + this.f1923c + " declared target fragment " + this.f1923c.mTarget + " that does not belong to this FragmentManager!"); } Fragment fragment3 = this.f1923c; fragment3.mTargetWho = fragment3.mTarget.mWho; fragment3.mTarget = null; tVar = m10; } else { String str = fragment.mTargetWho; if (str != null && (tVar = this.f1922b.m(str)) == null) { throw new IllegalStateException("Fragment " + this.f1923c + " declared target fragment " + this.f1923c.mTargetWho + " that does not belong to this FragmentManager!"); } } if (tVar != null && (n.P || tVar.k().mState < 1)) { tVar.m(); } Fragment fragment4 = this.f1923c; fragment4.mHost = fragment4.mFragmentManager.s0(); Fragment fragment5 = this.f1923c; fragment5.mParentFragment = fragment5.mFragmentManager.v0(); this.f1921a.g(this.f1923c, false); this.f1923c.performAttach(); this.f1921a.b(this.f1923c, false); } int d() { Fragment fragment; ViewGroup viewGroup; Fragment fragment2 = this.f1923c; if (fragment2.mFragmentManager == null) { return fragment2.mState; } int i10 = this.f1925e; int i11 = b.f1928a[fragment2.mMaxState.ordinal()]; if (i11 != 1) { i10 = i11 != 2 ? i11 != 3 ? i11 != 4 ? Math.min(i10, -1) : Math.min(i10, 0) : Math.min(i10, 1) : Math.min(i10, 5); } Fragment fragment3 = this.f1923c; if (fragment3.mFromLayout) { if (fragment3.mInLayout) { i10 = Math.max(this.f1925e, 2); View view = this.f1923c.mView; if (view != null && view.getParent() == null) { i10 = Math.min(i10, 2); } } else { i10 = this.f1925e < 4 ? Math.min(i10, fragment3.mState) : Math.min(i10, 1); } } if (!this.f1923c.mAdded) { i10 = Math.min(i10, 1); } b0.e.b l10 = (!n.P || (viewGroup = (fragment = this.f1923c).mContainer) == null) ? null : b0.n(viewGroup, fragment.getParentFragmentManager()).l(this); if (l10 == b0.e.b.ADDING) { i10 = Math.min(i10, 6); } else if (l10 == b0.e.b.REMOVING) { i10 = Math.max(i10, 3); } else { Fragment fragment4 = this.f1923c; if (fragment4.mRemoving) { i10 = fragment4.isInBackStack() ? Math.min(i10, 1) : Math.min(i10, -1); } } Fragment fragment5 = this.f1923c; if (fragment5.mDeferStart && fragment5.mState < 5) { i10 = Math.min(i10, 4); } if (n.E0(2)) { Log.v("FragmentManager", "computeExpectedState() of " + i10 + " for " + this.f1923c); } return i10; } void e() { if (n.E0(3)) { Log.d("FragmentManager", "moveto CREATED: " + this.f1923c); } Fragment fragment = this.f1923c; if (fragment.mIsCreated) { fragment.restoreChildFragmentState(fragment.mSavedFragmentState); this.f1923c.mState = 1; return; } this.f1921a.h(fragment, fragment.mSavedFragmentState, false); Fragment fragment2 = this.f1923c; fragment2.performCreate(fragment2.mSavedFragmentState); m mVar = this.f1921a; Fragment fragment3 = this.f1923c; mVar.c(fragment3, fragment3.mSavedFragmentState, false); } void f() { String str; if (this.f1923c.mFromLayout) { return; } if (n.E0(3)) { Log.d("FragmentManager", "moveto CREATE_VIEW: " + this.f1923c); } Fragment fragment = this.f1923c; LayoutInflater performGetLayoutInflater = fragment.performGetLayoutInflater(fragment.mSavedFragmentState); Fragment fragment2 = this.f1923c; ViewGroup viewGroup = fragment2.mContainer; if (viewGroup == null) { int i10 = fragment2.mContainerId; if (i10 == 0) { viewGroup = null; } else { if (i10 == -1) { throw new IllegalArgumentException("Cannot create fragment " + this.f1923c + " for a container view with no id"); } viewGroup = (ViewGroup) fragment2.mFragmentManager.n0().c(this.f1923c.mContainerId); if (viewGroup == null) { Fragment fragment3 = this.f1923c; if (!fragment3.mRestored) { try { str = fragment3.getResources().getResourceName(this.f1923c.mContainerId); } catch (Resources.NotFoundException unused) { str = "unknown"; } throw new IllegalArgumentException("No view found for id 0x" + Integer.toHexString(this.f1923c.mContainerId) + " (" + str + ") for fragment " + this.f1923c); } } } } Fragment fragment4 = this.f1923c; fragment4.mContainer = viewGroup; fragment4.performCreateView(performGetLayoutInflater, viewGroup, fragment4.mSavedFragmentState); View view = this.f1923c.mView; if (view != null) { boolean z10 = false; view.setSaveFromParentEnabled(false); Fragment fragment5 = this.f1923c; fragment5.mView.setTag(f0.b.f9489a, fragment5); if (viewGroup != null) { b(); } Fragment fragment6 = this.f1923c; if (fragment6.mHidden) { fragment6.mView.setVisibility(8); } if (n0.Q(this.f1923c.mView)) { n0.k0(this.f1923c.mView); } else { View view2 = this.f1923c.mView; view2.addOnAttachStateChangeListener(new a(view2)); } this.f1923c.performViewCreated(); m mVar = this.f1921a; Fragment fragment7 = this.f1923c; mVar.m(fragment7, fragment7.mView, fragment7.mSavedFragmentState, false); int visibility = this.f1923c.mView.getVisibility(); float alpha = this.f1923c.mView.getAlpha(); if (n.P) { this.f1923c.setPostOnViewCreatedAlpha(alpha); Fragment fragment8 = this.f1923c; if (fragment8.mContainer != null && visibility == 0) { View findFocus = fragment8.mView.findFocus(); if (findFocus != null) { this.f1923c.setFocusedView(findFocus); if (n.E0(2)) { Log.v("FragmentManager", "requestFocus: Saved focused view " + findFocus + " for Fragment " + this.f1923c); } } this.f1923c.mView.setAlpha(0.0f); } } else { Fragment fragment9 = this.f1923c; if (visibility == 0 && fragment9.mContainer != null) { z10 = true; } fragment9.mIsNewlyAdded = z10; } } this.f1923c.mState = 2; } void g() { Fragment f10; if (n.E0(3)) { Log.d("FragmentManager", "movefrom CREATED: " + this.f1923c); } Fragment fragment = this.f1923c; boolean z10 = true; boolean z11 = fragment.mRemoving && !fragment.isInBackStack(); if (!(z11 || this.f1922b.o().p(this.f1923c))) { String str = this.f1923c.mTargetWho; if (str != null && (f10 = this.f1922b.f(str)) != null && f10.mRetainInstance) { this.f1923c.mTarget = f10; } this.f1923c.mState = 0; return; } k kVar = this.f1923c.mHost; if (kVar instanceof androidx.lifecycle.x) { z10 = this.f1922b.o().m(); } else if (kVar.f() instanceof Activity) { z10 = true ^ ((Activity) kVar.f()).isChangingConfigurations(); } if (z11 || z10) { this.f1922b.o().g(this.f1923c); } this.f1923c.performDestroy(); this.f1921a.d(this.f1923c, false); for (t tVar : this.f1922b.k()) { if (tVar != null) { Fragment k10 = tVar.k(); if (this.f1923c.mWho.equals(k10.mTargetWho)) { k10.mTarget = this.f1923c; k10.mTargetWho = null; } } } Fragment fragment2 = this.f1923c; String str2 = fragment2.mTargetWho; if (str2 != null) { fragment2.mTarget = this.f1922b.f(str2); } this.f1922b.q(this); } void h() { View view; if (n.E0(3)) { Log.d("FragmentManager", "movefrom CREATE_VIEW: " + this.f1923c); } Fragment fragment = this.f1923c; ViewGroup viewGroup = fragment.mContainer; if (viewGroup != null && (view = fragment.mView) != null) { viewGroup.removeView(view); } this.f1923c.performDestroyView(); this.f1921a.n(this.f1923c, false); Fragment fragment2 = this.f1923c; fragment2.mContainer = null; fragment2.mView = null; fragment2.mViewLifecycleOwner = null; fragment2.mViewLifecycleOwnerLiveData.n(null); this.f1923c.mInLayout = false; } void i() { if (n.E0(3)) { Log.d("FragmentManager", "movefrom ATTACHED: " + this.f1923c); } this.f1923c.performDetach(); boolean z10 = false; this.f1921a.e(this.f1923c, false); Fragment fragment = this.f1923c; fragment.mState = -1; fragment.mHost = null; fragment.mParentFragment = null; fragment.mFragmentManager = null; if (fragment.mRemoving && !fragment.isInBackStack()) { z10 = true; } if (z10 || this.f1922b.o().p(this.f1923c)) { if (n.E0(3)) { Log.d("FragmentManager", "initState called for fragment: " + this.f1923c); } this.f1923c.initState(); } } void j() { Fragment fragment = this.f1923c; if (fragment.mFromLayout && fragment.mInLayout && !fragment.mPerformedCreateView) { if (n.E0(3)) { Log.d("FragmentManager", "moveto CREATE_VIEW: " + this.f1923c); } Fragment fragment2 = this.f1923c; fragment2.performCreateView(fragment2.performGetLayoutInflater(fragment2.mSavedFragmentState), null, this.f1923c.mSavedFragmentState); View view = this.f1923c.mView; if (view != null) { view.setSaveFromParentEnabled(false); Fragment fragment3 = this.f1923c; fragment3.mView.setTag(f0.b.f9489a, fragment3); Fragment fragment4 = this.f1923c; if (fragment4.mHidden) { fragment4.mView.setVisibility(8); } this.f1923c.performViewCreated(); m mVar = this.f1921a; Fragment fragment5 = this.f1923c; mVar.m(fragment5, fragment5.mView, fragment5.mSavedFragmentState, false); this.f1923c.mState = 2; } } } Fragment k() { return this.f1923c; } void m() { ViewGroup viewGroup; ViewGroup viewGroup2; ViewGroup viewGroup3; if (this.f1924d) { if (n.E0(2)) { Log.v("FragmentManager", "Ignoring re-entrant call to moveToExpectedState() for " + k()); return; } return; } try { this.f1924d = true; while (true) { int d10 = d(); Fragment fragment = this.f1923c; int i10 = fragment.mState; if (d10 == i10) { if (n.P && fragment.mHiddenChanged) { if (fragment.mView != null && (viewGroup = fragment.mContainer) != null) { b0 n10 = b0.n(viewGroup, fragment.getParentFragmentManager()); if (this.f1923c.mHidden) { n10.c(this); } else { n10.e(this); } } Fragment fragment2 = this.f1923c; n nVar = fragment2.mFragmentManager; if (nVar != null) { nVar.C0(fragment2); } Fragment fragment3 = this.f1923c; fragment3.mHiddenChanged = false; fragment3.onHiddenChanged(fragment3.mHidden); } return; } if (d10 <= i10) { switch (i10 - 1) { case -1: i(); break; case 0: g(); break; case 1: h(); this.f1923c.mState = 1; break; case 2: fragment.mInLayout = false; fragment.mState = 2; break; case 3: if (n.E0(3)) { Log.d("FragmentManager", "movefrom ACTIVITY_CREATED: " + this.f1923c); } Fragment fragment4 = this.f1923c; if (fragment4.mView != null && fragment4.mSavedViewState == null) { s(); } Fragment fragment5 = this.f1923c; if (fragment5.mView != null && (viewGroup3 = fragment5.mContainer) != null) { b0.n(viewGroup3, fragment5.getParentFragmentManager()).d(this); } this.f1923c.mState = 3; break; case 4: v(); break; case 5: fragment.mState = 5; break; case 6: n(); break; } } else { switch (i10 + 1) { case 0: c(); break; case 1: e(); break; case 2: j(); f(); break; case 3: a(); break; case 4: if (fragment.mView != null && (viewGroup2 = fragment.mContainer) != null) { b0.n(viewGroup2, fragment.getParentFragmentManager()).b(b0.e.c.b(this.f1923c.mView.getVisibility()), this); } this.f1923c.mState = 4; break; case 5: u(); break; case 6: fragment.mState = 6; break; case 7: p(); break; } } } } finally { this.f1924d = false; } } void n() { if (n.E0(3)) { Log.d("FragmentManager", "movefrom RESUMED: " + this.f1923c); } this.f1923c.performPause(); this.f1921a.f(this.f1923c, false); } void o(ClassLoader classLoader) { Bundle bundle = this.f1923c.mSavedFragmentState; if (bundle == null) { return; } bundle.setClassLoader(classLoader); Fragment fragment = this.f1923c; fragment.mSavedViewState = fragment.mSavedFragmentState.getSparseParcelableArray("android:view_state"); Fragment fragment2 = this.f1923c; fragment2.mSavedViewRegistryState = fragment2.mSavedFragmentState.getBundle("android:view_registry_state"); Fragment fragment3 = this.f1923c; fragment3.mTargetWho = fragment3.mSavedFragmentState.getString("android:target_state"); Fragment fragment4 = this.f1923c; if (fragment4.mTargetWho != null) { fragment4.mTargetRequestCode = fragment4.mSavedFragmentState.getInt("android:target_req_state", 0); } Fragment fragment5 = this.f1923c; Boolean bool = fragment5.mSavedUserVisibleHint; if (bool != null) { fragment5.mUserVisibleHint = bool.booleanValue(); this.f1923c.mSavedUserVisibleHint = null; } else { fragment5.mUserVisibleHint = fragment5.mSavedFragmentState.getBoolean("android:user_visible_hint", true); } Fragment fragment6 = this.f1923c; if (fragment6.mUserVisibleHint) { return; } fragment6.mDeferStart = true; } void p() { if (n.E0(3)) { Log.d("FragmentManager", "moveto RESUMED: " + this.f1923c); } View focusedView = this.f1923c.getFocusedView(); if (focusedView != null && l(focusedView)) { boolean requestFocus = focusedView.requestFocus(); if (n.E0(2)) { StringBuilder sb = new StringBuilder(); sb.append("requestFocus: Restoring focused view "); sb.append(focusedView); sb.append(" "); sb.append(requestFocus ? "succeeded" : "failed"); sb.append(" on Fragment "); sb.append(this.f1923c); sb.append(" resulting in focused view "); sb.append(this.f1923c.mView.findFocus()); Log.v("FragmentManager", sb.toString()); } } this.f1923c.setFocusedView(null); this.f1923c.performResume(); this.f1921a.i(this.f1923c, false); Fragment fragment = this.f1923c; fragment.mSavedFragmentState = null; fragment.mSavedViewState = null; fragment.mSavedViewRegistryState = null; } s r() { s sVar = new s(this.f1923c); Fragment fragment = this.f1923c; if (fragment.mState <= -1 || sVar.f1920m != null) { sVar.f1920m = fragment.mSavedFragmentState; } else { Bundle q10 = q(); sVar.f1920m = q10; if (this.f1923c.mTargetWho != null) { if (q10 == null) { sVar.f1920m = new Bundle(); } sVar.f1920m.putString("android:target_state", this.f1923c.mTargetWho); int i10 = this.f1923c.mTargetRequestCode; if (i10 != 0) { sVar.f1920m.putInt("android:target_req_state", i10); } } } return sVar; } void s() { if (this.f1923c.mView == null) { return; } SparseArray sparseArray = new SparseArray<>(); this.f1923c.mView.saveHierarchyState(sparseArray); if (sparseArray.size() > 0) { this.f1923c.mSavedViewState = sparseArray; } Bundle bundle = new Bundle(); this.f1923c.mViewLifecycleOwner.e(bundle); if (bundle.isEmpty()) { return; } this.f1923c.mSavedViewRegistryState = bundle; } void t(int i10) { this.f1925e = i10; } void u() { if (n.E0(3)) { Log.d("FragmentManager", "moveto STARTED: " + this.f1923c); } this.f1923c.performStart(); this.f1921a.k(this.f1923c, false); } void v() { if (n.E0(3)) { Log.d("FragmentManager", "movefrom STARTED: " + this.f1923c); } this.f1923c.performStop(); this.f1921a.l(this.f1923c, false); } t(m mVar, u uVar, ClassLoader classLoader, j jVar, s sVar) { this.f1921a = mVar; this.f1922b = uVar; Fragment a10 = jVar.a(classLoader, sVar.f1908a); this.f1923c = a10; Bundle bundle = sVar.f1917j; if (bundle != null) { bundle.setClassLoader(classLoader); } a10.setArguments(sVar.f1917j); a10.mWho = sVar.f1909b; a10.mFromLayout = sVar.f1910c; a10.mRestored = true; a10.mFragmentId = sVar.f1911d; a10.mContainerId = sVar.f1912e; a10.mTag = sVar.f1913f; a10.mRetainInstance = sVar.f1914g; a10.mRemoving = sVar.f1915h; a10.mDetached = sVar.f1916i; a10.mHidden = sVar.f1918k; a10.mMaxState = e.c.values()[sVar.f1919l]; Bundle bundle2 = sVar.f1920m; if (bundle2 != null) { a10.mSavedFragmentState = bundle2; } else { a10.mSavedFragmentState = new Bundle(); } if (n.E0(2)) { Log.v("FragmentManager", "Instantiated fragment " + a10); } } t(m mVar, u uVar, Fragment fragment, s sVar) { this.f1921a = mVar; this.f1922b = uVar; this.f1923c = fragment; fragment.mSavedViewState = null; fragment.mSavedViewRegistryState = null; fragment.mBackStackNesting = 0; fragment.mInLayout = false; fragment.mAdded = false; Fragment fragment2 = fragment.mTarget; fragment.mTargetWho = fragment2 != null ? fragment2.mWho : null; fragment.mTarget = null; Bundle bundle = sVar.f1920m; if (bundle != null) { fragment.mSavedFragmentState = bundle; } else { fragment.mSavedFragmentState = new Bundle(); } } }