package androidx.appcompat.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.LinearLayout;

/* JADX INFO: compiled from: LinearLayoutCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class m0 extends ViewGroup {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private boolean f998e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private int f999f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private int f1000g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private int f1001h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private int f1002i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private int f1003j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private float f1004k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private boolean f1005l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private int[] f1006m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private int[] f1007n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private Drawable f1008o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private int f1009p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private int f1010q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private int f1011r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    private int f1012s;

    /* JADX INFO: compiled from: LinearLayoutCompat.java */
    public static class a extends LinearLayout.LayoutParams {
        public a(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public a(int i3, int i4) {
            super(i3, i4);
        }

        public a(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }
    }

    public m0(Context context) {
        this(context, null);
    }

    private void A(View view, int i3, int i4, int i5, int i6) {
        view.layout(i3, i4, i5 + i3, i6 + i4);
    }

    private void k(int i3, int i4) {
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 1073741824);
        for (int i5 = 0; i5 < i3; i5++) {
            View viewS = s(i5);
            if (viewS.getVisibility() != 8) {
                a aVar = (a) viewS.getLayoutParams();
                if (((LinearLayout.LayoutParams) aVar).height == -1) {
                    int i6 = ((LinearLayout.LayoutParams) aVar).width;
                    ((LinearLayout.LayoutParams) aVar).width = viewS.getMeasuredWidth();
                    measureChildWithMargins(viewS, i4, 0, iMakeMeasureSpec, 0);
                    ((LinearLayout.LayoutParams) aVar).width = i6;
                }
            }
        }
    }

    private void l(int i3, int i4) {
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 1073741824);
        for (int i5 = 0; i5 < i3; i5++) {
            View viewS = s(i5);
            if (viewS.getVisibility() != 8) {
                a aVar = (a) viewS.getLayoutParams();
                if (((LinearLayout.LayoutParams) aVar).width == -1) {
                    int i6 = ((LinearLayout.LayoutParams) aVar).height;
                    ((LinearLayout.LayoutParams) aVar).height = viewS.getMeasuredHeight();
                    measureChildWithMargins(viewS, iMakeMeasureSpec, 0, i4, 0);
                    ((LinearLayout.LayoutParams) aVar).height = i6;
                }
            }
        }
    }

    @Override // android.view.ViewGroup
    protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof a;
    }

    void g(Canvas canvas) {
        int right;
        int left;
        int i3;
        int virtualChildCount = getVirtualChildCount();
        boolean zB = j1.b(this);
        for (int i4 = 0; i4 < virtualChildCount; i4++) {
            View viewS = s(i4);
            if (viewS != null && viewS.getVisibility() != 8 && t(i4)) {
                a aVar = (a) viewS.getLayoutParams();
                j(canvas, zB ? viewS.getRight() + ((LinearLayout.LayoutParams) aVar).rightMargin : (viewS.getLeft() - ((LinearLayout.LayoutParams) aVar).leftMargin) - this.f1009p);
            }
        }
        if (t(virtualChildCount)) {
            View viewS2 = s(virtualChildCount - 1);
            if (viewS2 != null) {
                a aVar2 = (a) viewS2.getLayoutParams();
                if (zB) {
                    left = viewS2.getLeft() - ((LinearLayout.LayoutParams) aVar2).leftMargin;
                    i3 = this.f1009p;
                    right = left - i3;
                } else {
                    right = viewS2.getRight() + ((LinearLayout.LayoutParams) aVar2).rightMargin;
                }
            } else if (zB) {
                right = getPaddingLeft();
            } else {
                left = getWidth() - getPaddingRight();
                i3 = this.f1009p;
                right = left - i3;
            }
            j(canvas, right);
        }
    }

    @Override // android.view.View
    public int getBaseline() {
        int i3;
        if (this.f999f < 0) {
            return super.getBaseline();
        }
        int childCount = getChildCount();
        int i4 = this.f999f;
        if (childCount <= i4) {
            throw new RuntimeException("mBaselineAlignedChildIndex of LinearLayout set to an index that is out of bounds.");
        }
        View childAt = getChildAt(i4);
        int baseline = childAt.getBaseline();
        if (baseline == -1) {
            if (this.f999f == 0) {
                return -1;
            }
            throw new RuntimeException("mBaselineAlignedChildIndex of LinearLayout points to a View that doesn't know how to get its baseline.");
        }
        int bottom = this.f1000g;
        if (this.f1001h == 1 && (i3 = this.f1002i & 112) != 48) {
            if (i3 == 16) {
                bottom += ((((getBottom() - getTop()) - getPaddingTop()) - getPaddingBottom()) - this.f1003j) / 2;
            } else if (i3 == 80) {
                bottom = ((getBottom() - getTop()) - getPaddingBottom()) - this.f1003j;
            }
        }
        return bottom + ((LinearLayout.LayoutParams) ((a) childAt.getLayoutParams())).topMargin + baseline;
    }

    public int getBaselineAlignedChildIndex() {
        return this.f999f;
    }

    public Drawable getDividerDrawable() {
        return this.f1008o;
    }

    public int getDividerPadding() {
        return this.f1012s;
    }

    public int getDividerWidth() {
        return this.f1009p;
    }

    public int getGravity() {
        return this.f1002i;
    }

    public int getOrientation() {
        return this.f1001h;
    }

    public int getShowDividers() {
        return this.f1011r;
    }

    int getVirtualChildCount() {
        return getChildCount();
    }

    public float getWeightSum() {
        return this.f1004k;
    }

    void h(Canvas canvas) {
        int virtualChildCount = getVirtualChildCount();
        for (int i3 = 0; i3 < virtualChildCount; i3++) {
            View viewS = s(i3);
            if (viewS != null && viewS.getVisibility() != 8 && t(i3)) {
                i(canvas, (viewS.getTop() - ((LinearLayout.LayoutParams) ((a) viewS.getLayoutParams())).topMargin) - this.f1010q);
            }
        }
        if (t(virtualChildCount)) {
            View viewS2 = s(virtualChildCount - 1);
            i(canvas, viewS2 == null ? (getHeight() - getPaddingBottom()) - this.f1010q : viewS2.getBottom() + ((LinearLayout.LayoutParams) ((a) viewS2.getLayoutParams())).bottomMargin);
        }
    }

    void i(Canvas canvas, int i3) {
        this.f1008o.setBounds(getPaddingLeft() + this.f1012s, i3, (getWidth() - getPaddingRight()) - this.f1012s, this.f1010q + i3);
        this.f1008o.draw(canvas);
    }

    void j(Canvas canvas, int i3) {
        this.f1008o.setBounds(i3, getPaddingTop() + this.f1012s, this.f1009p + i3, (getHeight() - getPaddingBottom()) - this.f1012s);
        this.f1008o.draw(canvas);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: m, reason: merged with bridge method [inline-methods] */
    public a generateDefaultLayoutParams() {
        int i3 = this.f1001h;
        if (i3 == 0) {
            return new a(-2, -2);
        }
        if (i3 == 1) {
            return new a(-1, -2);
        }
        return null;
    }

    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: n, reason: merged with bridge method [inline-methods] */
    public a generateLayoutParams(AttributeSet attributeSet) {
        return new a(getContext(), attributeSet);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: o, reason: merged with bridge method [inline-methods] */
    public a generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return new a(layoutParams);
    }

    @Override // android.view.View
    protected void onDraw(Canvas canvas) {
        if (this.f1008o == null) {
            return;
        }
        if (this.f1001h == 1) {
            h(canvas);
        } else {
            g(canvas);
        }
    }

    @Override // android.view.View
    public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onInitializeAccessibilityEvent(accessibilityEvent);
        accessibilityEvent.setClassName("androidx.appcompat.widget.LinearLayoutCompat");
    }

    @Override // android.view.View
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName("androidx.appcompat.widget.LinearLayoutCompat");
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onLayout(boolean z2, int i3, int i4, int i5, int i6) {
        if (this.f1001h == 1) {
            v(i3, i4, i5, i6);
        } else {
            u(i3, i4, i5, i6);
        }
    }

    @Override // android.view.View
    protected void onMeasure(int i3, int i4) {
        if (this.f1001h == 1) {
            z(i3, i4);
        } else {
            x(i3, i4);
        }
    }

    int p(View view, int i3) {
        return 0;
    }

    int q(View view) {
        return 0;
    }

    int r(View view) {
        return 0;
    }

    View s(int i3) {
        return getChildAt(i3);
    }

    public void setBaselineAligned(boolean z2) {
        this.f998e = z2;
    }

    public void setBaselineAlignedChildIndex(int i3) {
        if (i3 >= 0 && i3 < getChildCount()) {
            this.f999f = i3;
            return;
        }
        throw new IllegalArgumentException("base aligned child index out of range (0, " + getChildCount() + ")");
    }

    public void setDividerDrawable(Drawable drawable) {
        if (drawable == this.f1008o) {
            return;
        }
        this.f1008o = drawable;
        if (drawable != null) {
            this.f1009p = drawable.getIntrinsicWidth();
            this.f1010q = drawable.getIntrinsicHeight();
        } else {
            this.f1009p = 0;
            this.f1010q = 0;
        }
        setWillNotDraw(drawable == null);
        requestLayout();
    }

    public void setDividerPadding(int i3) {
        this.f1012s = i3;
    }

    public void setGravity(int i3) {
        if (this.f1002i != i3) {
            if ((8388615 & i3) == 0) {
                i3 |= 8388611;
            }
            if ((i3 & 112) == 0) {
                i3 |= 48;
            }
            this.f1002i = i3;
            requestLayout();
        }
    }

    public void setHorizontalGravity(int i3) {
        int i4 = i3 & 8388615;
        int i5 = this.f1002i;
        if ((8388615 & i5) != i4) {
            this.f1002i = i4 | ((-8388616) & i5);
            requestLayout();
        }
    }

    public void setMeasureWithLargestChildEnabled(boolean z2) {
        this.f1005l = z2;
    }

    public void setOrientation(int i3) {
        if (this.f1001h != i3) {
            this.f1001h = i3;
            requestLayout();
        }
    }

    public void setShowDividers(int i3) {
        if (i3 != this.f1011r) {
            requestLayout();
        }
        this.f1011r = i3;
    }

    public void setVerticalGravity(int i3) {
        int i4 = i3 & 112;
        int i5 = this.f1002i;
        if ((i5 & 112) != i4) {
            this.f1002i = i4 | (i5 & (-113));
            requestLayout();
        }
    }

    public void setWeightSum(float f3) {
        this.f1004k = Math.max(0.0f, f3);
    }

    @Override // android.view.ViewGroup
    public boolean shouldDelayChildPressedState() {
        return false;
    }

    protected boolean t(int i3) {
        if (i3 == 0) {
            return (this.f1011r & 1) != 0;
        }
        if (i3 == getChildCount()) {
            return (this.f1011r & 4) != 0;
        }
        if ((this.f1011r & 2) == 0) {
            return false;
        }
        for (int i4 = i3 - 1; i4 >= 0; i4--) {
            if (getChildAt(i4).getVisibility() != 8) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x00af  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00b8  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00eb  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00ff  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void u(int r25, int r26, int r27, int r28) {
        /*
            Method dump skipped, instruction units count: 329
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.m0.u(int, int, int, int):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x009f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void v(int r18, int r19, int r20, int r21) {
        /*
            Method dump skipped, instruction units count: 204
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.m0.v(int, int, int, int):void");
    }

    void w(View view, int i3, int i4, int i5, int i6, int i7) {
        measureChildWithMargins(view, i4, i5, i6, i7);
    }

    /* JADX WARN: Removed duplicated region for block: B:197:0x0453  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x0177  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x0199  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x01c5  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x01cd  */
    /* JADX WARN: Removed duplicated region for block: B:81:0x01d8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void x(int r39, int r40) {
        /*
            Method dump skipped, instruction units count: 1294
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.m0.x(int, int):void");
    }

    int y(int i3) {
        return 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:150:0x0325  */
    /* JADX WARN: Removed duplicated region for block: B:156:0x0333  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void z(int r34, int r35) {
        /*
            Method dump skipped, instruction units count: 914
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.m0.z(int, int):void");
    }

    public m0(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public m0(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        this.f998e = true;
        this.f999f = -1;
        this.f1000g = 0;
        this.f1002i = 8388659;
        int[] iArr = c.j.W0;
        a1 a1VarV = a1.v(context, attributeSet, iArr, i3, 0);
        androidx.core.view.y.p0(this, context, iArr, attributeSet, a1VarV.r(), i3, 0);
        int iK = a1VarV.k(c.j.Y0, -1);
        if (iK >= 0) {
            setOrientation(iK);
        }
        int iK2 = a1VarV.k(c.j.X0, -1);
        if (iK2 >= 0) {
            setGravity(iK2);
        }
        boolean zA = a1VarV.a(c.j.Z0, true);
        if (!zA) {
            setBaselineAligned(zA);
        }
        this.f1004k = a1VarV.i(c.j.f3294b1, -1.0f);
        this.f999f = a1VarV.k(c.j.f3290a1, -1);
        this.f1005l = a1VarV.a(c.j.f3306e1, false);
        setDividerDrawable(a1VarV.g(c.j.f3298c1));
        this.f1011r = a1VarV.k(c.j.f3310f1, 0);
        this.f1012s = a1VarV.f(c.j.f3302d1, 0);
        a1VarV.w();
    }
}
