package androidx.recyclerview.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.recyclerview.widget.RecyclerView;
import c.n.c.m;
import c.n.c.r;
import java.util.List;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class LinearLayoutManager extends RecyclerView.m {
    public SavedState A;
    public final a B;
    public final b C;
    public int D;
    public int[] E;
    public int q;
    public c r;
    public r s;
    public boolean t;
    public boolean u;
    public boolean v;
    public boolean w;
    public boolean x;
    public int y;
    public int z;

    @SuppressLint({"BanParcelableUsage"})
    public static class SavedState implements Parcelable {
        public static final Parcelable.Creator<SavedState> CREATOR = new a();

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

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

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

        public class a implements Parcelable.Creator<SavedState> {
            @Override // android.os.Parcelable.Creator
            public SavedState createFromParcel(Parcel parcel) {
                return new SavedState(parcel);
            }

            @Override // android.os.Parcelable.Creator
            public SavedState[] newArray(int i2) {
                return new SavedState[i2];
            }
        }

        public SavedState() {
        }

        public boolean b() {
            return this.f396b >= 0;
        }

        @Override // android.os.Parcelable
        public int describeContents() {
            return 0;
        }

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeInt(this.f396b);
            parcel.writeInt(this.f397e);
            parcel.writeInt(this.f398f ? 1 : 0);
        }

        public SavedState(Parcel parcel) {
            this.f396b = parcel.readInt();
            this.f397e = parcel.readInt();
            this.f398f = parcel.readInt() == 1;
        }

        @SuppressLint({"UnknownNullness"})
        public SavedState(SavedState savedState) {
            this.f396b = savedState.f396b;
            this.f397e = savedState.f397e;
            this.f398f = savedState.f398f;
        }
    }

    public static class a {
        public r a;

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

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

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

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

        public a() {
            d();
        }

        public void a() {
            this.f400c = this.f401d ? this.a.g() : this.a.k();
        }

        public void b(View view, int i2) {
            if (this.f401d) {
                this.f400c = this.a.m() + this.a.b(view);
            } else {
                this.f400c = this.a.e(view);
            }
            this.f399b = i2;
        }

        public void c(View view, int i2) {
            int iM = this.a.m();
            if (iM >= 0) {
                b(view, i2);
                return;
            }
            this.f399b = i2;
            if (!this.f401d) {
                int iE = this.a.e(view);
                int iK = iE - this.a.k();
                this.f400c = iE;
                if (iK > 0) {
                    int iG = (this.a.g() - Math.min(0, (this.a.g() - iM) - this.a.b(view))) - (this.a.c(view) + iE);
                    if (iG < 0) {
                        this.f400c -= Math.min(iK, -iG);
                        return;
                    }
                    return;
                }
                return;
            }
            int iG2 = (this.a.g() - iM) - this.a.b(view);
            this.f400c = this.a.g() - iG2;
            if (iG2 > 0) {
                int iC = this.f400c - this.a.c(view);
                int iK2 = this.a.k();
                int iMin = iC - (Math.min(this.a.e(view) - iK2, 0) + iK2);
                if (iMin < 0) {
                    this.f400c = Math.min(iG2, -iMin) + this.f400c;
                }
            }
        }

        public void d() {
            this.f399b = -1;
            this.f400c = Integer.MIN_VALUE;
            this.f401d = false;
            this.f402e = false;
        }

        public String toString() {
            StringBuilder sbB = d.b.a.a.a.B("AnchorInfo{mPosition=");
            sbB.append(this.f399b);
            sbB.append(", mCoordinate=");
            sbB.append(this.f400c);
            sbB.append(", mLayoutFromEnd=");
            sbB.append(this.f401d);
            sbB.append(", mValid=");
            sbB.append(this.f402e);
            sbB.append('}');
            return sbB.toString();
        }
    }

    public static class b {
        public int a;

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

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

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public boolean f405d;
    }

    public static class c {

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

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

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

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

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

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

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

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        public boolean f416l;
        public boolean a = true;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public int f412h = 0;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public int f413i = 0;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        public List<RecyclerView.z> f415k = null;

        public void a(View view) {
            int iA;
            int size = this.f415k.size();
            View view2 = null;
            int i2 = Integer.MAX_VALUE;
            for (int i3 = 0; i3 < size; i3++) {
                View view3 = this.f415k.get(i3).f483b;
                RecyclerView.n nVar = (RecyclerView.n) view3.getLayoutParams();
                if (view3 != view && !nVar.c() && (iA = (nVar.a() - this.f408d) * this.f409e) >= 0 && iA < i2) {
                    view2 = view3;
                    if (iA == 0) {
                        break;
                    } else {
                        i2 = iA;
                    }
                }
            }
            if (view2 == null) {
                this.f408d = -1;
            } else {
                this.f408d = ((RecyclerView.n) view2.getLayoutParams()).a();
            }
        }

        public boolean b(RecyclerView.v vVar) {
            int i2 = this.f408d;
            return i2 >= 0 && i2 < vVar.b();
        }

        public View c(RecyclerView.s sVar) {
            List<RecyclerView.z> list = this.f415k;
            if (list == null) {
                View view = sVar.l(this.f408d, false, Long.MAX_VALUE).f483b;
                this.f408d += this.f409e;
                return view;
            }
            int size = list.size();
            for (int i2 = 0; i2 < size; i2++) {
                View view2 = this.f415k.get(i2).f483b;
                RecyclerView.n nVar = (RecyclerView.n) view2.getLayoutParams();
                if (!nVar.c() && this.f408d == nVar.a()) {
                    a(view2);
                    return view2;
                }
            }
            return null;
        }
    }

    public LinearLayoutManager(@SuppressLint({"UnknownNullness"}) Context context) {
        this.q = 1;
        this.u = false;
        this.v = false;
        this.w = false;
        this.x = true;
        this.y = -1;
        this.z = Integer.MIN_VALUE;
        this.A = null;
        this.B = new a();
        this.C = new b();
        this.D = 2;
        this.E = new int[2];
        r1(1);
        c(null);
        if (this.u) {
            this.u = false;
            F0();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int G0(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        if (this.q == 1) {
            return 0;
        }
        return q1(i2, sVar, vVar);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int H0(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        if (this.q == 0) {
            return 0;
        }
        return q1(i2, sVar, vVar);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean O0() {
        boolean z;
        if (this.n == 1073741824 || this.m == 1073741824) {
            return false;
        }
        int iX = x();
        int i2 = 0;
        while (true) {
            if (i2 >= iX) {
                z = false;
                break;
            }
            ViewGroup.LayoutParams layoutParams = w(i2).getLayoutParams();
            if (layoutParams.width < 0 && layoutParams.height < 0) {
                z = true;
                break;
            }
            i2++;
        }
        return z;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean Q() {
        return true;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean Q0() {
        return this.A == null && this.t == this.w;
    }

    public void R0(RecyclerView.v vVar, c cVar, RecyclerView.m.c cVar2) {
        int i2 = cVar.f408d;
        if (i2 < 0 || i2 >= vVar.b()) {
            return;
        }
        ((m.b) cVar2).a(i2, Math.max(0, cVar.f411g));
    }

    public final int S0(RecyclerView.v vVar) {
        if (x() == 0) {
            return 0;
        }
        W0();
        return c.n.a.g(vVar, this.s, Z0(!this.x, true), Y0(!this.x, true), this, this.x);
    }

    public final int T0(RecyclerView.v vVar) {
        if (x() == 0) {
            return 0;
        }
        W0();
        return c.n.a.h(vVar, this.s, Z0(!this.x, true), Y0(!this.x, true), this, this.x, this.v);
    }

    public final int U0(RecyclerView.v vVar) {
        if (x() == 0) {
            return 0;
        }
        W0();
        return c.n.a.i(vVar, this.s, Z0(!this.x, true), Y0(!this.x, true), this, this.x);
    }

    public int V0(int i2) {
        return i2 != 1 ? i2 != 2 ? i2 != 17 ? i2 != 33 ? i2 != 66 ? (i2 == 130 && this.q == 1) ? 1 : Integer.MIN_VALUE : this.q == 0 ? 1 : Integer.MIN_VALUE : this.q == 1 ? -1 : Integer.MIN_VALUE : this.q == 0 ? -1 : Integer.MIN_VALUE : (this.q != 1 && j1()) ? -1 : 1 : (this.q != 1 && j1()) ? 1 : -1;
    }

    public void W0() {
        if (this.r == null) {
            this.r = new c();
        }
    }

    public int X0(RecyclerView.s sVar, c cVar, RecyclerView.v vVar, boolean z) {
        int i2 = cVar.f407c;
        int i3 = cVar.f411g;
        if (i3 != Integer.MIN_VALUE) {
            if (i2 < 0) {
                cVar.f411g = i3 + i2;
            }
            m1(sVar, cVar);
        }
        int i4 = cVar.f407c + cVar.f412h;
        b bVar = this.C;
        while (true) {
            if ((!cVar.f416l && i4 <= 0) || !cVar.b(vVar)) {
                break;
            }
            bVar.a = 0;
            bVar.f403b = false;
            bVar.f404c = false;
            bVar.f405d = false;
            k1(sVar, vVar, cVar, bVar);
            if (!bVar.f403b) {
                int i5 = cVar.f406b;
                int i6 = bVar.a;
                cVar.f406b = (cVar.f410f * i6) + i5;
                if (!bVar.f404c || cVar.f415k != null || !vVar.f469f) {
                    cVar.f407c -= i6;
                    i4 -= i6;
                }
                int i7 = cVar.f411g;
                if (i7 != Integer.MIN_VALUE) {
                    int i8 = i7 + i6;
                    cVar.f411g = i8;
                    int i9 = cVar.f407c;
                    if (i9 < 0) {
                        cVar.f411g = i8 + i9;
                    }
                    m1(sVar, cVar);
                }
                if (z && bVar.f405d) {
                    break;
                }
            } else {
                break;
            }
        }
        return i2 - cVar.f407c;
    }

    public View Y0(boolean z, boolean z2) {
        return this.v ? d1(0, x(), z, z2) : d1(x() - 1, -1, z, z2);
    }

    public View Z0(boolean z, boolean z2) {
        return this.v ? d1(x() - 1, -1, z, z2) : d1(0, x(), z, z2);
    }

    public int a1() {
        View viewD1 = d1(0, x(), false, true);
        if (viewD1 == null) {
            return -1;
        }
        return L(viewD1);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void b0(RecyclerView recyclerView, RecyclerView.s sVar) {
        a0();
    }

    public int b1() {
        View viewD1 = d1(x() - 1, -1, false, true);
        if (viewD1 == null) {
            return -1;
        }
        return L(viewD1);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void c(String str) {
        RecyclerView recyclerView;
        if (this.A != null || (recyclerView = this.f436b) == null) {
            return;
        }
        recyclerView.f(str);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public View c0(View view, int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        int iV0;
        p1();
        if (x() == 0 || (iV0 = V0(i2)) == Integer.MIN_VALUE) {
            return null;
        }
        W0();
        t1(iV0, (int) (this.s.l() * 0.33333334f), false, vVar);
        c cVar = this.r;
        cVar.f411g = Integer.MIN_VALUE;
        cVar.a = false;
        X0(sVar, cVar, vVar, true);
        View viewC1 = iV0 == -1 ? this.v ? c1(x() - 1, -1) : c1(0, x()) : this.v ? c1(0, x()) : c1(x() - 1, -1);
        View viewI1 = iV0 == -1 ? i1() : h1();
        if (!viewI1.hasFocusable()) {
            return viewC1;
        }
        if (viewC1 == null) {
            return null;
        }
        return viewI1;
    }

    public View c1(int i2, int i3) {
        int i4;
        int i5;
        W0();
        if ((i3 > i2 ? (byte) 1 : i3 < i2 ? (byte) -1 : (byte) 0) == 0) {
            return w(i2);
        }
        if (this.s.e(w(i2)) < this.s.k()) {
            i4 = 16644;
            i5 = 16388;
        } else {
            i4 = 4161;
            i5 = 4097;
        }
        return this.q == 0 ? this.f439e.a(i2, i3, i4, i5) : this.f440f.a(i2, i3, i4, i5);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean d() {
        return this.q == 0;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void d0(AccessibilityEvent accessibilityEvent) {
        RecyclerView.s sVar = this.f436b.n;
        e0(accessibilityEvent);
        if (x() > 0) {
            accessibilityEvent.setFromIndex(a1());
            accessibilityEvent.setToIndex(b1());
        }
    }

    public View d1(int i2, int i3, boolean z, boolean z2) {
        W0();
        int i4 = z ? 24579 : 320;
        int i5 = z2 ? 320 : 0;
        return this.q == 0 ? this.f439e.a(i2, i3, i4, i5) : this.f440f.a(i2, i3, i4, i5);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean e() {
        return this.q == 1;
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x0073  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0077  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.view.View e1(androidx.recyclerview.widget.RecyclerView.s r17, androidx.recyclerview.widget.RecyclerView.v r18, boolean r19, boolean r20) {
        /*
            r16 = this;
            r0 = r16
            r16.W0()
            int r1 = r16.x()
            r2 = -1
            r3 = 0
            r4 = 1
            if (r20 == 0) goto L15
            int r1 = r16.x()
            int r1 = r1 - r4
            r5 = r2
            goto L18
        L15:
            r2 = r1
            r1 = r3
            r5 = r4
        L18:
            int r6 = r18.b()
            c.n.c.r r7 = r0.s
            int r7 = r7.k()
            c.n.c.r r8 = r0.s
            int r8 = r8.g()
            r9 = 0
            r10 = r9
            r11 = r10
        L2b:
            if (r1 == r2) goto L7a
            android.view.View r12 = r0.w(r1)
            int r13 = r0.L(r12)
            c.n.c.r r14 = r0.s
            int r14 = r14.e(r12)
            c.n.c.r r15 = r0.s
            int r15 = r15.b(r12)
            if (r13 < 0) goto L78
            if (r13 >= r6) goto L78
            android.view.ViewGroup$LayoutParams r13 = r12.getLayoutParams()
            androidx.recyclerview.widget.RecyclerView$n r13 = (androidx.recyclerview.widget.RecyclerView.n) r13
            boolean r13 = r13.c()
            if (r13 == 0) goto L55
            if (r11 != 0) goto L78
            r11 = r12
            goto L78
        L55:
            if (r15 > r7) goto L5b
            if (r14 >= r7) goto L5b
            r13 = r4
            goto L5c
        L5b:
            r13 = r3
        L5c:
            if (r14 < r8) goto L62
            if (r15 <= r8) goto L62
            r14 = r4
            goto L63
        L62:
            r14 = r3
        L63:
            if (r13 != 0) goto L69
            if (r14 == 0) goto L68
            goto L69
        L68:
            return r12
        L69:
            if (r19 == 0) goto L71
            if (r14 == 0) goto L6e
            goto L73
        L6e:
            if (r9 != 0) goto L78
            goto L77
        L71:
            if (r13 == 0) goto L75
        L73:
            r10 = r12
            goto L78
        L75:
            if (r9 != 0) goto L78
        L77:
            r9 = r12
        L78:
            int r1 = r1 + r5
            goto L2b
        L7a:
            if (r9 == 0) goto L7d
            goto L82
        L7d:
            if (r10 == 0) goto L81
            r9 = r10
            goto L82
        L81:
            r9 = r11
        L82:
            return r9
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.LinearLayoutManager.e1(androidx.recyclerview.widget.RecyclerView$s, androidx.recyclerview.widget.RecyclerView$v, boolean, boolean):android.view.View");
    }

    public final int f1(int i2, RecyclerView.s sVar, RecyclerView.v vVar, boolean z) {
        int iG;
        int iG2 = this.s.g() - i2;
        if (iG2 <= 0) {
            return 0;
        }
        int i3 = -q1(-iG2, sVar, vVar);
        int i4 = i2 + i3;
        if (!z || (iG = this.s.g() - i4) <= 0) {
            return i3;
        }
        this.s.p(iG);
        return iG + i3;
    }

    public final int g1(int i2, RecyclerView.s sVar, RecyclerView.v vVar, boolean z) {
        int iK;
        int iK2 = i2 - this.s.k();
        if (iK2 <= 0) {
            return 0;
        }
        int i3 = -q1(iK2, sVar, vVar);
        int i4 = i2 + i3;
        if (!z || (iK = i4 - this.s.k()) <= 0) {
            return i3;
        }
        this.s.p(-iK);
        return i3 - iK;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void h(int i2, int i3, RecyclerView.v vVar, RecyclerView.m.c cVar) {
        if (this.q != 0) {
            i2 = i3;
        }
        if (x() == 0 || i2 == 0) {
            return;
        }
        W0();
        t1(i2 > 0 ? 1 : -1, Math.abs(i2), true, vVar);
        R0(vVar, this.r, cVar);
    }

    public final View h1() {
        return w(this.v ? 0 : x() - 1);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void i(int i2, RecyclerView.m.c cVar) {
        boolean z;
        int i3;
        SavedState savedState = this.A;
        if (savedState == null || !savedState.b()) {
            p1();
            z = this.v;
            i3 = this.y;
            if (i3 == -1) {
                i3 = z ? i2 - 1 : 0;
            }
        } else {
            SavedState savedState2 = this.A;
            z = savedState2.f398f;
            i3 = savedState2.f396b;
        }
        int i4 = z ? -1 : 1;
        for (int i5 = 0; i5 < this.D && i3 >= 0 && i3 < i2; i5++) {
            ((m.b) cVar).a(i3, 0);
            i3 += i4;
        }
    }

    public final View i1() {
        return w(this.v ? x() - 1 : 0);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int j(RecyclerView.v vVar) {
        return S0(vVar);
    }

    public boolean j1() {
        return E() == 1;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int k(RecyclerView.v vVar) {
        return T0(vVar);
    }

    public void k1(RecyclerView.s sVar, RecyclerView.v vVar, c cVar, b bVar) {
        int i2;
        int i3;
        int i4;
        int I;
        int iD;
        View viewC = cVar.c(sVar);
        if (viewC == null) {
            bVar.f403b = true;
            return;
        }
        RecyclerView.n nVar = (RecyclerView.n) viewC.getLayoutParams();
        if (cVar.f415k == null) {
            if (this.v == (cVar.f410f == -1)) {
                b(viewC, -1, false);
            } else {
                b(viewC, 0, false);
            }
        } else {
            if (this.v == (cVar.f410f == -1)) {
                b(viewC, -1, true);
            } else {
                b(viewC, 0, true);
            }
        }
        RecyclerView.n nVar2 = (RecyclerView.n) viewC.getLayoutParams();
        Rect rectK = this.f436b.K(viewC);
        int i5 = rectK.left + rectK.right + 0;
        int i6 = rectK.top + rectK.bottom + 0;
        int iY = RecyclerView.m.y(this.o, this.m, J() + I() + ((ViewGroup.MarginLayoutParams) nVar2).leftMargin + ((ViewGroup.MarginLayoutParams) nVar2).rightMargin + i5, ((ViewGroup.MarginLayoutParams) nVar2).width, d());
        int iY2 = RecyclerView.m.y(this.p, this.n, H() + K() + ((ViewGroup.MarginLayoutParams) nVar2).topMargin + ((ViewGroup.MarginLayoutParams) nVar2).bottomMargin + i6, ((ViewGroup.MarginLayoutParams) nVar2).height, e());
        if (N0(viewC, iY, iY2, nVar2)) {
            viewC.measure(iY, iY2);
        }
        bVar.a = this.s.c(viewC);
        if (this.q == 1) {
            if (j1()) {
                iD = this.o - J();
                I = iD - this.s.d(viewC);
            } else {
                I = I();
                iD = this.s.d(viewC) + I;
            }
            if (cVar.f410f == -1) {
                int i7 = cVar.f406b;
                i4 = i7;
                i3 = iD;
                i2 = i7 - bVar.a;
            } else {
                int i8 = cVar.f406b;
                i2 = i8;
                i3 = iD;
                i4 = bVar.a + i8;
            }
        } else {
            int iK = K();
            int iD2 = this.s.d(viewC) + iK;
            if (cVar.f410f == -1) {
                int i9 = cVar.f406b;
                i3 = i9;
                i2 = iK;
                i4 = iD2;
                I = i9 - bVar.a;
            } else {
                int i10 = cVar.f406b;
                i2 = iK;
                i3 = bVar.a + i10;
                i4 = iD2;
                I = i10;
            }
        }
        U(viewC, I, i2, i3, i4);
        if (nVar.c() || nVar.b()) {
            bVar.f404c = true;
        }
        bVar.f405d = viewC.hasFocusable();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int l(RecyclerView.v vVar) {
        return U0(vVar);
    }

    public void l1(RecyclerView.s sVar, RecyclerView.v vVar, a aVar, int i2) {
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int m(RecyclerView.v vVar) {
        return S0(vVar);
    }

    public final void m1(RecyclerView.s sVar, c cVar) {
        if (!cVar.a || cVar.f416l) {
            return;
        }
        int i2 = cVar.f411g;
        int i3 = cVar.f413i;
        if (cVar.f410f == -1) {
            int iX = x();
            if (i2 < 0) {
                return;
            }
            int iF = (this.s.f() - i2) + i3;
            if (this.v) {
                for (int i4 = 0; i4 < iX; i4++) {
                    View viewW = w(i4);
                    if (this.s.e(viewW) < iF || this.s.o(viewW) < iF) {
                        n1(sVar, 0, i4);
                        return;
                    }
                }
                return;
            }
            int i5 = iX - 1;
            for (int i6 = i5; i6 >= 0; i6--) {
                View viewW2 = w(i6);
                if (this.s.e(viewW2) < iF || this.s.o(viewW2) < iF) {
                    n1(sVar, i5, i6);
                    return;
                }
            }
            return;
        }
        if (i2 < 0) {
            return;
        }
        int i7 = i2 - i3;
        int iX2 = x();
        if (!this.v) {
            for (int i8 = 0; i8 < iX2; i8++) {
                View viewW3 = w(i8);
                if (this.s.b(viewW3) > i7 || this.s.n(viewW3) > i7) {
                    n1(sVar, 0, i8);
                    return;
                }
            }
            return;
        }
        int i9 = iX2 - 1;
        for (int i10 = i9; i10 >= 0; i10--) {
            View viewW4 = w(i10);
            if (this.s.b(viewW4) > i7 || this.s.n(viewW4) > i7) {
                n1(sVar, i9, i10);
                return;
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int n(RecyclerView.v vVar) {
        return T0(vVar);
    }

    public final void n1(RecyclerView.s sVar, int i2, int i3) {
        if (i2 == i3) {
            return;
        }
        if (i3 <= i2) {
            while (i2 > i3) {
                C0(i2, sVar);
                i2--;
            }
        } else {
            for (int i4 = i3 - 1; i4 >= i2; i4--) {
                C0(i4, sVar);
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public int o(RecyclerView.v vVar) {
        return U0(vVar);
    }

    public boolean o1() {
        return this.s.i() == 0 && this.s.f() == 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:127:0x020e  */
    /* JADX WARN: Removed duplicated region for block: B:84:0x0180  */
    /* JADX WARN: Removed duplicated region for block: B:99:0x01b7  */
    @Override // androidx.recyclerview.widget.RecyclerView.m
    @android.annotation.SuppressLint({"UnknownNullness"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void p0(androidx.recyclerview.widget.RecyclerView.s r17, androidx.recyclerview.widget.RecyclerView.v r18) {
        /*
            Method dump skipped, instruction units count: 1068
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.LinearLayoutManager.p0(androidx.recyclerview.widget.RecyclerView$s, androidx.recyclerview.widget.RecyclerView$v):void");
    }

    public final void p1() {
        if (this.q == 1 || !j1()) {
            this.v = this.u;
        } else {
            this.v = !this.u;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void q0(RecyclerView.v vVar) {
        this.A = null;
        this.y = -1;
        this.z = Integer.MIN_VALUE;
        this.B.d();
    }

    public int q1(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        if (x() == 0 || i2 == 0) {
            return 0;
        }
        W0();
        this.r.a = true;
        int i3 = i2 > 0 ? 1 : -1;
        int iAbs = Math.abs(i2);
        t1(i3, iAbs, true, vVar);
        c cVar = this.r;
        int iX0 = X0(sVar, cVar, vVar, false) + cVar.f411g;
        if (iX0 < 0) {
            return 0;
        }
        if (iAbs > iX0) {
            i2 = i3 * iX0;
        }
        this.s.p(-i2);
        this.r.f414j = i2;
        return i2;
    }

    public void r1(int i2) {
        if (i2 != 0 && i2 != 1) {
            throw new IllegalArgumentException(d.b.a.a.a.j("invalid orientation:", i2));
        }
        c(null);
        if (i2 != this.q || this.s == null) {
            r rVarA = r.a(this, i2);
            this.s = rVarA;
            this.B.a = rVarA;
            this.q = i2;
            F0();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public View s(int i2) {
        int iX = x();
        if (iX == 0) {
            return null;
        }
        int iL = i2 - L(w(0));
        if (iL >= 0 && iL < iX) {
            View viewW = w(iL);
            if (L(viewW) == i2) {
                return viewW;
            }
        }
        return super.s(i2);
    }

    public void s1(boolean z) {
        c(null);
        if (this.w == z) {
            return;
        }
        this.w = z;
        F0();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public RecyclerView.n t() {
        return new RecyclerView.n(-2, -2);
    }

    public final void t1(int i2, int i3, boolean z, RecyclerView.v vVar) {
        int iK;
        this.r.f416l = o1();
        this.r.f410f = i2;
        int[] iArr = this.E;
        iArr[0] = 0;
        iArr[1] = 0;
        Objects.requireNonNull(vVar);
        int i4 = this.r.f410f;
        iArr[0] = 0;
        iArr[1] = 0;
        int iMax = Math.max(0, this.E[0]);
        int iMax2 = Math.max(0, this.E[1]);
        boolean z2 = i2 == 1;
        c cVar = this.r;
        int i5 = z2 ? iMax2 : iMax;
        cVar.f412h = i5;
        if (!z2) {
            iMax = iMax2;
        }
        cVar.f413i = iMax;
        if (z2) {
            cVar.f412h = this.s.h() + i5;
            View viewH1 = h1();
            c cVar2 = this.r;
            cVar2.f409e = this.v ? -1 : 1;
            int iL = L(viewH1);
            c cVar3 = this.r;
            cVar2.f408d = iL + cVar3.f409e;
            cVar3.f406b = this.s.b(viewH1);
            iK = this.s.b(viewH1) - this.s.g();
        } else {
            View viewI1 = i1();
            c cVar4 = this.r;
            cVar4.f412h = this.s.k() + cVar4.f412h;
            c cVar5 = this.r;
            cVar5.f409e = this.v ? 1 : -1;
            int iL2 = L(viewI1);
            c cVar6 = this.r;
            cVar5.f408d = iL2 + cVar6.f409e;
            cVar6.f406b = this.s.e(viewI1);
            iK = (-this.s.e(viewI1)) + this.s.k();
        }
        c cVar7 = this.r;
        cVar7.f407c = i3;
        if (z) {
            cVar7.f407c = i3 - iK;
        }
        cVar7.f411g = iK;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public void u0(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            this.A = savedState;
            if (this.y != -1) {
                savedState.f396b = -1;
            }
            F0();
        }
    }

    public final void u1(int i2, int i3) {
        this.r.f407c = this.s.g() - i3;
        c cVar = this.r;
        cVar.f409e = this.v ? -1 : 1;
        cVar.f408d = i2;
        cVar.f410f = 1;
        cVar.f406b = i3;
        cVar.f411g = Integer.MIN_VALUE;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    @SuppressLint({"UnknownNullness"})
    public Parcelable v0() {
        SavedState savedState = this.A;
        if (savedState != null) {
            return new SavedState(savedState);
        }
        SavedState savedState2 = new SavedState();
        if (x() > 0) {
            W0();
            boolean z = this.t ^ this.v;
            savedState2.f398f = z;
            if (z) {
                View viewH1 = h1();
                savedState2.f397e = this.s.g() - this.s.b(viewH1);
                savedState2.f396b = L(viewH1);
            } else {
                View viewI1 = i1();
                savedState2.f396b = L(viewI1);
                savedState2.f397e = this.s.e(viewI1) - this.s.k();
            }
        } else {
            savedState2.f396b = -1;
        }
        return savedState2;
    }

    public final void v1(int i2, int i3) {
        this.r.f407c = i3 - this.s.k();
        c cVar = this.r;
        cVar.f408d = i2;
        cVar.f409e = this.v ? 1 : -1;
        cVar.f410f = -1;
        cVar.f406b = i3;
        cVar.f411g = Integer.MIN_VALUE;
    }

    @SuppressLint({"UnknownNullness"})
    public LinearLayoutManager(Context context, AttributeSet attributeSet, int i2, int i3) {
        this.q = 1;
        this.u = false;
        this.v = false;
        this.w = false;
        this.x = true;
        this.y = -1;
        this.z = Integer.MIN_VALUE;
        this.A = null;
        this.B = new a();
        this.C = new b();
        this.D = 2;
        this.E = new int[2];
        RecyclerView.m.d dVarM = RecyclerView.m.M(context, attributeSet, i2, i3);
        r1(dVarM.a);
        boolean z = dVarM.f448c;
        c(null);
        if (z != this.u) {
            this.u = z;
            F0();
        }
        s1(dVarM.f449d);
    }
}
