package androidx.leanback.widget;

import I2.C0327k;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import androidx.media3.exoplayer.DecoderReuseEvaluation;
import androidx.recyclerview.widget.C1159i;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;

/* JADX INFO: renamed from: androidx.leanback.widget.f, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC1074f extends RecyclerView {
    public final C1084p K0;
    public boolean L0;

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

    /* JADX INFO: renamed from: N0, reason: collision with root package name */
    public androidx.recyclerview.widget.G f11978N0;

    /* JADX INFO: renamed from: O0, reason: collision with root package name */
    public androidx.recyclerview.widget.Q f11979O0;

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

    public AbstractC1074f(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        this.L0 = true;
        this.f11977M0 = true;
        this.f11980P0 = 4;
        C1084p c1084p = new C1084p(this);
        this.K0 = c1084p;
        setLayoutManager(c1084p);
        setPreserveFocusAfterLayout(false);
        setDescendantFocusability(262144);
        setHasFixedSize(true);
        setChildrenDrawingOrderEnabled(true);
        setWillNotDraw(true);
        setOverScrollMode(2);
        ((C1159i) getItemAnimator()).f13093g = false;
        super.setRecyclerListener(new C1069a(this));
    }

    @Override // android.view.ViewGroup, android.view.View
    public final boolean dispatchGenericFocusedEvent(MotionEvent motionEvent) {
        return super.dispatchGenericFocusedEvent(motionEvent);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent);
    }

    @Override // android.view.View
    public final View focusSearch(int i6) {
        if (isFocused()) {
            C1084p c1084p = this.K0;
            View viewR = c1084p.r(c1084p.f12022B);
            if (viewR != null) {
                return focusSearch(viewR, i6);
            }
        }
        return super.focusSearch(i6);
    }

    public final void g0(Context context, AttributeSet attributeSet) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Z1.a.f9143c);
        boolean z6 = typedArrayObtainStyledAttributes.getBoolean(4, false);
        boolean z7 = typedArrayObtainStyledAttributes.getBoolean(3, false);
        C1084p c1084p = this.K0;
        c1084p.f12057z = (z6 ? 2048 : 0) | (c1084p.f12057z & (-6145)) | (z7 ? 4096 : 0);
        boolean z8 = typedArrayObtainStyledAttributes.getBoolean(6, true);
        boolean z9 = typedArrayObtainStyledAttributes.getBoolean(5, true);
        c1084p.f12057z = (z8 ? 8192 : 0) | (c1084p.f12057z & (-24577)) | (z9 ? 16384 : 0);
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(2, typedArrayObtainStyledAttributes.getDimensionPixelSize(8, 0));
        if (c1084p.f12049r == 1) {
            c1084p.f12033M = dimensionPixelSize;
            c1084p.f12034N = dimensionPixelSize;
        } else {
            c1084p.f12033M = dimensionPixelSize;
            c1084p.f12035O = dimensionPixelSize;
        }
        int dimensionPixelSize2 = typedArrayObtainStyledAttributes.getDimensionPixelSize(1, typedArrayObtainStyledAttributes.getDimensionPixelSize(7, 0));
        if (c1084p.f12049r == 0) {
            c1084p.f12032L = dimensionPixelSize2;
            c1084p.f12034N = dimensionPixelSize2;
        } else {
            c1084p.f12032L = dimensionPixelSize2;
            c1084p.f12035O = dimensionPixelSize2;
        }
        if (typedArrayObtainStyledAttributes.hasValue(0)) {
            setGravity(typedArrayObtainStyledAttributes.getInt(0, 0));
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    @Override // androidx.recyclerview.widget.RecyclerView, android.view.ViewGroup
    public final int getChildDrawingOrder(int i6, int i7) {
        int iIndexOfChild;
        C1084p c1084p = this.K0;
        View viewR = c1084p.r(c1084p.f12022B);
        return (viewR != null && i7 >= (iIndexOfChild = indexOfChild(viewR))) ? i7 < i6 + (-1) ? ((iIndexOfChild + i6) - 1) - i7 : iIndexOfChild : i7;
    }

    public int getExtraLayoutSpace() {
        return this.K0.X;
    }

    public int getFocusScrollStrategy() {
        return this.K0.f12040T;
    }

    @Deprecated
    public int getHorizontalMargin() {
        return this.K0.f12032L;
    }

    public int getHorizontalSpacing() {
        return this.K0.f12032L;
    }

    public int getInitialPrefetchItemCount() {
        return this.f11980P0;
    }

    public int getItemAlignmentOffset() {
        return ((C1087t) this.K0.f12042V.f743d).f12073b;
    }

    public float getItemAlignmentOffsetPercent() {
        return ((C1087t) this.K0.f12042V.f743d).f12074c;
    }

    public int getItemAlignmentViewId() {
        return ((C1087t) this.K0.f12042V.f743d).f12072a;
    }

    public InterfaceC1073e getOnUnhandledKeyListener() {
        return null;
    }

    public final int getSaveChildrenLimitNumber() {
        return this.K0.f12044Z.f2634b;
    }

    public final int getSaveChildrenPolicy() {
        return this.K0.f12044Z.f2633a;
    }

    public int getSelectedPosition() {
        return this.K0.f12022B;
    }

    public int getSelectedSubPosition() {
        this.K0.getClass();
        return 0;
    }

    @Deprecated
    public int getVerticalMargin() {
        return this.K0.f12033M;
    }

    public int getVerticalSpacing() {
        return this.K0.f12033M;
    }

    public int getWindowAlignment() {
        return ((X) this.K0.f12041U.f535d).f11970f;
    }

    public int getWindowAlignmentOffset() {
        return ((X) this.K0.f12041U.f535d).f11971g;
    }

    public float getWindowAlignmentOffsetPercent() {
        return ((X) this.K0.f12041U.f535d).f11972h;
    }

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

    @Override // android.view.View
    public final void onFocusChanged(boolean z6, int i6, Rect rect) {
        super.onFocusChanged(z6, i6, rect);
        C1084p c1084p = this.K0;
        if (!z6) {
            c1084p.getClass();
            return;
        }
        int i7 = c1084p.f12022B;
        while (true) {
            View viewR = c1084p.r(i7);
            if (viewR == null) {
                return;
            }
            if (viewR.getVisibility() == 0 && viewR.hasFocusable()) {
                viewR.requestFocus();
                return;
            }
            i7++;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView, android.view.ViewGroup
    public final boolean onRequestFocusInDescendants(int i6, Rect rect) {
        int i7;
        int i8;
        int i9;
        C1084p c1084p = this.K0;
        int i10 = c1084p.f12040T;
        if (i10 == 1 || i10 == 2) {
            int iW = c1084p.w();
            if ((i6 & 2) != 0) {
                i8 = iW;
                i9 = 1;
                i7 = 0;
            } else {
                i7 = iW - 1;
                i8 = -1;
                i9 = -1;
            }
            X x6 = (X) c1084p.f12041U.f535d;
            int i11 = x6.f11974j;
            int i12 = ((x6.f11973i - i11) - x6.f11975k) + i11;
            while (i7 != i8) {
                View viewV = c1084p.v(i7);
                if (viewV.getVisibility() == 0 && c1084p.f12050s.e(viewV) >= i11 && c1084p.f12050s.b(viewV) <= i12 && viewV.requestFocus(i6, rect)) {
                    return true;
                }
                i7 += i9;
            }
        } else {
            View viewR = c1084p.r(c1084p.f12022B);
            if (viewR != null) {
                return viewR.requestFocus(i6, rect);
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:6:0x000d  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onRtlPropertiesChanged(int i6) {
        int i7;
        C1084p c1084p = this.K0;
        if (c1084p.f12049r == 0) {
            i7 = i6 == 1 ? 262144 : 0;
        } else if (i6 == 1) {
            i7 = 524288;
        }
        int i8 = c1084p.f12057z;
        if ((786432 & i8) == i7) {
            return;
        }
        c1084p.f12057z = i7 | (i8 & (-786433)) | 256;
        ((X) c1084p.f12041U.f534c).l = i6 == 1;
    }

    public void setAnimateChildLayout(boolean z6) {
        if (this.L0 != z6) {
            this.L0 = z6;
            if (z6) {
                super.setItemAnimator(this.f11978N0);
            } else {
                this.f11978N0 = getItemAnimator();
                super.setItemAnimator(null);
            }
        }
    }

    public void setChildrenVisibility(int i6) {
        C1084p c1084p = this.K0;
        c1084p.f12026F = i6;
        if (i6 != -1) {
            int iW = c1084p.w();
            for (int i7 = 0; i7 < iW; i7++) {
                c1084p.v(i7).setVisibility(c1084p.f12026F);
            }
        }
    }

    public void setExtraLayoutSpace(int i6) {
        C1084p c1084p = this.K0;
        int i7 = c1084p.X;
        if (i7 == i6) {
            return;
        }
        if (i7 < 0) {
            throw new IllegalArgumentException("ExtraLayoutSpace must >= 0");
        }
        c1084p.X = i6;
        c1084p.y0();
    }

    public void setFocusDrawingOrderEnabled(boolean z6) {
        super.setChildrenDrawingOrderEnabled(z6);
    }

    public void setFocusScrollStrategy(int i6) {
        if (i6 != 0 && i6 != 1 && i6 != 2) {
            throw new IllegalArgumentException("Invalid scrollStrategy");
        }
        this.K0.f12040T = i6;
        requestLayout();
    }

    public final void setFocusSearchDisabled(boolean z6) {
        setDescendantFocusability(z6 ? 393216 : 262144);
        C1084p c1084p = this.K0;
        c1084p.f12057z = (z6 ? DecoderReuseEvaluation.DISCARD_REASON_AUDIO_BYPASS_POSSIBLE : 0) | (c1084p.f12057z & (-32769));
    }

    public void setGravity(int i6) {
        this.K0.f12036P = i6;
        requestLayout();
    }

    public void setHasOverlappingRendering(boolean z6) {
        this.f11977M0 = z6;
    }

    @Deprecated
    public void setHorizontalMargin(int i6) {
        setHorizontalSpacing(i6);
    }

    public void setHorizontalSpacing(int i6) {
        C1084p c1084p = this.K0;
        if (c1084p.f12049r == 0) {
            c1084p.f12032L = i6;
            c1084p.f12034N = i6;
        } else {
            c1084p.f12032L = i6;
            c1084p.f12035O = i6;
        }
        requestLayout();
    }

    public void setInitialPrefetchItemCount(int i6) {
        this.f11980P0 = i6;
    }

    public void setItemAlignmentOffset(int i6) {
        C1084p c1084p = this.K0;
        ((C1087t) c1084p.f12042V.f743d).f12073b = i6;
        c1084p.s1();
        requestLayout();
    }

    public void setItemAlignmentOffsetPercent(float f6) {
        C1084p c1084p = this.K0;
        C1087t c1087t = (C1087t) c1084p.f12042V.f743d;
        c1087t.getClass();
        if ((f6 < 0.0f || f6 > 100.0f) && f6 != -1.0f) {
            throw new IllegalArgumentException();
        }
        c1087t.f12074c = f6;
        c1084p.s1();
        requestLayout();
    }

    public void setItemAlignmentOffsetWithPadding(boolean z6) {
        C1084p c1084p = this.K0;
        ((C1087t) c1084p.f12042V.f743d).f12075d = z6;
        c1084p.s1();
        requestLayout();
    }

    public void setItemAlignmentViewId(int i6) {
        C1084p c1084p = this.K0;
        ((C1087t) c1084p.f12042V.f743d).f12072a = i6;
        c1084p.s1();
    }

    @Deprecated
    public void setItemMargin(int i6) {
        setItemSpacing(i6);
    }

    public void setItemSpacing(int i6) {
        C1084p c1084p = this.K0;
        c1084p.f12032L = i6;
        c1084p.f12033M = i6;
        c1084p.f12035O = i6;
        c1084p.f12034N = i6;
        requestLayout();
    }

    public void setLayoutEnabled(boolean z6) {
        C1084p c1084p = this.K0;
        int i6 = c1084p.f12057z;
        if (((i6 & 512) != 0) != z6) {
            c1084p.f12057z = (i6 & (-513)) | (z6 ? 512 : 0);
            c1084p.y0();
        }
    }

    public void setOnChildLaidOutListener(InterfaceC1090w interfaceC1090w) {
        this.K0.getClass();
    }

    public void setOnChildSelectedListener(InterfaceC1091x interfaceC1091x) {
        this.K0.getClass();
    }

    public void setOnChildViewHolderSelectedListener(y yVar) {
        C1084p c1084p = this.K0;
        if (yVar == null) {
            c1084p.f12021A = null;
            return;
        }
        ArrayList arrayList = c1084p.f12021A;
        if (arrayList == null) {
            c1084p.f12021A = new ArrayList();
        } else {
            arrayList.clear();
        }
        c1084p.f12021A.add(yVar);
    }

    public void setOnKeyInterceptListener(InterfaceC1070b interfaceC1070b) {
    }

    public void setOnMotionInterceptListener(InterfaceC1071c interfaceC1071c) {
    }

    public void setOnTouchInterceptListener(InterfaceC1072d interfaceC1072d) {
    }

    public void setOnUnhandledKeyListener(InterfaceC1073e interfaceC1073e) {
    }

    public void setPruneChild(boolean z6) {
        C1084p c1084p = this.K0;
        int i6 = c1084p.f12057z;
        int i7 = androidx.media3.common.C.DEFAULT_BUFFER_SEGMENT_SIZE;
        if (((i6 & androidx.media3.common.C.DEFAULT_BUFFER_SEGMENT_SIZE) != 0) != z6) {
            int i8 = i6 & (-65537);
            if (!z6) {
                i7 = 0;
            }
            c1084p.f12057z = i8 | i7;
            if (z6) {
                c1084p.y0();
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView
    public void setRecyclerListener(androidx.recyclerview.widget.Q q6) {
        this.f11979O0 = q6;
    }

    public final void setSaveChildrenLimitNumber(int i6) {
        C0327k c0327k = this.K0.f12044Z;
        c0327k.f2634b = i6;
        c0327k.c();
    }

    public final void setSaveChildrenPolicy(int i6) {
        C0327k c0327k = this.K0.f12044Z;
        c0327k.f2633a = i6;
        c0327k.c();
    }

    public void setScrollEnabled(boolean z6) {
        int i6;
        C1084p c1084p = this.K0;
        int i7 = c1084p.f12057z;
        if (((i7 & 131072) != 0) != z6) {
            int i8 = (i7 & (-131073)) | (z6 ? 131072 : 0);
            c1084p.f12057z = i8;
            if ((i8 & 131072) == 0 || c1084p.f12040T != 0 || (i6 = c1084p.f12022B) == -1) {
                return;
            }
            c1084p.m1(i6, true);
        }
    }

    public void setSelectedPosition(int i6) {
        this.K0.q1(i6, false);
    }

    public void setSelectedPositionSmooth(int i6) {
        this.K0.q1(i6, true);
    }

    @Deprecated
    public void setVerticalMargin(int i6) {
        setVerticalSpacing(i6);
    }

    public void setVerticalSpacing(int i6) {
        C1084p c1084p = this.K0;
        if (c1084p.f12049r == 1) {
            c1084p.f12033M = i6;
            c1084p.f12034N = i6;
        } else {
            c1084p.f12033M = i6;
            c1084p.f12035O = i6;
        }
        requestLayout();
    }

    public void setWindowAlignment(int i6) {
        ((X) this.K0.f12041U.f535d).f11970f = i6;
        requestLayout();
    }

    public void setWindowAlignmentOffset(int i6) {
        ((X) this.K0.f12041U.f535d).f11971g = i6;
        requestLayout();
    }

    public void setWindowAlignmentOffsetPercent(float f6) {
        X x6 = (X) this.K0.f12041U.f535d;
        x6.getClass();
        if ((f6 < 0.0f || f6 > 100.0f) && f6 != -1.0f) {
            throw new IllegalArgumentException();
        }
        x6.f11972h = f6;
        requestLayout();
    }

    public void setWindowAlignmentPreferKeyLineOverHighEdge(boolean z6) {
        X x6 = (X) this.K0.f12041U.f535d;
        x6.f11969e = z6 ? x6.f11969e | 2 : x6.f11969e & (-3);
        requestLayout();
    }

    public void setWindowAlignmentPreferKeyLineOverLowEdge(boolean z6) {
        X x6 = (X) this.K0.f12041U.f535d;
        x6.f11969e = z6 ? x6.f11969e | 1 : x6.f11969e & (-2);
        requestLayout();
    }
}
