package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.TypedArray;
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 com.seewo.libmcuservice.constant.ITouchConstants;
import io.netty.util.internal.shaded.org.jctools.util.Pow2;

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private int f697g;
    private int h;
    private float i;
    private boolean j;
    private int[] k;
    private int[] l;
    private Drawable m;
    private int n;
    private int o;
    private int p;
    private int q;

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

    private void h(int i, int i2) {
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), Pow2.MAX_POW2);
        for (int i3 = 0; i3 < i; i3++) {
            View viewP = p(i3);
            if (viewP.getVisibility() != 8) {
                a aVar = (a) viewP.getLayoutParams();
                if (((ViewGroup.MarginLayoutParams) aVar).height == -1) {
                    int i4 = ((ViewGroup.MarginLayoutParams) aVar).width;
                    ((ViewGroup.MarginLayoutParams) aVar).width = viewP.getMeasuredWidth();
                    measureChildWithMargins(viewP, i2, 0, iMakeMeasureSpec, 0);
                    ((ViewGroup.MarginLayoutParams) aVar).width = i4;
                }
            }
        }
    }

    private void i(int i, int i2) {
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), Pow2.MAX_POW2);
        for (int i3 = 0; i3 < i; i3++) {
            View viewP = p(i3);
            if (viewP.getVisibility() != 8) {
                a aVar = (a) viewP.getLayoutParams();
                if (((ViewGroup.MarginLayoutParams) aVar).width == -1) {
                    int i4 = ((ViewGroup.MarginLayoutParams) aVar).height;
                    ((ViewGroup.MarginLayoutParams) aVar).height = viewP.getMeasuredHeight();
                    measureChildWithMargins(viewP, iMakeMeasureSpec, 0, i2, 0);
                    ((ViewGroup.MarginLayoutParams) aVar).height = i4;
                }
            }
        }
    }

    private void x(View view, int i, int i2, int i3, int i4) {
        view.layout(i, i2, i3 + i, i4 + i2);
    }

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

    void d(Canvas canvas) {
        int right;
        int left;
        int i;
        int virtualChildCount = getVirtualChildCount();
        boolean zB = o0.b(this);
        for (int i2 = 0; i2 < virtualChildCount; i2++) {
            View viewP = p(i2);
            if (viewP != null && viewP.getVisibility() != 8 && q(i2)) {
                a aVar = (a) viewP.getLayoutParams();
                g(canvas, zB ? viewP.getRight() + ((ViewGroup.MarginLayoutParams) aVar).rightMargin : (viewP.getLeft() - ((ViewGroup.MarginLayoutParams) aVar).leftMargin) - this.n);
            }
        }
        if (q(virtualChildCount)) {
            View viewP2 = p(virtualChildCount - 1);
            if (viewP2 != null) {
                a aVar2 = (a) viewP2.getLayoutParams();
                if (zB) {
                    left = viewP2.getLeft() - ((ViewGroup.MarginLayoutParams) aVar2).leftMargin;
                    i = this.n;
                    right = left - i;
                } else {
                    right = viewP2.getRight() + ((ViewGroup.MarginLayoutParams) aVar2).rightMargin;
                }
            } else if (zB) {
                right = getPaddingLeft();
            } else {
                left = getWidth() - getPaddingRight();
                i = this.n;
                right = left - i;
            }
            g(canvas, right);
        }
    }

    void e(Canvas canvas) {
        int virtualChildCount = getVirtualChildCount();
        for (int i = 0; i < virtualChildCount; i++) {
            View viewP = p(i);
            if (viewP != null && viewP.getVisibility() != 8 && q(i)) {
                f(canvas, (viewP.getTop() - ((ViewGroup.MarginLayoutParams) ((a) viewP.getLayoutParams())).topMargin) - this.o);
            }
        }
        if (q(virtualChildCount)) {
            View viewP2 = p(virtualChildCount - 1);
            f(canvas, viewP2 == null ? (getHeight() - getPaddingBottom()) - this.o : viewP2.getBottom() + ((ViewGroup.MarginLayoutParams) ((a) viewP2.getLayoutParams())).bottomMargin);
        }
    }

    void f(Canvas canvas, int i) {
        this.m.setBounds(getPaddingLeft() + this.q, i, (getWidth() - getPaddingRight()) - this.q, this.o + i);
        this.m.draw(canvas);
    }

    void g(Canvas canvas, int i) {
        this.m.setBounds(i, getPaddingTop() + this.q, this.n + i, (getHeight() - getPaddingBottom()) - this.q);
        this.m.draw(canvas);
    }

    @Override // android.view.View
    public int getBaseline() {
        int i;
        if (this.f694d < 0) {
            return super.getBaseline();
        }
        int childCount = getChildCount();
        int i2 = this.f694d;
        if (childCount <= i2) {
            throw new RuntimeException("mBaselineAlignedChildIndex of LinearLayout set to an index that is out of bounds.");
        }
        View childAt = getChildAt(i2);
        int baseline = childAt.getBaseline();
        if (baseline == -1) {
            if (this.f694d == 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.f695e;
        if (this.f696f == 1 && (i = this.f697g & ITouchConstants.ACTION_OUT_GET_CAP_TOUCH_UPGRADE_ACK) != 48) {
            if (i == 16) {
                bottom += ((((getBottom() - getTop()) - getPaddingTop()) - getPaddingBottom()) - this.h) / 2;
            } else if (i == 80) {
                bottom = ((getBottom() - getTop()) - getPaddingBottom()) - this.h;
            }
        }
        return bottom + ((ViewGroup.MarginLayoutParams) ((a) childAt.getLayoutParams())).topMargin + baseline;
    }

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

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

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

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

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

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

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

    int getVirtualChildCount() {
        return getChildCount();
    }

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

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

    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: k, 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: l, reason: merged with bridge method [inline-methods] */
    public a generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return new a(layoutParams);
    }

    int m(View view, int i) {
        return 0;
    }

    int n(View view) {
        return 0;
    }

    int o(View view) {
        return 0;
    }

    @Override // android.view.View
    protected void onDraw(Canvas canvas) {
        if (this.m == null) {
            return;
        }
        if (this.f696f == 1) {
            e(canvas);
        } else {
            d(canvas);
        }
    }

    @Override // android.view.View
    public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onInitializeAccessibilityEvent(accessibilityEvent);
        accessibilityEvent.setClassName(v.class.getName());
    }

    @Override // android.view.View
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName(v.class.getName());
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        if (this.f696f == 1) {
            s(i, i2, i3, i4);
        } else {
            r(i, i2, i3, i4);
        }
    }

    @Override // android.view.View
    protected void onMeasure(int i, int i2) {
        if (this.f696f == 1) {
            w(i, i2);
        } else {
            u(i, i2);
        }
    }

    View p(int i) {
        return getChildAt(i);
    }

    protected boolean q(int i) {
        if (i == 0) {
            return (this.p & 1) != 0;
        }
        if (i == getChildCount()) {
            return (this.p & 4) != 0;
        }
        if ((this.p & 2) == 0) {
            return false;
        }
        for (int i2 = i - 1; i2 >= 0; i2--) {
            if (getChildAt(i2).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 r(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.v.r(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 s(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.v.s(int, int, int, int):void");
    }

    public void setBaselineAligned(boolean z) {
        this.f693c = z;
    }

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

    public void setDividerDrawable(Drawable drawable) {
        if (drawable == this.m) {
            return;
        }
        this.m = drawable;
        if (drawable != null) {
            this.n = drawable.getIntrinsicWidth();
            this.o = drawable.getIntrinsicHeight();
        } else {
            this.n = 0;
            this.o = 0;
        }
        setWillNotDraw(drawable == null);
        requestLayout();
    }

    public void setDividerPadding(int i) {
        this.q = i;
    }

    public void setGravity(int i) {
        if (this.f697g != i) {
            if ((8388615 & i) == 0) {
                i |= 8388611;
            }
            if ((i & ITouchConstants.ACTION_OUT_GET_CAP_TOUCH_UPGRADE_ACK) == 0) {
                i |= 48;
            }
            this.f697g = i;
            requestLayout();
        }
    }

    public void setHorizontalGravity(int i) {
        int i2 = i & 8388615;
        int i3 = this.f697g;
        if ((8388615 & i3) != i2) {
            this.f697g = i2 | ((-8388616) & i3);
            requestLayout();
        }
    }

    public void setMeasureWithLargestChildEnabled(boolean z) {
        this.j = z;
    }

    public void setOrientation(int i) {
        if (this.f696f != i) {
            this.f696f = i;
            requestLayout();
        }
    }

    public void setShowDividers(int i) {
        if (i != this.p) {
            requestLayout();
        }
        this.p = i;
    }

    public void setVerticalGravity(int i) {
        int i2 = i & ITouchConstants.ACTION_OUT_GET_CAP_TOUCH_UPGRADE_ACK;
        int i3 = this.f697g;
        if ((i3 & ITouchConstants.ACTION_OUT_GET_CAP_TOUCH_UPGRADE_ACK) != i2) {
            this.f697g = i2 | (i3 & (-113));
            requestLayout();
        }
    }

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

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

    void t(View view, int i, int i2, int i3, int i4, int i5) {
        measureChildWithMargins(view, i2, i3, i4, i5);
    }

    /* 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 u(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.v.u(int, int):void");
    }

    int v(int i) {
        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 w(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.v.w(int, int):void");
    }

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

    public v(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f693c = true;
        this.f694d = -1;
        this.f695e = 0;
        this.f697g = 8388659;
        i0 i0VarS = i0.s(context, attributeSet, a.a.j.B0, i, 0);
        int i2 = i0VarS.i(a.a.j.D0, -1);
        if (i2 >= 0) {
            setOrientation(i2);
        }
        int i3 = i0VarS.i(a.a.j.C0, -1);
        if (i3 >= 0) {
            setGravity(i3);
        }
        boolean zA = i0VarS.a(a.a.j.E0, true);
        if (!zA) {
            setBaselineAligned(zA);
        }
        this.i = i0VarS.g(a.a.j.G0, -1.0f);
        this.f694d = i0VarS.i(a.a.j.F0, -1);
        this.j = i0VarS.a(a.a.j.J0, false);
        setDividerDrawable(i0VarS.f(a.a.j.H0));
        this.p = i0VarS.i(a.a.j.K0, 0);
        this.q = i0VarS.e(a.a.j.I0, 0);
        i0VarS.t();
    }

    /* JADX INFO: compiled from: LinearLayoutCompat.java */
    public static class a extends ViewGroup.MarginLayoutParams {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public float f698a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f699b;

        public a(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f699b = -1;
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, a.a.j.L0);
            this.f698a = typedArrayObtainStyledAttributes.getFloat(a.a.j.N0, 0.0f);
            this.f699b = typedArrayObtainStyledAttributes.getInt(a.a.j.M0, -1);
            typedArrayObtainStyledAttributes.recycle();
        }

        public a(int i, int i2) {
            super(i, i2);
            this.f699b = -1;
            this.f698a = 0.0f;
        }

        public a(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f699b = -1;
        }
    }
}
