package androidx.fragment.app; import android.animation.LayoutTransition; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.os.Build; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.FrameLayout; import java.util.ArrayList; import p023h0.C0829h1; import p023h0.C0920q4; import p047p0.C1536c; /* renamed from: androidx.fragment.app.g */ /* loaded from: classes.dex */ public final class C0311g extends FrameLayout { /* renamed from: d */ public ArrayList f1321d; /* renamed from: e */ public ArrayList f1322e; /* renamed from: f */ public View.OnApplyWindowInsetsListener f1323f; /* renamed from: g */ public boolean f1324g; public C0311g(Context context, AttributeSet attributeSet, AbstractC0330m abstractC0330m) { super(context, attributeSet); String str; this.f1324g = true; String classAttribute = attributeSet.getClassAttribute(); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C1536c.f3417h); classAttribute = classAttribute == null ? obtainStyledAttributes.getString(C1536c.f3418i) : classAttribute; String string = obtainStyledAttributes.getString(C1536c.f3419j); obtainStyledAttributes.recycle(); int id = getId(); Fragment m3990d0 = abstractC0330m.m3990d0(id); if (classAttribute != null && m3990d0 == null) { if (id <= 0) { if (string != null) { str = " with tag " + string; } else { str = ""; } throw new IllegalStateException("FragmentContainerView must have an android:id to add Fragment " + classAttribute + str); } Fragment mo3937a = abstractC0330m.m3967m0().mo3937a(context.getClassLoader(), classAttribute); mo3937a.m4182u0(context, attributeSet, null); abstractC0330m.m3972k().m3787h(true).m3792c(this, mo3937a, string).mo3790e(); } abstractC0330m.m4025N0(this); } /* renamed from: a */ public final void m4109a(View view) { ArrayList arrayList = this.f1322e; if (arrayList == null || !arrayList.contains(view)) { return; } if (this.f1321d == null) { this.f1321d = new ArrayList<>(); } this.f1321d.add(view); } @Override // android.view.ViewGroup public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) { if (AbstractC0330m.m3949v0(view) != null) { super.addView(view, i, layoutParams); return; } throw new IllegalStateException("Views added to a FragmentContainerView must be associated with a Fragment. View " + view + " is not associated with a Fragment."); } @Override // android.view.ViewGroup public boolean addViewInLayout(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) { if (AbstractC0330m.m3949v0(view) != null) { return super.addViewInLayout(view, i, layoutParams, z); } throw new IllegalStateException("Views added to a FragmentContainerView must be associated with a Fragment. View " + view + " is not associated with a Fragment."); } @Override // android.view.ViewGroup, android.view.View public WindowInsets dispatchApplyWindowInsets(WindowInsets windowInsets) { C0920q4 m2857F; WindowInsets onApplyWindowInsets; C0920q4 m2569u = C0920q4.m2569u(windowInsets); View.OnApplyWindowInsetsListener onApplyWindowInsetsListener = this.f1323f; if (onApplyWindowInsetsListener != null) { onApplyWindowInsets = onApplyWindowInsetsListener.onApplyWindowInsets(this, windowInsets); m2857F = C0920q4.m2569u(onApplyWindowInsets); } else { m2857F = C0829h1.m2857F(this, m2569u); } if (!m2857F.m2576n()) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { C0829h1.m2829e(getChildAt(i), m2857F); } } return windowInsets; } @Override // android.view.ViewGroup, android.view.View public void dispatchDraw(Canvas canvas) { if (this.f1324g && this.f1321d != null) { for (int i = 0; i < this.f1321d.size(); i++) { super.drawChild(canvas, this.f1321d.get(i), getDrawingTime()); } } super.dispatchDraw(canvas); } @Override // android.view.ViewGroup public boolean drawChild(Canvas canvas, View view, long j) { ArrayList arrayList; if (!this.f1324g || (arrayList = this.f1321d) == null || arrayList.size() <= 0 || !this.f1321d.contains(view)) { return super.drawChild(canvas, view, j); } return false; } @Override // android.view.ViewGroup public void endViewTransition(View view) { ArrayList arrayList = this.f1322e; if (arrayList != null) { arrayList.remove(view); ArrayList arrayList2 = this.f1321d; if (arrayList2 != null && arrayList2.remove(view)) { this.f1324g = true; } } super.endViewTransition(view); } @Override // android.view.View public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) { return windowInsets; } @Override // android.view.ViewGroup public void removeAllViewsInLayout() { for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) { m4109a(getChildAt(childCount)); } super.removeAllViewsInLayout(); } @Override // android.view.ViewGroup public void removeDetachedView(View view, boolean z) { if (z) { m4109a(view); } super.removeDetachedView(view, z); } @Override // android.view.ViewGroup, android.view.ViewManager public void removeView(View view) { m4109a(view); super.removeView(view); } @Override // android.view.ViewGroup public void removeViewAt(int i) { m4109a(getChildAt(i)); super.removeViewAt(i); } @Override // android.view.ViewGroup public void removeViewInLayout(View view) { m4109a(view); super.removeViewInLayout(view); } @Override // android.view.ViewGroup public void removeViews(int i, int i2) { for (int i3 = i; i3 < i + i2; i3++) { m4109a(getChildAt(i3)); } super.removeViews(i, i2); } @Override // android.view.ViewGroup public void removeViewsInLayout(int i, int i2) { for (int i3 = i; i3 < i + i2; i3++) { m4109a(getChildAt(i3)); } super.removeViewsInLayout(i, i2); } public void setDrawDisappearingViewsLast(boolean z) { this.f1324g = z; } @Override // android.view.ViewGroup public void setLayoutTransition(LayoutTransition layoutTransition) { if (Build.VERSION.SDK_INT >= 18) { throw new UnsupportedOperationException("FragmentContainerView does not support Layout Transitions or animateLayoutChanges=\"true\"."); } super.setLayoutTransition(layoutTransition); } @Override // android.view.View public void setOnApplyWindowInsetsListener(View.OnApplyWindowInsetsListener onApplyWindowInsetsListener) { this.f1323f = onApplyWindowInsetsListener; } @Override // android.view.ViewGroup public void startViewTransition(View view) { if (view.getParent() == this) { if (this.f1322e == null) { this.f1322e = new ArrayList<>(); } this.f1322e.add(view); } super.startViewTransition(view); } }