package androidx.fragment.app; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /* loaded from: classes.dex */ class l implements LayoutInflater.Factory2 { /* renamed from: a, reason: collision with root package name */ final n f1838a; class a implements View.OnAttachStateChangeListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ t f1839a; a(t tVar) { this.f1839a = tVar; } @Override // android.view.View.OnAttachStateChangeListener public void onViewAttachedToWindow(View view) { Fragment k10 = this.f1839a.k(); this.f1839a.m(); b0.n((ViewGroup) k10.mView.getParent(), l.this.f1838a).j(); } @Override // android.view.View.OnAttachStateChangeListener public void onViewDetachedFromWindow(View view) { } } l(n nVar) { this.f1838a = nVar; } @Override // android.view.LayoutInflater.Factory public View onCreateView(String str, Context context, AttributeSet attributeSet) { return onCreateView(null, str, context, attributeSet); } @Override // android.view.LayoutInflater.Factory2 public View onCreateView(View view, String str, Context context, AttributeSet attributeSet) { t v10; if (h.class.getName().equals(str)) { return new h(context, attributeSet, this.f1838a); } if (!"fragment".equals(str)) { return null; } String attributeValue = attributeSet.getAttributeValue(null, "class"); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f0.c.f9495d); if (attributeValue == null) { attributeValue = obtainStyledAttributes.getString(f0.c.f9496e); } int resourceId = obtainStyledAttributes.getResourceId(f0.c.f9497f, -1); String string = obtainStyledAttributes.getString(f0.c.f9498g); obtainStyledAttributes.recycle(); if (attributeValue == null || !j.b(context.getClassLoader(), attributeValue)) { return null; } int id = view != null ? view.getId() : 0; if (id == -1 && resourceId == -1 && string == null) { throw new IllegalArgumentException(attributeSet.getPositionDescription() + ": Must specify unique android:id, android:tag, or have a parent with an id for " + attributeValue); } Fragment g02 = resourceId != -1 ? this.f1838a.g0(resourceId) : null; if (g02 == null && string != null) { g02 = this.f1838a.h0(string); } if (g02 == null && id != -1) { g02 = this.f1838a.g0(id); } if (g02 == null) { g02 = this.f1838a.p0().a(context.getClassLoader(), attributeValue); g02.mFromLayout = true; g02.mFragmentId = resourceId != 0 ? resourceId : id; g02.mContainerId = id; g02.mTag = string; g02.mInLayout = true; n nVar = this.f1838a; g02.mFragmentManager = nVar; g02.mHost = nVar.s0(); g02.onInflate(this.f1838a.s0().f(), attributeSet, g02.mSavedFragmentState); v10 = this.f1838a.g(g02); if (n.E0(2)) { Log.v("FragmentManager", "Fragment " + g02 + " has been inflated via the tag: id=0x" + Integer.toHexString(resourceId)); } } else { if (g02.mInLayout) { throw new IllegalArgumentException(attributeSet.getPositionDescription() + ": Duplicate id 0x" + Integer.toHexString(resourceId) + ", tag " + string + ", or parent id 0x" + Integer.toHexString(id) + " with another fragment for " + attributeValue); } g02.mInLayout = true; n nVar2 = this.f1838a; g02.mFragmentManager = nVar2; g02.mHost = nVar2.s0(); g02.onInflate(this.f1838a.s0().f(), attributeSet, g02.mSavedFragmentState); v10 = this.f1838a.v(g02); if (n.E0(2)) { Log.v("FragmentManager", "Retained Fragment " + g02 + " has been re-attached via the tag: id=0x" + Integer.toHexString(resourceId)); } } g02.mContainer = (ViewGroup) view; v10.m(); v10.j(); View view2 = g02.mView; if (view2 == null) { throw new IllegalStateException("Fragment " + attributeValue + " did not create a view."); } if (resourceId != 0) { view2.setId(resourceId); } if (g02.mView.getTag() == null) { g02.mView.setTag(string); } g02.mView.addOnAttachStateChangeListener(new a(v10)); return g02.mView; } }