package ca.canadapost.core.common.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import h7.f;
import h7.i;
import h7.j;
import h7.n;
import kotlin.Metadata;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;

@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0005\b\u0007\u0018\u00002\u00020\u0001B1\b\u0007\u0012\u0006\u0010\u0010\u001a\u00020\u000f\u0012\n\b\u0002\u0010\u0012\u001a\u0004\u0018\u00010\u0011\u0012\b\b\u0002\u0010\u0014\u001a\u00020\u0013\u0012\b\b\u0002\u0010\u0015\u001a\u00020\u0013¢\u0006\u0004\b\u0016\u0010\u0017J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0002J\b\u0010\u0006\u001a\u00020\u0004H\u0002J\b\u0010\u0007\u001a\u00020\u0004H\u0014R\u0014\u0010\n\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\b\u0010\tR\u0016\u0010\u000e\u001a\u00020\u000b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\f\u0010\r¨\u0006\u0018"}, d2 = {"Lca/canadapost/core/common/ui/CpcFragmentContainerFullView;", "Landroid/widget/LinearLayout;", "Landroid/view/View;", "child", "Lrm/n0;", "a", "b", "onFinishInflate", "p", "Landroid/view/View;", "fragmentView", "", "q", "Z", "noPadding", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyle", "defStyleRes", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public final class CpcFragmentContainerFullView extends LinearLayout {

    /* renamed from: p, reason: collision with root package name and from kotlin metadata */
    private final View fragmentView;

    /* renamed from: q, reason: collision with root package name and from kotlin metadata */
    private boolean noPadding;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public CpcFragmentContainerFullView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0, 0, 12, null);
        t.g(context, "context");
    }

    private final void a(View view) {
        removeView(view);
        ((ViewGroup) findViewById(i.f21070s)).addView(view, view.getLayoutParams());
    }

    private final void b() {
        LinearLayout linearLayout;
        if (!this.noPadding || (linearLayout = (LinearLayout) this.fragmentView.findViewById(i.f21070s)) == null) {
            return;
        }
        linearLayout.setPadding(0, 0, 0, 0);
    }

    @Override // android.view.View
    protected void onFinishInflate() {
        super.onFinishInflate();
        int i10 = 0;
        while (i10 < getChildCount()) {
            View childAt = getChildAt(i10);
            if (t.b(childAt, this.fragmentView)) {
                i10++;
            } else {
                t.d(childAt);
                a(childAt);
            }
        }
        b();
    }

    public /* synthetic */ CpcFragmentContainerFullView(Context context, AttributeSet attributeSet, int i10, int i11, int i12, k kVar) {
        this(context, (i12 & 2) != 0 ? null : attributeSet, (i12 & 4) != 0 ? 0 : i10, (i12 & 8) != 0 ? 0 : i11);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public CpcFragmentContainerFullView(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        int i12;
        boolean z10;
        int i13;
        t.g(context, "context");
        int i14 = f.f20961b;
        int color = getResources().getColor(i14, context.getTheme());
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, n.f21364x0, 0, 0);
            t.f(obtainStyledAttributes, "obtainStyledAttributes(...)");
            this.noPadding = obtainStyledAttributes.getBoolean(n.f21374z0, false);
            z10 = obtainStyledAttributes.getBoolean(n.A0, true);
            i12 = obtainStyledAttributes.getColor(n.f21369y0, getResources().getColor(i14, context.getTheme()));
            obtainStyledAttributes.recycle();
        } else {
            i12 = color;
            z10 = true;
        }
        setOrientation(1);
        LayoutInflater from = LayoutInflater.from(context);
        if (z10) {
            i13 = j.f21103r;
        } else {
            i13 = j.f21102q;
        }
        View inflate = from.inflate(i13, (ViewGroup) this, false);
        t.f(inflate, "inflate(...)");
        this.fragmentView = inflate;
        ViewGroup viewGroup = (ViewGroup) inflate.findViewById(i.f21070s);
        if (viewGroup != null) {
            viewGroup.setBackgroundColor(i12);
        }
        addView(inflate);
    }
}
