package androidx.leanback.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public class NonOverlappingLinearLayout extends LinearLayout {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList f11839c;

    public NonOverlappingLinearLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        this.f11837a = false;
        this.f11839c = new ArrayList();
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void focusableViewAvailable(View view) {
        int iIndexOfChild;
        if (!this.f11838b) {
            super.focusableViewAvailable(view);
            return;
        }
        for (View view2 = view; view2 != this && view2 != null; view2 = (View) view2.getParent()) {
            if (view2.getParent() == this) {
                iIndexOfChild = indexOfChild(view2);
                break;
            }
        }
        iIndexOfChild = -1;
        if (iIndexOfChild != -1) {
            ((ArrayList) this.f11839c.get(iIndexOfChild)).add(view);
        }
    }

    @Override // android.view.View
    public final boolean hasOverlappingRendering() {
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x001b  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00b3  */
    @Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onLayout(boolean z6, int i6, int i7, int i8, int i9) throws Throwable {
        NonOverlappingLinearLayout nonOverlappingLinearLayout;
        Throwable th;
        ArrayList arrayList = this.f11839c;
        int i10 = 0;
        try {
            if (this.f11837a) {
                try {
                    boolean z7 = getOrientation() == 0 && getLayoutDirection() == 1;
                    this.f11838b = z7;
                    if (z7) {
                        while (arrayList.size() > getChildCount()) {
                            arrayList.remove(arrayList.size() - 1);
                        }
                        while (arrayList.size() < getChildCount()) {
                            arrayList.add(new ArrayList());
                        }
                    }
                    nonOverlappingLinearLayout = this;
                } catch (Throwable th2) {
                    th = th2;
                    nonOverlappingLinearLayout = this;
                }
                try {
                    super.onLayout(z6, i6, i7, i8, i9);
                    if (nonOverlappingLinearLayout.f11838b) {
                        for (int i11 = 0; i11 < arrayList.size(); i11++) {
                            for (int i12 = 0; i12 < ((ArrayList) arrayList.get(i11)).size(); i12++) {
                                super.focusableViewAvailable((View) ((ArrayList) arrayList.get(i11)).get(i12));
                            }
                        }
                    }
                    if (nonOverlappingLinearLayout.f11838b) {
                        nonOverlappingLinearLayout.f11838b = false;
                        while (i10 < arrayList.size()) {
                            ((ArrayList) arrayList.get(i10)).clear();
                            i10++;
                        }
                        return;
                    }
                    return;
                } catch (Throwable th3) {
                    th = th3;
                    th = th;
                    if (nonOverlappingLinearLayout.f11838b) {
                    }
                }
            }
        } catch (Throwable th4) {
            th = th4;
            nonOverlappingLinearLayout = this;
        }
        if (nonOverlappingLinearLayout.f11838b) {
            throw th;
        }
        nonOverlappingLinearLayout.f11838b = false;
        while (i10 < arrayList.size()) {
            ((ArrayList) arrayList.get(i10)).clear();
            i10++;
        }
        throw th;
    }

    public void setFocusableViewAvailableFixEnabled(boolean z6) {
        this.f11837a = z6;
    }
}
