package d.k.b;

import android.animation.LayoutTransition;
import android.content.Context;
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 com.ifpdos.udi.service.core.pc.R;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class u extends FrameLayout {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public ArrayList<View> f3135f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public ArrayList<View> f3136m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public View.OnApplyWindowInsetsListener f3137n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public boolean f3138o;

    public u(Context context, AttributeSet attributeSet, a0 a0Var) {
        View view;
        super(context, attributeSet);
        this.f3138o = true;
        String classAttribute = attributeSet.getClassAttribute();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, d.k.a.f2887b);
        classAttribute = classAttribute == null ? typedArrayObtainStyledAttributes.getString(0) : classAttribute;
        String string = typedArrayObtainStyledAttributes.getString(1);
        typedArrayObtainStyledAttributes.recycle();
        int id = getId();
        m mVarH = a0Var.H(id);
        if (classAttribute != null && mVarH == null) {
            if (id <= 0) {
                throw new IllegalStateException(g.a.a.a.a.u("FragmentContainerView must have an android:id to add Fragment ", classAttribute, string != null ? g.a.a.a.a.t(" with tag ", string) : ""));
            }
            m mVarA = a0Var.J().a(context.getClassLoader(), classAttribute);
            mVarA.Q(attributeSet, null);
            a aVar = new a(a0Var);
            aVar.f3014o = true;
            mVarA.P = this;
            aVar.e(getId(), mVarA, string, 1);
            if (aVar.f3006g) {
                throw new IllegalStateException("This transaction is already being added to the back stack");
            }
            aVar.f2888p.D(aVar, true);
        }
        for (g0 g0Var : (ArrayList) a0Var.f2892c.f()) {
            m mVar = g0Var.f2988c;
            if (mVar.I == getId() && (view = mVar.Q) != null && view.getParent() == null) {
                mVar.P = this;
                g0Var.b();
            }
        }
    }

    public final void a(View view) {
        ArrayList<View> arrayList = this.f3136m;
        if (arrayList == null || !arrayList.contains(view)) {
            return;
        }
        if (this.f3135f == null) {
            this.f3135f = new ArrayList<>();
        }
        this.f3135f.add(view);
    }

    @Override // android.view.ViewGroup
    public void addView(View view, int i2, ViewGroup.LayoutParams layoutParams) {
        Object tag = view.getTag(R.id.fragment_container_view_tag);
        if ((tag instanceof m ? (m) tag : null) != null) {
            super.addView(view, i2, 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 i2, ViewGroup.LayoutParams layoutParams, boolean z2) {
        Object tag = view.getTag(R.id.fragment_container_view_tag);
        if ((tag instanceof m ? (m) tag : null) != null) {
            return super.addViewInLayout(view, i2, layoutParams, z2);
        }
        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) {
        d.h.j.h0 h0VarI = d.h.j.h0.i(windowInsets, null);
        View.OnApplyWindowInsetsListener onApplyWindowInsetsListener = this.f3137n;
        d.h.j.h0 h0VarH = onApplyWindowInsetsListener != null ? d.h.j.h0.h(onApplyWindowInsetsListener.onApplyWindowInsets(this, windowInsets)) : d.h.j.y.k(this, h0VarI);
        if (!h0VarH.f()) {
            int childCount = getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                d.h.j.y.c(getChildAt(i2), h0VarH);
            }
        }
        return windowInsets;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        if (this.f3138o && this.f3135f != null) {
            for (int i2 = 0; i2 < this.f3135f.size(); i2++) {
                super.drawChild(canvas, this.f3135f.get(i2), getDrawingTime());
            }
        }
        super.dispatchDraw(canvas);
    }

    @Override // android.view.ViewGroup
    public boolean drawChild(Canvas canvas, View view, long j2) {
        ArrayList<View> arrayList;
        if (!this.f3138o || (arrayList = this.f3135f) == null || arrayList.size() <= 0 || !this.f3135f.contains(view)) {
            return super.drawChild(canvas, view, j2);
        }
        return false;
    }

    @Override // android.view.ViewGroup
    public void endViewTransition(View view) {
        ArrayList<View> arrayList = this.f3136m;
        if (arrayList != null) {
            arrayList.remove(view);
            ArrayList<View> arrayList2 = this.f3135f;
            if (arrayList2 != null && arrayList2.remove(view)) {
                this.f3138o = 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
    public void removeDetachedView(View view, boolean z2) {
        if (z2) {
            a(view);
        }
        super.removeDetachedView(view, z2);
    }

    @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 i2) {
        a(getChildAt(i2));
        super.removeViewAt(i2);
    }

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

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

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

    public void setDrawDisappearingViewsLast(boolean z2) {
        this.f3138o = z2;
    }

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

    @Override // android.view.ViewGroup
    public void startViewTransition(View view) {
        if (view.getParent() == this) {
            if (this.f3136m == null) {
                this.f3136m = new ArrayList<>();
            }
            this.f3136m.add(view);
        }
        super.startViewTransition(view);
    }
}
