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.ViewCompat; import androidx.core.view.WindowInsetsCompat; import androidx.fragment.R; import io.sentry.Session; import io.sentry.protocol.Message; import io.sentry.protocol.MetricSummary; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import kotlin.Metadata; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import kotlin.text.Typography; /* compiled from: FragmentContainerView.kt */ @Metadata(d1 = {"\u0000v\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u0001:\u0001 disappearingFragmentChildren; private boolean drawDisappearingViewsFirst; private final List transitioningFragmentViews; /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public FragmentContainerView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0, 4, null); Intrinsics.checkNotNullParameter(context, "context"); } @Override // android.view.View public WindowInsets onApplyWindowInsets(WindowInsets insets) { Intrinsics.checkNotNullParameter(insets, "insets"); return insets; } public final void setDrawDisappearingViewsLast(boolean drawDisappearingViewsFirst) { this.drawDisappearingViewsFirst = drawDisappearingViewsFirst; } @Override // android.view.View public void setOnApplyWindowInsetsListener(View.OnApplyWindowInsetsListener listener) { Intrinsics.checkNotNullParameter(listener, "listener"); this.applyWindowInsetsListener = listener; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public FragmentContainerView(Context context) { super(context); Intrinsics.checkNotNullParameter(context, "context"); this.disappearingFragmentChildren = new ArrayList(); this.transitioningFragmentViews = new ArrayList(); this.drawDisappearingViewsFirst = true; } public /* synthetic */ FragmentContainerView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) { this(context, attributeSet, (i2 & 4) != 0 ? 0 : i); } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public FragmentContainerView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); String str; Intrinsics.checkNotNullParameter(context, "context"); this.disappearingFragmentChildren = new ArrayList(); this.transitioningFragmentViews = new ArrayList(); this.drawDisappearingViewsFirst = true; if (attributeSet != null) { String classAttribute = attributeSet.getClassAttribute(); int[] FragmentContainerView = R.styleable.FragmentContainerView; Intrinsics.checkNotNullExpressionValue(FragmentContainerView, "FragmentContainerView"); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, FragmentContainerView, 0, 0); if (classAttribute == null) { classAttribute = obtainStyledAttributes.getString(R.styleable.FragmentContainerView_android_name); str = "android:name"; } else { str = "class"; } obtainStyledAttributes.recycle(); if (classAttribute != null && !isInEditMode()) { throw new UnsupportedOperationException("FragmentContainerView must be within a FragmentActivity to use " + str + "=\"" + classAttribute + Typography.quote); } } } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public FragmentContainerView(Context context, AttributeSet attrs, FragmentManager fm) { super(context, attrs); Intrinsics.checkNotNullParameter(context, "context"); Intrinsics.checkNotNullParameter(attrs, "attrs"); Intrinsics.checkNotNullParameter(fm, "fm"); this.disappearingFragmentChildren = new ArrayList(); this.transitioningFragmentViews = new ArrayList(); this.drawDisappearingViewsFirst = true; String classAttribute = attrs.getClassAttribute(); int[] FragmentContainerView = R.styleable.FragmentContainerView; Intrinsics.checkNotNullExpressionValue(FragmentContainerView, "FragmentContainerView"); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, FragmentContainerView, 0, 0); classAttribute = classAttribute == null ? obtainStyledAttributes.getString(R.styleable.FragmentContainerView_android_name) : classAttribute; String string = obtainStyledAttributes.getString(R.styleable.FragmentContainerView_android_tag); obtainStyledAttributes.recycle(); int id = getId(); Fragment findFragmentById = fm.findFragmentById(id); if (classAttribute != null && findFragmentById == null) { if (id == -1) { throw new IllegalStateException("FragmentContainerView must have an android:id to add Fragment " + classAttribute + (string != null ? " with tag " + string : "")); } Fragment instantiate = fm.getFragmentFactory().instantiate(context.getClassLoader(), classAttribute); Intrinsics.checkNotNullExpressionValue(instantiate, "fm.fragmentFactory.insta…ontext.classLoader, name)"); instantiate.onInflate(context, attrs, (Bundle) null); fm.beginTransaction().setReorderingAllowed(true).add(this, instantiate, string).commitNowAllowingStateLoss(); } fm.onContainerAvailable(this); } @Override // android.view.ViewGroup public void setLayoutTransition(LayoutTransition transition) { throw new UnsupportedOperationException("FragmentContainerView does not support Layout Transitions or animateLayoutChanges=\"true\"."); } @Override // android.view.ViewGroup, android.view.View public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { WindowInsetsCompat onApplyWindowInsets; Intrinsics.checkNotNullParameter(insets, "insets"); WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat.toWindowInsetsCompat(insets); Intrinsics.checkNotNullExpressionValue(windowInsetsCompat, "toWindowInsetsCompat(insets)"); if (this.applyWindowInsetsListener != null) { Api20Impl api20Impl = Api20Impl.INSTANCE; View.OnApplyWindowInsetsListener onApplyWindowInsetsListener = this.applyWindowInsetsListener; Intrinsics.checkNotNull(onApplyWindowInsetsListener); onApplyWindowInsets = WindowInsetsCompat.toWindowInsetsCompat(api20Impl.onApplyWindowInsets(onApplyWindowInsetsListener, this, insets)); } else { onApplyWindowInsets = ViewCompat.onApplyWindowInsets(this, windowInsetsCompat); } Intrinsics.checkNotNullExpressionValue(onApplyWindowInsets, "if (applyWindowInsetsLis…, insetsCompat)\n }"); if (!onApplyWindowInsets.isConsumed()) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { ViewCompat.dispatchApplyWindowInsets(getChildAt(i), onApplyWindowInsets); } } return insets; } @Override // android.view.ViewGroup, android.view.View protected void dispatchDraw(Canvas canvas) { Intrinsics.checkNotNullParameter(canvas, "canvas"); if (this.drawDisappearingViewsFirst) { Iterator it = this.disappearingFragmentChildren.iterator(); while (it.hasNext()) { super.drawChild(canvas, (View) it.next(), getDrawingTime()); } } super.dispatchDraw(canvas); } @Override // android.view.ViewGroup protected boolean drawChild(Canvas canvas, View child, long drawingTime) { Intrinsics.checkNotNullParameter(canvas, "canvas"); Intrinsics.checkNotNullParameter(child, "child"); if (this.drawDisappearingViewsFirst && (!this.disappearingFragmentChildren.isEmpty()) && this.disappearingFragmentChildren.contains(child)) { return false; } return super.drawChild(canvas, child, drawingTime); } @Override // android.view.ViewGroup public void startViewTransition(View view) { Intrinsics.checkNotNullParameter(view, "view"); if (view.getParent() == this) { this.transitioningFragmentViews.add(view); } super.startViewTransition(view); } @Override // android.view.ViewGroup public void endViewTransition(View view) { Intrinsics.checkNotNullParameter(view, "view"); this.transitioningFragmentViews.remove(view); if (this.disappearingFragmentChildren.remove(view)) { this.drawDisappearingViewsFirst = true; } super.endViewTransition(view); } @Override // android.view.ViewGroup public void addView(View child, int index, ViewGroup.LayoutParams params) { Intrinsics.checkNotNullParameter(child, "child"); if (FragmentManager.getViewFragment(child) == null) { throw new IllegalStateException(("Views added to a FragmentContainerView must be associated with a Fragment. View " + child + " is not associated with a Fragment.").toString()); } super.addView(child, index, params); } @Override // android.view.ViewGroup public void removeViewAt(int index) { View view = getChildAt(index); Intrinsics.checkNotNullExpressionValue(view, "view"); addDisappearingFragmentView(view); super.removeViewAt(index); } @Override // android.view.ViewGroup public void removeViewInLayout(View view) { Intrinsics.checkNotNullParameter(view, "view"); addDisappearingFragmentView(view); super.removeViewInLayout(view); } @Override // android.view.ViewGroup, android.view.ViewManager public void removeView(View view) { Intrinsics.checkNotNullParameter(view, "view"); addDisappearingFragmentView(view); super.removeView(view); } @Override // android.view.ViewGroup public void removeViews(int start, int count) { int i = start + count; for (int i2 = start; i2 < i; i2++) { View view = getChildAt(i2); Intrinsics.checkNotNullExpressionValue(view, "view"); addDisappearingFragmentView(view); } super.removeViews(start, count); } @Override // android.view.ViewGroup public void removeViewsInLayout(int start, int count) { int i = start + count; for (int i2 = start; i2 < i; i2++) { View view = getChildAt(i2); Intrinsics.checkNotNullExpressionValue(view, "view"); addDisappearingFragmentView(view); } super.removeViewsInLayout(start, count); } @Override // android.view.ViewGroup public void removeAllViewsInLayout() { int childCount = getChildCount(); while (true) { childCount--; if (-1 < childCount) { View view = getChildAt(childCount); Intrinsics.checkNotNullExpressionValue(view, "view"); addDisappearingFragmentView(view); } else { super.removeAllViewsInLayout(); return; } } } private final void addDisappearingFragmentView(View v) { if (this.transitioningFragmentViews.contains(v)) { this.disappearingFragmentChildren.add(v); } } public final F getFragment() { return (F) FragmentManager.findFragmentManager(this).findFragmentById(getId()); } /* compiled from: FragmentContainerView.kt */ @Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bÁ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001e\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\u0004¨\u0006\n"}, d2 = {"Landroidx/fragment/app/FragmentContainerView$Api20Impl;", "", "()V", "onApplyWindowInsets", "Landroid/view/WindowInsets;", "onApplyWindowInsetsListener", "Landroid/view/View$OnApplyWindowInsetsListener;", "v", "Landroid/view/View;", "insets", "fragment_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes2.dex */ public static final class Api20Impl { public static final Api20Impl INSTANCE = new Api20Impl(); private Api20Impl() { } public final WindowInsets onApplyWindowInsets(View.OnApplyWindowInsetsListener onApplyWindowInsetsListener, View v, WindowInsets insets) { Intrinsics.checkNotNullParameter(onApplyWindowInsetsListener, "onApplyWindowInsetsListener"); Intrinsics.checkNotNullParameter(v, "v"); Intrinsics.checkNotNullParameter(insets, "insets"); WindowInsets onApplyWindowInsets = onApplyWindowInsetsListener.onApplyWindowInsets(v, insets); Intrinsics.checkNotNullExpressionValue(onApplyWindowInsets, "onApplyWindowInsetsListe…lyWindowInsets(v, insets)"); return onApplyWindowInsets; } } }