package androidx.fragment.app;

import android.animation.LayoutTransition;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import ar.tvplayer.tv.R;
import defpackage.AbstractActivityC2057;
import defpackage.AbstractC0061;
import defpackage.AbstractC0651;
import defpackage.AbstractC1764;
import defpackage.AbstractC2746;
import defpackage.AbstractComponentCallbacksC3393;
import defpackage.C0586;
import defpackage.C1734;
import defpackage.C2064;
import defpackage.C2813;
import defpackage.C4301;
import java.util.ArrayList;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes3.dex */
public final class FragmentContainerView extends FrameLayout {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final ArrayList f377;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public View.OnApplyWindowInsetsListener f378;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final ArrayList f379;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f380;

    public FragmentContainerView(Context context) {
        super(context);
        this.f377 = new ArrayList();
        this.f379 = new ArrayList();
        this.f380 = true;
    }

    public FragmentContainerView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0, 4, null);
    }

    public FragmentContainerView(Context context, AttributeSet attributeSet, int i) {
        String str;
        super(context, attributeSet, i);
        this.f377 = new ArrayList();
        this.f379 = new ArrayList();
        this.f380 = true;
        if (attributeSet != null) {
            String classAttribute = attributeSet.getClassAttribute();
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC0061.f1242, 0, 0);
            if (classAttribute == null) {
                classAttribute = typedArrayObtainStyledAttributes.getString(0);
                str = "android:name";
            } else {
                str = "class";
            }
            typedArrayObtainStyledAttributes.recycle();
            if (classAttribute == null || isInEditMode()) {
                return;
            }
            throw new UnsupportedOperationException("FragmentContainerView must be within a FragmentActivity to use " + ((Object) str) + "=\"" + ((Object) classAttribute) + "\"");
        }
    }

    public /* synthetic */ FragmentContainerView(Context context, AttributeSet attributeSet, int i, int i2, AbstractC1764 abstractC1764) {
        this(context, attributeSet, (i2 & 4) != 0 ? 0 : i);
    }

    public FragmentContainerView(Context context, AttributeSet attributeSet, AbstractC0651 abstractC0651) {
        View view;
        String str;
        super(context, attributeSet);
        this.f377 = new ArrayList();
        this.f379 = new ArrayList();
        this.f380 = true;
        String classAttribute = attributeSet.getClassAttribute();
        int i = 0;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC0061.f1242, 0, 0);
        classAttribute = classAttribute == null ? typedArrayObtainStyledAttributes.getString(0) : classAttribute;
        String string = typedArrayObtainStyledAttributes.getString(1);
        typedArrayObtainStyledAttributes.recycle();
        int id = getId();
        AbstractComponentCallbacksC3393 abstractComponentCallbacksC3393M2330 = abstractC0651.m2330(id);
        if (classAttribute != null && abstractComponentCallbacksC3393M2330 == null) {
            if (id == -1) {
                if (string != null) {
                    str = " with tag " + ((Object) string);
                } else {
                    str = "";
                }
                ˆˌᵣ.ᵨᵣ("FragmentContainerView must have an android:id to add Fragment ", classAttribute, str);
                throw null;
            }
            C2064 c2064M2363 = abstractC0651.m2363();
            context.getClassLoader();
            AbstractComponentCallbacksC3393 abstractComponentCallbacksC3393M5509 = c2064M2363.m5509(classAttribute);
            abstractComponentCallbacksC3393M5509.f13064 = id;
            abstractComponentCallbacksC3393M5509.f13043 = id;
            abstractComponentCallbacksC3393M5509.f13034 = string;
            abstractComponentCallbacksC3393M5509.f13054 = abstractC0651;
            C1734 c1734 = abstractC0651.f3066;
            abstractComponentCallbacksC3393M5509.f13028 = c1734;
            abstractComponentCallbacksC3393M5509.f13066 = true;
            if ((c1734 != null ? c1734.f6946 : null) != null) {
                abstractComponentCallbacksC3393M5509.f13066 = true;
            }
            C0586 c0586 = new C0586(abstractC0651);
            c0586.f2873 = true;
            abstractComponentCallbacksC3393M5509.f13067 = this;
            abstractComponentCallbacksC3393M5509.f13045 = true;
            c0586.m2211(getId(), abstractComponentCallbacksC3393M5509, string, 1);
            c0586.m2215();
        }
        ArrayList arrayList = abstractC0651.f3063.ˑˊᵲ();
        int size = arrayList.size();
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            C4301 c4301 = (C4301) obj;
            AbstractComponentCallbacksC3393 abstractComponentCallbacksC3393 = c4301.f16382;
            if (abstractComponentCallbacksC3393.f13043 == getId() && (view = abstractComponentCallbacksC3393.f13046) != null && view.getParent() == null) {
                abstractComponentCallbacksC3393.f13067 = this;
                c4301.m9280();
                c4301.m9294();
            }
        }
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
        Object tag = view.getTag(R.id.h);
        if ((tag instanceof AbstractComponentCallbacksC3393 ? (AbstractComponentCallbacksC3393) tag : null) != null) {
            super.addView(view, i, layoutParams);
        } else {
            ᵷᵝˎ.ᵮᵣᵗˈ("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 final WindowInsets dispatchApplyWindowInsets(WindowInsets windowInsets) {
        C2813 c2813M6792;
        C2813 c2813M67922 = C2813.m6792(windowInsets, null);
        View.OnApplyWindowInsetsListener onApplyWindowInsetsListener = this.f378;
        if (onApplyWindowInsetsListener != null) {
            c2813M6792 = C2813.m6792(onApplyWindowInsetsListener.onApplyWindowInsets(this, windowInsets), null);
        } else {
            WeakHashMap weakHashMap = AbstractC2746.f10556;
            WindowInsets windowInsetsM6794 = c2813M67922.m6794();
            if (windowInsetsM6794 != null && !windowInsetsM6794.equals(windowInsetsM6794)) {
                c2813M67922 = C2813.m6792(windowInsetsM6794, this);
            }
            c2813M6792 = c2813M67922;
        }
        if (!c2813M6792.f10815.mo1953()) {
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                AbstractC2746.m6643(getChildAt(i), c2813M6792);
            }
        }
        return windowInsets;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void dispatchDraw(Canvas canvas) {
        if (this.f380) {
            ArrayList arrayList = this.f377;
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                super.drawChild(canvas, (View) obj, getDrawingTime());
            }
        }
        super.dispatchDraw(canvas);
    }

    @Override // android.view.ViewGroup
    public final boolean drawChild(Canvas canvas, View view, long j) {
        if (this.f380) {
            ArrayList arrayList = this.f377;
            if (!arrayList.isEmpty() && arrayList.contains(view)) {
                return false;
            }
        }
        return super.drawChild(canvas, view, j);
    }

    @Override // android.view.ViewGroup
    public final void endViewTransition(View view) {
        this.f379.remove(view);
        if (this.f377.remove(view)) {
            this.f380 = true;
        }
        super.endViewTransition(view);
    }

    public final <F extends AbstractComponentCallbacksC3393> F getFragment() {
        AbstractComponentCallbacksC3393 abstractComponentCallbacksC3393;
        AbstractActivityC2057 abstractActivityC2057;
        AbstractC0651 abstractC0651M5482;
        View view = this;
        while (true) {
            if (view == null) {
                abstractComponentCallbacksC3393 = null;
                break;
            }
            Object tag = view.getTag(R.id.h);
            abstractComponentCallbacksC3393 = tag instanceof AbstractComponentCallbacksC3393 ? (AbstractComponentCallbacksC3393) tag : null;
            if (abstractComponentCallbacksC3393 != null) {
                break;
            }
            Object parent = view.getParent();
            view = parent instanceof View ? (View) parent : null;
        }
        if (abstractComponentCallbacksC3393 == null) {
            Context context = getContext();
            while (true) {
                if (!(context instanceof ContextWrapper)) {
                    abstractActivityC2057 = null;
                    break;
                }
                if (context instanceof AbstractActivityC2057) {
                    abstractActivityC2057 = (AbstractActivityC2057) context;
                    break;
                }
                context = ((ContextWrapper) context).getBaseContext();
            }
            if (abstractActivityC2057 == null) {
                ˆˌᵣ.ᵨᵣ("View ", this, " is not within a subclass of FragmentActivity.");
                return null;
            }
            abstractC0651M5482 = abstractActivityC2057.m5482();
        } else {
            if (!abstractComponentCallbacksC3393.m7765()) {
                ˆˌᵣ.ᵻˈᵦʼ("The Fragment ", abstractComponentCallbacksC3393, " that owns View ", this, " has already been destroyed. Nested fragments should always use the child FragmentManager.");
                return null;
            }
            abstractC0651M5482 = abstractComponentCallbacksC3393.m7773();
        }
        return (F) abstractC0651M5482.m2330(getId());
    }

    @Override // android.view.View
    public final WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
        return windowInsets;
    }

    @Override // android.view.ViewGroup
    public final void removeAllViewsInLayout() {
        int childCount = getChildCount();
        while (true) {
            childCount--;
            if (-1 >= childCount) {
                super.removeAllViewsInLayout();
                return;
            }
            m254(getChildAt(childCount));
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewManager
    public final void removeView(View view) {
        m254(view);
        super.removeView(view);
    }

    @Override // android.view.ViewGroup
    public final void removeViewAt(int i) {
        m254(getChildAt(i));
        super.removeViewAt(i);
    }

    @Override // android.view.ViewGroup
    public final void removeViewInLayout(View view) {
        m254(view);
        super.removeViewInLayout(view);
    }

    @Override // android.view.ViewGroup
    public final void removeViews(int i, int i2) {
        int i3 = i + i2;
        for (int i4 = i; i4 < i3; i4++) {
            m254(getChildAt(i4));
        }
        super.removeViews(i, i2);
    }

    @Override // android.view.ViewGroup
    public final void removeViewsInLayout(int i, int i2) {
        int i3 = i + i2;
        for (int i4 = i; i4 < i3; i4++) {
            m254(getChildAt(i4));
        }
        super.removeViewsInLayout(i, i2);
    }

    public final void setDrawDisappearingViewsLast(boolean z) {
        this.f380 = z;
    }

    @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.f378 = onApplyWindowInsetsListener;
    }

    @Override // android.view.ViewGroup
    public final void startViewTransition(View view) {
        if (view.getParent() == this) {
            this.f379.add(view);
        }
        super.startViewTransition(view);
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m254(View view) {
        if (this.f379.contains(view)) {
            this.f377.add(view);
        }
    }
}
