package androidx.fragment.app; import android.animation.LayoutTransition; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.os.Bundle; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.FrameLayout; import androidx.core.view.a1; import androidx.core.view.n0; import com.google.android.gms.ads.RequestConfiguration; import java.util.ArrayList; /* loaded from: classes.dex */ public final class h extends FrameLayout { /* renamed from: a, reason: collision with root package name */ private ArrayList f1827a; /* renamed from: b, reason: collision with root package name */ private ArrayList f1828b; /* renamed from: c, reason: collision with root package name */ private View.OnApplyWindowInsetsListener f1829c; /* renamed from: d, reason: collision with root package name */ private boolean f1830d; h(Context context, AttributeSet attributeSet, n nVar) { super(context, attributeSet); String str; this.f1830d = true; String classAttribute = attributeSet.getClassAttribute(); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f0.c.f9499h); classAttribute = classAttribute == null ? obtainStyledAttributes.getString(f0.c.f9500i) : classAttribute; String string = obtainStyledAttributes.getString(f0.c.f9501j); obtainStyledAttributes.recycle(); int id = getId(); Fragment g02 = nVar.g0(id); if (classAttribute != null && g02 == null) { if (id <= 0) { if (string != null) { str = " with tag " + string; } else { str = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } throw new IllegalStateException("FragmentContainerView must have an android:id to add Fragment " + classAttribute + str); } Fragment a10 = nVar.p0().a(context.getClassLoader(), classAttribute); a10.onInflate(context, attributeSet, (Bundle) null); nVar.m().o(true).c(this, a10, string).i(); } nVar.T0(this); } private void a(View view) { ArrayList arrayList = this.f1828b; if (arrayList == null || !arrayList.contains(view)) { return; } if (this.f1827a == null) { this.f1827a = new ArrayList(); } this.f1827a.add(view); } @Override // android.view.ViewGroup public void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) { if (n.y0(view) != null) { super.addView(view, i10, 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 protected boolean addViewInLayout(View view, int i10, ViewGroup.LayoutParams layoutParams, boolean z10) { if (n.y0(view) != null) { return super.addViewInLayout(view, i10, layoutParams, z10); } 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) { a1 u10 = a1.u(windowInsets); View.OnApplyWindowInsetsListener onApplyWindowInsetsListener = this.f1829c; a1 u11 = onApplyWindowInsetsListener != null ? a1.u(onApplyWindowInsetsListener.onApplyWindowInsets(this, windowInsets)) : n0.Z(this, u10); if (!u11.n()) { int childCount = getChildCount(); for (int i10 = 0; i10 < childCount; i10++) { n0.h(getChildAt(i10), u11); } } return windowInsets; } @Override // android.view.ViewGroup, android.view.View protected void dispatchDraw(Canvas canvas) { if (this.f1830d && this.f1827a != null) { for (int i10 = 0; i10 < this.f1827a.size(); i10++) { super.drawChild(canvas, (View) this.f1827a.get(i10), getDrawingTime()); } } super.dispatchDraw(canvas); } @Override // android.view.ViewGroup protected boolean drawChild(Canvas canvas, View view, long j10) { ArrayList arrayList; if (!this.f1830d || (arrayList = this.f1827a) == null || arrayList.size() <= 0 || !this.f1827a.contains(view)) { return super.drawChild(canvas, view, j10); } return false; } @Override // android.view.ViewGroup public void endViewTransition(View view) { ArrayList arrayList = this.f1828b; if (arrayList != null) { arrayList.remove(view); ArrayList arrayList2 = this.f1827a; if (arrayList2 != null && arrayList2.remove(view)) { this.f1830d = 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--) { a(getChildAt(childCount)); } super.removeAllViewsInLayout(); } @Override // android.view.ViewGroup protected void removeDetachedView(View view, boolean z10) { if (z10) { a(view); } super.removeDetachedView(view, z10); } @Override // android.view.ViewGroup, android.view.ViewManager public void removeView(View view) { a(view); super.removeView(view); } @Override // android.view.ViewGroup public void removeViewAt(int i10) { a(getChildAt(i10)); super.removeViewAt(i10); } @Override // android.view.ViewGroup public void removeViewInLayout(View view) { a(view); super.removeViewInLayout(view); } @Override // android.view.ViewGroup public void removeViews(int i10, int i11) { for (int i12 = i10; i12 < i10 + i11; i12++) { a(getChildAt(i12)); } super.removeViews(i10, i11); } @Override // android.view.ViewGroup public void removeViewsInLayout(int i10, int i11) { for (int i12 = i10; i12 < i10 + i11; i12++) { a(getChildAt(i12)); } super.removeViewsInLayout(i10, i11); } void setDrawDisappearingViewsLast(boolean z10) { this.f1830d = z10; } @Override // android.view.ViewGroup public void setLayoutTransition(LayoutTransition layoutTransition) { throw new UnsupportedOperationException("FragmentContainerView does not support Layout Transitions or animateLayoutChanges=\"true\"."); } @Override // android.view.View public void setOnApplyWindowInsetsListener(View.OnApplyWindowInsetsListener onApplyWindowInsetsListener) { this.f1829c = onApplyWindowInsetsListener; } @Override // android.view.ViewGroup public void startViewTransition(View view) { if (view.getParent() == this) { if (this.f1828b == null) { this.f1828b = new ArrayList(); } this.f1828b.add(view); } super.startViewTransition(view); } }