package androidx.recyclerview.widget;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import c.f.l.c0.d;
import io.netty.util.internal.shaded.org.jctools.util.Pow2;
import java.util.Arrays;

/* JADX INFO: loaded from: classes.dex */
public class GridLayoutManager extends LinearLayoutManager {
    boolean I;
    int J;
    int[] K;
    View[] L;
    final SparseIntArray M;
    final SparseIntArray N;
    c O;
    final Rect P;
    private boolean Q;

    public static final class a extends c {
        @Override // androidx.recyclerview.widget.GridLayoutManager.c
        public int e(int i2, int i3) {
            return i2 % i3;
        }

        @Override // androidx.recyclerview.widget.GridLayoutManager.c
        public int f(int i2) {
            return 1;
        }
    }

    public static abstract class c {
        final SparseIntArray a = new SparseIntArray();

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final SparseIntArray f970b = new SparseIntArray();

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

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private boolean f972d = false;

        static int a(SparseIntArray sparseIntArray, int i2) {
            int size = sparseIntArray.size() - 1;
            int i3 = 0;
            while (i3 <= size) {
                int i4 = (i3 + size) >>> 1;
                if (sparseIntArray.keyAt(i4) < i2) {
                    i3 = i4 + 1;
                } else {
                    size = i4 - 1;
                }
            }
            int i5 = i3 - 1;
            if (i5 < 0 || i5 >= sparseIntArray.size()) {
                return -1;
            }
            return sparseIntArray.keyAt(i5);
        }

        int b(int i2, int i3) {
            if (!this.f972d) {
                return d(i2, i3);
            }
            int i4 = this.f970b.get(i2, -1);
            if (i4 != -1) {
                return i4;
            }
            int iD = d(i2, i3);
            this.f970b.put(i2, iD);
            return iD;
        }

        int c(int i2, int i3) {
            if (!this.f971c) {
                return e(i2, i3);
            }
            int i4 = this.a.get(i2, -1);
            if (i4 != -1) {
                return i4;
            }
            int iE = e(i2, i3);
            this.a.put(i2, iE);
            return iE;
        }

        public int d(int i2, int i3) {
            int i4;
            int i5;
            int iC;
            int iA;
            if (!this.f972d || (iA = a(this.f970b, i2)) == -1) {
                i4 = 0;
                i5 = 0;
                iC = 0;
            } else {
                i4 = this.f970b.get(iA);
                i5 = iA + 1;
                iC = c(iA, i3) + f(iA);
                if (iC == i3) {
                    i4++;
                    iC = 0;
                }
            }
            int iF = f(i2);
            while (i5 < i2) {
                int iF2 = f(i5);
                iC += iF2;
                if (iC == i3) {
                    i4++;
                    iC = 0;
                } else if (iC > i3) {
                    i4++;
                    iC = iF2;
                }
                i5++;
            }
            return iC + iF > i3 ? i4 + 1 : i4;
        }

        public abstract int e(int i2, int i3);

        public abstract int f(int i2);

        public void g() {
            this.f970b.clear();
        }

        public void h() {
            this.a.clear();
        }
    }

    public GridLayoutManager(Context context, AttributeSet attributeSet, int i2, int i3) {
        super(context, attributeSet, i2, i3);
        this.I = false;
        this.J = -1;
        this.M = new SparseIntArray();
        this.N = new SparseIntArray();
        this.O = new a();
        this.P = new Rect();
        T2(RecyclerView.LayoutManager.g0(context, attributeSet, i2, i3).f1010b);
    }

    private void D2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i2, boolean z) {
        int i3;
        int i4;
        int i5 = 0;
        int i6 = -1;
        if (z) {
            i4 = 1;
            i6 = i2;
            i3 = 0;
        } else {
            i3 = i2 - 1;
            i4 = -1;
        }
        while (i3 != i6) {
            View view = this.L[i3];
            b bVar = (b) view.getLayoutParams();
            int iP2 = P2(vVar, a0Var, f0(view));
            bVar.f969f = iP2;
            bVar.f968e = i5;
            i5 += iP2;
            i3 += i4;
        }
    }

    private void E2() {
        int I = I();
        for (int i2 = 0; i2 < I; i2++) {
            b bVar = (b) H(i2).getLayoutParams();
            int iA = bVar.a();
            this.M.put(iA, bVar.f());
            this.N.put(iA, bVar.e());
        }
    }

    private void F2(int i2) {
        this.K = G2(this.K, this.J, i2);
    }

    static int[] G2(int[] iArr, int i2, int i3) {
        int i4;
        if (iArr == null || iArr.length != i2 + 1 || iArr[iArr.length - 1] != i3) {
            iArr = new int[i2 + 1];
        }
        int i5 = 0;
        iArr[0] = 0;
        int i6 = i3 / i2;
        int i7 = i3 % i2;
        int i8 = 0;
        for (int i9 = 1; i9 <= i2; i9++) {
            i5 += i7;
            if (i5 <= 0 || i2 - i5 >= i7) {
                i4 = i6;
            } else {
                i4 = i6 + 1;
                i5 -= i2;
            }
            i8 += i4;
            iArr[i9] = i8;
        }
        return iArr;
    }

    private void H2() {
        this.M.clear();
        this.N.clear();
    }

    private int I2(RecyclerView.a0 a0Var) {
        if (I() != 0 && a0Var.b() != 0) {
            N1();
            boolean zH2 = h2();
            View viewR1 = R1(!zH2, true);
            View viewQ1 = Q1(!zH2, true);
            if (viewR1 != null && viewQ1 != null) {
                int iB = this.O.b(f0(viewR1), this.J);
                int iB2 = this.O.b(f0(viewQ1), this.J);
                int iMax = this.x ? Math.max(0, ((this.O.b(a0Var.b() - 1, this.J) + 1) - Math.max(iB, iB2)) - 1) : Math.max(0, Math.min(iB, iB2));
                if (zH2) {
                    return Math.round((iMax * (Math.abs(this.u.d(viewQ1) - this.u.g(viewR1)) / ((this.O.b(f0(viewQ1), this.J) - this.O.b(f0(viewR1), this.J)) + 1))) + (this.u.m() - this.u.g(viewR1)));
                }
                return iMax;
            }
        }
        return 0;
    }

    private int J2(RecyclerView.a0 a0Var) {
        if (I() != 0 && a0Var.b() != 0) {
            N1();
            View viewR1 = R1(!h2(), true);
            View viewQ1 = Q1(!h2(), true);
            if (viewR1 != null && viewQ1 != null) {
                if (!h2()) {
                    return this.O.b(a0Var.b() - 1, this.J) + 1;
                }
                int iD = this.u.d(viewQ1) - this.u.g(viewR1);
                int iB = this.O.b(f0(viewR1), this.J);
                return (int) ((iD / ((this.O.b(f0(viewQ1), this.J) - iB) + 1)) * (this.O.b(a0Var.b() - 1, this.J) + 1));
            }
        }
        return 0;
    }

    private void K2(RecyclerView.v vVar, RecyclerView.a0 a0Var, LinearLayoutManager.a aVar, int i2) {
        boolean z = i2 == 1;
        int iO2 = O2(vVar, a0Var, aVar.f973b);
        if (z) {
            while (iO2 > 0) {
                int i3 = aVar.f973b;
                if (i3 <= 0) {
                    return;
                }
                int i4 = i3 - 1;
                aVar.f973b = i4;
                iO2 = O2(vVar, a0Var, i4);
            }
            return;
        }
        int iB = a0Var.b() - 1;
        int i5 = aVar.f973b;
        while (i5 < iB) {
            int i6 = i5 + 1;
            int iO22 = O2(vVar, a0Var, i6);
            if (iO22 <= iO2) {
                break;
            }
            i5 = i6;
            iO2 = iO22;
        }
        aVar.f973b = i5;
    }

    private void L2() {
        View[] viewArr = this.L;
        if (viewArr == null || viewArr.length != this.J) {
            this.L = new View[this.J];
        }
    }

    private int N2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i2) {
        if (!a0Var.e()) {
            return this.O.b(i2, this.J);
        }
        int iF = vVar.f(i2);
        if (iF != -1) {
            return this.O.b(iF, this.J);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. " + i2);
        return 0;
    }

    private int O2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i2) {
        if (!a0Var.e()) {
            return this.O.c(i2, this.J);
        }
        int i3 = this.N.get(i2, -1);
        if (i3 != -1) {
            return i3;
        }
        int iF = vVar.f(i2);
        if (iF != -1) {
            return this.O.c(iF, this.J);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i2);
        return 0;
    }

    private int P2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i2) {
        if (!a0Var.e()) {
            return this.O.f(i2);
        }
        int i3 = this.M.get(i2, -1);
        if (i3 != -1) {
            return i3;
        }
        int iF = vVar.f(i2);
        if (iF != -1) {
            return this.O.f(iF);
        }
        Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i2);
        return 1;
    }

    private void Q2(float f2, int i2) {
        F2(Math.max(Math.round(f2 * this.J), i2));
    }

    private void R2(View view, int i2, boolean z) {
        int iJ;
        int iJ2;
        b bVar = (b) view.getLayoutParams();
        Rect rect = bVar.f1038b;
        int i3 = rect.top + rect.bottom + ((ViewGroup.MarginLayoutParams) bVar).topMargin + ((ViewGroup.MarginLayoutParams) bVar).bottomMargin;
        int i4 = rect.left + rect.right + ((ViewGroup.MarginLayoutParams) bVar).leftMargin + ((ViewGroup.MarginLayoutParams) bVar).rightMargin;
        int iM2 = M2(bVar.f968e, bVar.f969f);
        if (this.s == 1) {
            iJ2 = RecyclerView.LayoutManager.J(iM2, i2, i4, ((ViewGroup.MarginLayoutParams) bVar).width, false);
            iJ = RecyclerView.LayoutManager.J(this.u.n(), W(), i3, ((ViewGroup.MarginLayoutParams) bVar).height, true);
        } else {
            int iJ3 = RecyclerView.LayoutManager.J(iM2, i2, i3, ((ViewGroup.MarginLayoutParams) bVar).height, false);
            int iJ4 = RecyclerView.LayoutManager.J(this.u.n(), n0(), i4, ((ViewGroup.MarginLayoutParams) bVar).width, true);
            iJ = iJ3;
            iJ2 = iJ4;
        }
        S2(view, iJ2, iJ, z);
    }

    private void S2(View view, int i2, int i3, boolean z) {
        RecyclerView.p pVar = (RecyclerView.p) view.getLayoutParams();
        if (z ? D1(view, i2, i3, pVar) : B1(view, i2, i3, pVar)) {
            view.measure(i2, i3);
        }
    }

    private void U2() {
        int iV;
        int iE0;
        if (f2() == 1) {
            iV = m0() - d0();
            iE0 = c0();
        } else {
            iV = V() - b0();
            iE0 = e0();
        }
        F2(iV - iE0);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public RecyclerView.p C() {
        return this.s == 0 ? new b(-2, -1) : new b(-1, -2);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public RecyclerView.p D(Context context, AttributeSet attributeSet) {
        return new b(context, attributeSet);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public RecyclerView.p E(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof ViewGroup.MarginLayoutParams ? new b((ViewGroup.MarginLayoutParams) layoutParams) : new b(layoutParams);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public boolean F1() {
        return this.D == null && !this.I;
    }

    /* JADX WARN: Code restructure failed: missing block: B:59:0x00d6, code lost:
    
        if (r13 == (r2 > r15)) goto L49;
     */
    /* JADX WARN: Removed duplicated region for block: B:79:0x0107  */
    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.view.View H0(android.view.View r24, int r25, androidx.recyclerview.widget.RecyclerView.v r26, androidx.recyclerview.widget.RecyclerView.a0 r27) {
        /*
            Method dump skipped, instruction units count: 337
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.H0(android.view.View, int, androidx.recyclerview.widget.RecyclerView$v, androidx.recyclerview.widget.RecyclerView$a0):android.view.View");
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager
    void H1(RecyclerView.a0 a0Var, LinearLayoutManager.c cVar, RecyclerView.LayoutManager.c cVar2) {
        int iF = this.J;
        for (int i2 = 0; i2 < this.J && cVar.c(a0Var) && iF > 0; i2++) {
            int i3 = cVar.f982d;
            cVar2.a(i3, Math.max(0, cVar.f985g));
            iF -= this.O.f(i3);
            cVar.f982d += cVar.f983e;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int M(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        if (this.s == 1) {
            return this.J;
        }
        if (a0Var.b() < 1) {
            return 0;
        }
        return N2(vVar, a0Var, a0Var.b() - 1) + 1;
    }

    int M2(int i2, int i3) {
        if (this.s != 1 || !g2()) {
            int[] iArr = this.K;
            return iArr[i3 + i2] - iArr[i2];
        }
        int[] iArr2 = this.K;
        int i4 = this.J;
        return iArr2[i4 - i2] - iArr2[(i4 - i2) - i3];
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void N0(RecyclerView.v vVar, RecyclerView.a0 a0Var, View view, c.f.l.c0.d dVar) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (!(layoutParams instanceof b)) {
            super.M0(view, dVar);
            return;
        }
        b bVar = (b) layoutParams;
        int iN2 = N2(vVar, a0Var, bVar.a());
        if (this.s == 0) {
            dVar.N(d.c.a(bVar.e(), bVar.f(), iN2, 1, false, false));
        } else {
            dVar.N(d.c.a(iN2, 1, bVar.e(), bVar.f(), false, false));
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void P0(RecyclerView recyclerView, int i2, int i3) {
        this.O.h();
        this.O.g();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void Q0(RecyclerView recyclerView) {
        this.O.h();
        this.O.g();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void R0(RecyclerView recyclerView, int i2, int i3, int i4) {
        this.O.h();
        this.O.g();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void S0(RecyclerView recyclerView, int i2, int i3) {
        this.O.h();
        this.O.g();
    }

    public void T2(int i2) {
        if (i2 == this.J) {
            return;
        }
        this.I = true;
        if (i2 >= 1) {
            this.J = i2;
            this.O.h();
            q1();
        } else {
            throw new IllegalArgumentException("Span count should be at least 1. Provided " + i2);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void U0(RecyclerView recyclerView, int i2, int i3, Object obj) {
        this.O.h();
        this.O.g();
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void V0(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        if (a0Var.e()) {
            E2();
        }
        super.V0(vVar, a0Var);
        H2();
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void W0(RecyclerView.a0 a0Var) {
        super.W0(a0Var);
        this.I = false;
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager
    View Z1(RecyclerView.v vVar, RecyclerView.a0 a0Var, boolean z, boolean z2) {
        int I;
        int I2 = I();
        int i2 = -1;
        int i3 = 1;
        if (z2) {
            I = I() - 1;
            i3 = -1;
        } else {
            i2 = I2;
            I = 0;
        }
        int iB = a0Var.b();
        N1();
        int iM = this.u.m();
        int i4 = this.u.i();
        View view = null;
        View view2 = null;
        while (I != i2) {
            View viewH = H(I);
            int iF0 = f0(viewH);
            if (iF0 >= 0 && iF0 < iB && O2(vVar, a0Var, iF0) == 0) {
                if (((RecyclerView.p) viewH.getLayoutParams()).c()) {
                    if (view2 == null) {
                        view2 = viewH;
                    }
                } else {
                    if (this.u.g(viewH) < i4 && this.u.d(viewH) >= iM) {
                        return viewH;
                    }
                    if (view == null) {
                        view = viewH;
                    }
                }
            }
            I += i3;
        }
        return view != null ? view : view2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int i0(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        if (this.s == 0) {
            return this.J;
        }
        if (a0Var.b() < 1) {
            return 0;
        }
        return N2(vVar, a0Var, a0Var.b() - 1) + 1;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r5v0 */
    /* JADX WARN: Type inference failed for: r5v1, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r5v19 */
    @Override // androidx.recyclerview.widget.LinearLayoutManager
    void i2(RecyclerView.v vVar, RecyclerView.a0 a0Var, LinearLayoutManager.c cVar, LinearLayoutManager.b bVar) {
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        int iF;
        int iF2;
        int iF3;
        int iJ;
        int iJ2;
        View viewD;
        int iL = this.u.l();
        ?? r5 = 0;
        boolean z = iL != 1073741824;
        int i7 = I() > 0 ? this.K[this.J] : 0;
        if (z) {
            U2();
        }
        boolean z2 = cVar.f983e == 1;
        int iO2 = this.J;
        if (!z2) {
            iO2 = O2(vVar, a0Var, cVar.f982d) + P2(vVar, a0Var, cVar.f982d);
        }
        int i8 = 0;
        while (i8 < this.J && cVar.c(a0Var) && iO2 > 0) {
            int i9 = cVar.f982d;
            int iP2 = P2(vVar, a0Var, i9);
            if (iP2 > this.J) {
                throw new IllegalArgumentException("Item at position " + i9 + " requires " + iP2 + " spans but GridLayoutManager has only " + this.J + " spans.");
            }
            iO2 -= iP2;
            if (iO2 < 0 || (viewD = cVar.d(vVar)) == null) {
                break;
            }
            this.L[i8] = viewD;
            i8++;
        }
        if (i8 == 0) {
            bVar.f977b = true;
            return;
        }
        float f2 = 0.0f;
        D2(vVar, a0Var, i8, z2);
        int i10 = 0;
        int i11 = 0;
        while (i10 < i8) {
            View view = this.L[i10];
            if (cVar.l == null) {
                if (z2) {
                    c(view);
                } else {
                    d(view, r5);
                }
            } else if (z2) {
                a(view);
            } else {
                b(view, r5);
            }
            i(view, this.P);
            R2(view, iL, r5);
            int iE = this.u.e(view);
            if (iE > i11) {
                i11 = iE;
            }
            float f3 = (this.u.f(view) * 1.0f) / ((b) view.getLayoutParams()).f969f;
            if (f3 > f2) {
                f2 = f3;
            }
            i10++;
            r5 = 0;
        }
        if (z) {
            Q2(f2, i7);
            i11 = 0;
            for (int i12 = 0; i12 < i8; i12++) {
                View view2 = this.L[i12];
                R2(view2, Pow2.MAX_POW2, true);
                int iE2 = this.u.e(view2);
                if (iE2 > i11) {
                    i11 = iE2;
                }
            }
        }
        for (int i13 = 0; i13 < i8; i13++) {
            View view3 = this.L[i13];
            if (this.u.e(view3) != i11) {
                b bVar2 = (b) view3.getLayoutParams();
                Rect rect = bVar2.f1038b;
                int i14 = rect.top + rect.bottom + ((ViewGroup.MarginLayoutParams) bVar2).topMargin + ((ViewGroup.MarginLayoutParams) bVar2).bottomMargin;
                int i15 = rect.left + rect.right + ((ViewGroup.MarginLayoutParams) bVar2).leftMargin + ((ViewGroup.MarginLayoutParams) bVar2).rightMargin;
                int iM2 = M2(bVar2.f968e, bVar2.f969f);
                if (this.s == 1) {
                    iJ2 = RecyclerView.LayoutManager.J(iM2, Pow2.MAX_POW2, i15, ((ViewGroup.MarginLayoutParams) bVar2).width, false);
                    iJ = View.MeasureSpec.makeMeasureSpec(i11 - i14, Pow2.MAX_POW2);
                } else {
                    int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i11 - i15, Pow2.MAX_POW2);
                    iJ = RecyclerView.LayoutManager.J(iM2, Pow2.MAX_POW2, i14, ((ViewGroup.MarginLayoutParams) bVar2).height, false);
                    iJ2 = iMakeMeasureSpec;
                }
                S2(view3, iJ2, iJ, true);
            }
        }
        int i16 = 0;
        bVar.a = i11;
        if (this.s == 1) {
            if (cVar.f984f == -1) {
                i4 = cVar.f980b;
                i5 = i4 - i11;
            } else {
                int i17 = cVar.f980b;
                i5 = i17;
                i4 = i11 + i17;
            }
            i2 = 0;
            i3 = 0;
        } else if (cVar.f984f == -1) {
            int i18 = cVar.f980b;
            i3 = i18 - i11;
            i5 = 0;
            i2 = i18;
            i4 = 0;
        } else {
            int i19 = cVar.f980b;
            i2 = i11 + i19;
            i3 = i19;
            i4 = 0;
            i5 = 0;
        }
        while (i16 < i8) {
            View view4 = this.L[i16];
            b bVar3 = (b) view4.getLayoutParams();
            if (this.s == 1) {
                if (g2()) {
                    int iC0 = c0() + this.K[this.J - bVar3.f968e];
                    iF3 = i4;
                    iF = iC0;
                    iF2 = iC0 - this.u.f(view4);
                } else {
                    int iC02 = c0() + this.K[bVar3.f968e];
                    iF3 = i4;
                    iF2 = iC02;
                    iF = this.u.f(view4) + iC02;
                }
                i6 = i5;
            } else {
                int iE0 = e0() + this.K[bVar3.f968e];
                i6 = iE0;
                iF = i2;
                iF2 = i3;
                iF3 = this.u.f(view4) + iE0;
            }
            x0(view4, iF2, i6, iF, iF3);
            if (bVar3.c() || bVar3.b()) {
                bVar.f978c = true;
            }
            bVar.f979d |= view4.hasFocusable();
            i16++;
            i4 = iF3;
            i2 = iF;
            i3 = iF2;
            i5 = i6;
        }
        Arrays.fill(this.L, (Object) null);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager
    void k2(RecyclerView.v vVar, RecyclerView.a0 a0Var, LinearLayoutManager.a aVar, int i2) {
        super.k2(vVar, a0Var, aVar, i2);
        U2();
        if (a0Var.b() > 0 && !a0Var.e()) {
            K2(vVar, a0Var, aVar, i2);
        }
        L2();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public boolean l(RecyclerView.p pVar) {
        return pVar instanceof b;
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int q(RecyclerView.a0 a0Var) {
        return this.Q ? I2(a0Var) : super.q(a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int r(RecyclerView.a0 a0Var) {
        return this.Q ? J2(a0Var) : super.r(a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int t(RecyclerView.a0 a0Var) {
        return this.Q ? I2(a0Var) : super.t(a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int t1(int i2, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        U2();
        L2();
        return super.t1(i2, vVar, a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int u(RecyclerView.a0 a0Var) {
        return this.Q ? J2(a0Var) : super.u(a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
    public int u1(int i2, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        U2();
        L2();
        return super.u1(i2, vVar, a0Var);
    }

    @Override // androidx.recyclerview.widget.LinearLayoutManager
    public void u2(boolean z) {
        if (z) {
            throw new UnsupportedOperationException("GridLayoutManager does not support stack from end. Consider using reverse layout");
        }
        super.u2(false);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
    public void y1(Rect rect, int i2, int i3) {
        int iM;
        int iM2;
        if (this.K == null) {
            super.y1(rect, i2, i3);
        }
        int iC0 = c0() + d0();
        int iE0 = e0() + b0();
        if (this.s == 1) {
            iM2 = RecyclerView.LayoutManager.m(i3, rect.height() + iE0, Z());
            int[] iArr = this.K;
            iM = RecyclerView.LayoutManager.m(i2, iArr[iArr.length - 1] + iC0, a0());
        } else {
            iM = RecyclerView.LayoutManager.m(i2, rect.width() + iC0, a0());
            int[] iArr2 = this.K;
            iM2 = RecyclerView.LayoutManager.m(i3, iArr2[iArr2.length - 1] + iE0, Z());
        }
        x1(iM, iM2);
    }

    public static class b extends RecyclerView.p {

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

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

        public b(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f968e = -1;
            this.f969f = 0;
        }

        public int e() {
            return this.f968e;
        }

        public int f() {
            return this.f969f;
        }

        public b(int i2, int i3) {
            super(i2, i3);
            this.f968e = -1;
            this.f969f = 0;
        }

        public b(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f968e = -1;
            this.f969f = 0;
        }

        public b(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f968e = -1;
            this.f969f = 0;
        }
    }
}
