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.n;
import c.n.c.r;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class StaggeredGridLayoutManager extends RecyclerView.m {
    public boolean E;
    public boolean F;
    public SavedState G;
    public int H;
    public int[] L;
    public int q;
    public d[] r;
    public r s;
    public r t;
    public int u;
    public int v;
    public final n w;
    public boolean x;
    public BitSet z;
    public boolean y = false;
    public int A = -1;
    public int B = Integer.MIN_VALUE;
    public LazySpanLookup C = new LazySpanLookup();
    public int D = 2;
    public final Rect I = new Rect();
    public final b J = new b();
    public boolean K = true;
    public final Runnable M = new a();

    @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 f499b;

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

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

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

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

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public int[] f504i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public List<LazySpanLookup.FullSpanItem> f505j;

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

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        public boolean f507l;
        public boolean m;

        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() {
        }

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

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeInt(this.f499b);
            parcel.writeInt(this.f500e);
            parcel.writeInt(this.f501f);
            if (this.f501f > 0) {
                parcel.writeIntArray(this.f502g);
            }
            parcel.writeInt(this.f503h);
            if (this.f503h > 0) {
                parcel.writeIntArray(this.f504i);
            }
            parcel.writeInt(this.f506k ? 1 : 0);
            parcel.writeInt(this.f507l ? 1 : 0);
            parcel.writeInt(this.m ? 1 : 0);
            parcel.writeList(this.f505j);
        }

        public SavedState(Parcel parcel) {
            this.f499b = parcel.readInt();
            this.f500e = parcel.readInt();
            int i2 = parcel.readInt();
            this.f501f = i2;
            if (i2 > 0) {
                int[] iArr = new int[i2];
                this.f502g = iArr;
                parcel.readIntArray(iArr);
            }
            int i3 = parcel.readInt();
            this.f503h = i3;
            if (i3 > 0) {
                int[] iArr2 = new int[i3];
                this.f504i = iArr2;
                parcel.readIntArray(iArr2);
            }
            this.f506k = parcel.readInt() == 1;
            this.f507l = parcel.readInt() == 1;
            this.m = parcel.readInt() == 1;
            this.f505j = parcel.readArrayList(LazySpanLookup.FullSpanItem.class.getClassLoader());
        }

        public SavedState(SavedState savedState) {
            this.f501f = savedState.f501f;
            this.f499b = savedState.f499b;
            this.f500e = savedState.f500e;
            this.f502g = savedState.f502g;
            this.f503h = savedState.f503h;
            this.f504i = savedState.f504i;
            this.f506k = savedState.f506k;
            this.f507l = savedState.f507l;
            this.m = savedState.m;
            this.f505j = savedState.f505j;
        }
    }

    public class a implements Runnable {
        public a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            StaggeredGridLayoutManager.this.R0();
        }
    }

    public class b {
        public int a;

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

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

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

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

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

        public b() {
            b();
        }

        public void a() {
            this.f509b = this.f510c ? StaggeredGridLayoutManager.this.s.g() : StaggeredGridLayoutManager.this.s.k();
        }

        public void b() {
            this.a = -1;
            this.f509b = Integer.MIN_VALUE;
            this.f510c = false;
            this.f511d = false;
            this.f512e = false;
            int[] iArr = this.f513f;
            if (iArr != null) {
                Arrays.fill(iArr, -1);
            }
        }
    }

    public static class c extends RecyclerView.n {

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

        public c(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public c(int i2, int i3) {
            super(i2, i3);
        }

        public c(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
        }

        public c(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }
    }

    public class d {
        public ArrayList<View> a = new ArrayList<>();

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f516b = Integer.MIN_VALUE;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f517c = Integer.MIN_VALUE;

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

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

        public d(int i2) {
            this.f519e = i2;
        }

        public void a(View view) {
            c cVarJ = j(view);
            cVarJ.f515e = this;
            this.a.add(view);
            this.f517c = Integer.MIN_VALUE;
            if (this.a.size() == 1) {
                this.f516b = Integer.MIN_VALUE;
            }
            if (cVarJ.c() || cVarJ.b()) {
                this.f518d = StaggeredGridLayoutManager.this.s.c(view) + this.f518d;
            }
        }

        public void b() {
            View view = this.a.get(r0.size() - 1);
            c cVarJ = j(view);
            this.f517c = StaggeredGridLayoutManager.this.s.b(view);
            Objects.requireNonNull(cVarJ);
        }

        public void c() {
            View view = this.a.get(0);
            c cVarJ = j(view);
            this.f516b = StaggeredGridLayoutManager.this.s.e(view);
            Objects.requireNonNull(cVarJ);
        }

        public void d() {
            this.a.clear();
            this.f516b = Integer.MIN_VALUE;
            this.f517c = Integer.MIN_VALUE;
            this.f518d = 0;
        }

        public int e() {
            return StaggeredGridLayoutManager.this.x ? g(this.a.size() - 1, -1, true) : g(0, this.a.size(), true);
        }

        public int f() {
            return StaggeredGridLayoutManager.this.x ? g(0, this.a.size(), true) : g(this.a.size() - 1, -1, true);
        }

        public int g(int i2, int i3, boolean z) {
            int iK = StaggeredGridLayoutManager.this.s.k();
            int iG = StaggeredGridLayoutManager.this.s.g();
            int i4 = i3 > i2 ? 1 : -1;
            while (i2 != i3) {
                View view = this.a.get(i2);
                int iE = StaggeredGridLayoutManager.this.s.e(view);
                int iB = StaggeredGridLayoutManager.this.s.b(view);
                boolean z2 = false;
                boolean z3 = !z ? iE >= iG : iE > iG;
                if (!z ? iB > iK : iB >= iK) {
                    z2 = true;
                }
                if (z3 && z2 && (iE < iK || iB > iG)) {
                    return StaggeredGridLayoutManager.this.L(view);
                }
                i2 += i4;
            }
            return -1;
        }

        public int h(int i2) {
            int i3 = this.f517c;
            if (i3 != Integer.MIN_VALUE) {
                return i3;
            }
            if (this.a.size() == 0) {
                return i2;
            }
            b();
            return this.f517c;
        }

        public View i(int i2, int i3) {
            View view = null;
            if (i3 != -1) {
                int size = this.a.size() - 1;
                while (size >= 0) {
                    View view2 = this.a.get(size);
                    StaggeredGridLayoutManager staggeredGridLayoutManager = StaggeredGridLayoutManager.this;
                    if (staggeredGridLayoutManager.x && staggeredGridLayoutManager.L(view2) >= i2) {
                        break;
                    }
                    StaggeredGridLayoutManager staggeredGridLayoutManager2 = StaggeredGridLayoutManager.this;
                    if ((!staggeredGridLayoutManager2.x && staggeredGridLayoutManager2.L(view2) <= i2) || !view2.hasFocusable()) {
                        break;
                    }
                    size--;
                    view = view2;
                }
            } else {
                int size2 = this.a.size();
                int i4 = 0;
                while (i4 < size2) {
                    View view3 = this.a.get(i4);
                    StaggeredGridLayoutManager staggeredGridLayoutManager3 = StaggeredGridLayoutManager.this;
                    if (staggeredGridLayoutManager3.x && staggeredGridLayoutManager3.L(view3) <= i2) {
                        break;
                    }
                    StaggeredGridLayoutManager staggeredGridLayoutManager4 = StaggeredGridLayoutManager.this;
                    if ((!staggeredGridLayoutManager4.x && staggeredGridLayoutManager4.L(view3) >= i2) || !view3.hasFocusable()) {
                        break;
                    }
                    i4++;
                    view = view3;
                }
            }
            return view;
        }

        public c j(View view) {
            return (c) view.getLayoutParams();
        }

        public int k(int i2) {
            int i3 = this.f516b;
            if (i3 != Integer.MIN_VALUE) {
                return i3;
            }
            if (this.a.size() == 0) {
                return i2;
            }
            c();
            return this.f516b;
        }

        public void l() {
            int size = this.a.size();
            View viewRemove = this.a.remove(size - 1);
            c cVarJ = j(viewRemove);
            cVarJ.f515e = null;
            if (cVarJ.c() || cVarJ.b()) {
                this.f518d -= StaggeredGridLayoutManager.this.s.c(viewRemove);
            }
            if (size == 1) {
                this.f516b = Integer.MIN_VALUE;
            }
            this.f517c = Integer.MIN_VALUE;
        }

        public void m() {
            View viewRemove = this.a.remove(0);
            c cVarJ = j(viewRemove);
            cVarJ.f515e = null;
            if (this.a.size() == 0) {
                this.f517c = Integer.MIN_VALUE;
            }
            if (cVarJ.c() || cVarJ.b()) {
                this.f518d -= StaggeredGridLayoutManager.this.s.c(viewRemove);
            }
            this.f516b = Integer.MIN_VALUE;
        }

        public void n(View view) {
            c cVarJ = j(view);
            cVarJ.f515e = this;
            this.a.add(0, view);
            this.f516b = Integer.MIN_VALUE;
            if (this.a.size() == 1) {
                this.f517c = Integer.MIN_VALUE;
            }
            if (cVarJ.c() || cVarJ.b()) {
                this.f518d = StaggeredGridLayoutManager.this.s.c(view) + this.f518d;
            }
        }
    }

    public StaggeredGridLayoutManager(Context context, AttributeSet attributeSet, int i2, int i3) {
        this.q = -1;
        this.x = false;
        RecyclerView.m.d dVarM = RecyclerView.m.M(context, attributeSet, i2, i3);
        int i4 = dVarM.a;
        if (i4 != 0 && i4 != 1) {
            throw new IllegalArgumentException("invalid orientation.");
        }
        c(null);
        if (i4 != this.u) {
            this.u = i4;
            r rVar = this.s;
            this.s = this.t;
            this.t = rVar;
            F0();
        }
        int i5 = dVarM.f447b;
        c(null);
        if (i5 != this.q) {
            this.C.a();
            F0();
            this.q = i5;
            this.z = new BitSet(this.q);
            this.r = new d[this.q];
            for (int i6 = 0; i6 < this.q; i6++) {
                this.r[i6] = new d(i6);
            }
            F0();
        }
        boolean z = dVarM.f448c;
        c(null);
        SavedState savedState = this.G;
        if (savedState != null && savedState.f506k != z) {
            savedState.f506k = z;
        }
        this.x = z;
        F0();
        this.w = new n();
        this.s = r.a(this, this.u);
        this.t = r.a(this, 1 - this.u);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public int G0(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        return p1(i2, sVar, vVar);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public int H0(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        return p1(i2, sVar, vVar);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void K0(Rect rect, int i2, int i3) {
        int iG;
        int iG2;
        int iJ = J() + I();
        int iH = H() + K();
        if (this.u == 1) {
            iG2 = RecyclerView.m.g(i3, rect.height() + iH, F());
            iG = RecyclerView.m.g(i2, (this.v * this.q) + iJ, G());
        } else {
            iG = RecyclerView.m.g(i2, rect.width() + iJ, G());
            iG2 = RecyclerView.m.g(i3, (this.v * this.q) + iH, F());
        }
        this.f436b.setMeasuredDimension(iG, iG2);
    }

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

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

    public boolean R0() {
        int iA1;
        if (x() != 0 && this.D != 0 && this.f442h) {
            if (this.y) {
                iA1 = b1();
                a1();
            } else {
                iA1 = a1();
                b1();
            }
            if (iA1 == 0 && f1() != null) {
                this.C.a();
                this.f441g = true;
                F0();
                return true;
            }
        }
        return false;
    }

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

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

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void V(int i2) {
        super.V(i2);
        for (int i3 = 0; i3 < this.q; i3++) {
            d dVar = this.r[i3];
            int i4 = dVar.f516b;
            if (i4 != Integer.MIN_VALUE) {
                dVar.f516b = i4 + i2;
            }
            int i5 = dVar.f517c;
            if (i5 != Integer.MIN_VALUE) {
                dVar.f517c = i5 + i2;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r17v0, types: [androidx.recyclerview.widget.RecyclerView$m, androidx.recyclerview.widget.StaggeredGridLayoutManager] */
    /* JADX WARN: Type inference failed for: r2v22 */
    /* JADX WARN: Type inference failed for: r2v4 */
    /* JADX WARN: Type inference failed for: r2v5, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r3v18 */
    /* JADX WARN: Type inference failed for: r3v19 */
    /* JADX WARN: Type inference failed for: r3v20, types: [int] */
    /* JADX WARN: Type inference failed for: r3v24, types: [int] */
    /* JADX WARN: Type inference failed for: r3v29 */
    /* JADX WARN: Type inference failed for: r3v30 */
    /* JADX WARN: Type inference failed for: r3v31 */
    /* JADX WARN: Type inference failed for: r3v32 */
    /* JADX WARN: Type inference failed for: r3v33 */
    public final int V0(RecyclerView.s sVar, n nVar, RecyclerView.v vVar) {
        d dVar;
        ?? r2;
        int iC;
        int iC2;
        int iK;
        int iC3;
        boolean z;
        int i2;
        ?? r3;
        int i3;
        boolean z2 = false;
        this.z.set(0, this.q, true);
        int i4 = this.w.f1895i ? nVar.f1891e == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE : nVar.f1891e == 1 ? nVar.f1893g + nVar.f1888b : nVar.f1892f - nVar.f1888b;
        r1(nVar.f1891e, i4);
        int iG = this.y ? this.s.g() : this.s.k();
        boolean z3 = false;
        while (true) {
            int i5 = nVar.f1889c;
            if (!((i5 < 0 || i5 >= vVar.b()) ? z2 : true) || (!this.w.f1895i && this.z.isEmpty())) {
                break;
            }
            View view = sVar.l(nVar.f1889c, z2, Long.MAX_VALUE).f483b;
            nVar.f1889c += nVar.f1890d;
            c cVar = (c) view.getLayoutParams();
            int iA = cVar.a();
            int[] iArr = this.C.a;
            int i6 = (iArr == null || iA >= iArr.length) ? -1 : iArr[iA];
            if (i6 == -1 ? true : z2) {
                if (j1(nVar.f1891e)) {
                    i2 = -1;
                    i3 = -1;
                    r3 = this.q - 1;
                } else {
                    i2 = this.q;
                    r3 = z2;
                    i3 = 1;
                }
                d dVar2 = null;
                if (nVar.f1891e == 1) {
                    int iK2 = this.s.k();
                    int i7 = Integer.MAX_VALUE;
                    for (?? r32 = r3; r32 != i2; r32 += i3) {
                        d dVar3 = this.r[r32];
                        int iH = dVar3.h(iK2);
                        if (iH < i7) {
                            dVar2 = dVar3;
                            i7 = iH;
                        }
                    }
                } else {
                    int iG2 = this.s.g();
                    int i8 = Integer.MIN_VALUE;
                    for (?? r33 = r3; r33 != i2; r33 += i3) {
                        d dVar4 = this.r[r33];
                        int iK3 = dVar4.k(iG2);
                        if (iK3 > i8) {
                            dVar2 = dVar4;
                            i8 = iK3;
                        }
                    }
                }
                dVar = dVar2;
                LazySpanLookup lazySpanLookup = this.C;
                lazySpanLookup.b(iA);
                lazySpanLookup.a[iA] = dVar.f519e;
            } else {
                dVar = this.r[i6];
            }
            d dVar5 = dVar;
            cVar.f515e = dVar5;
            if (nVar.f1891e == 1) {
                r2 = 0;
                b(view, -1, false);
            } else {
                r2 = 0;
                b(view, 0, false);
            }
            if (this.u == 1) {
                h1(view, RecyclerView.m.y(this.v, this.m, r2, ((ViewGroup.MarginLayoutParams) cVar).width, r2), RecyclerView.m.y(this.p, this.n, H() + K(), ((ViewGroup.MarginLayoutParams) cVar).height, true), r2);
            } else {
                h1(view, RecyclerView.m.y(this.o, this.m, J() + I(), ((ViewGroup.MarginLayoutParams) cVar).width, true), RecyclerView.m.y(this.v, this.n, 0, ((ViewGroup.MarginLayoutParams) cVar).height, false), false);
            }
            if (nVar.f1891e == 1) {
                int iH2 = dVar5.h(iG);
                iC2 = iH2;
                iC = this.s.c(view) + iH2;
            } else {
                int iK4 = dVar5.k(iG);
                iC = iK4;
                iC2 = iK4 - this.s.c(view);
            }
            if (nVar.f1891e == 1) {
                cVar.f515e.a(view);
            } else {
                cVar.f515e.n(view);
            }
            if (g1() && this.u == 1) {
                iC3 = this.t.g() - (((this.q - 1) - dVar5.f519e) * this.v);
                iK = iC3 - this.t.c(view);
            } else {
                iK = this.t.k() + (dVar5.f519e * this.v);
                iC3 = this.t.c(view) + iK;
            }
            int i9 = iC3;
            int i10 = iK;
            if (this.u == 1) {
                U(view, i10, iC2, i9, iC);
            } else {
                U(view, iC2, i10, iC, i9);
            }
            t1(dVar5, this.w.f1891e, i4);
            l1(sVar, this.w);
            if (this.w.f1894h && view.hasFocusable()) {
                z = false;
                this.z.set(dVar5.f519e, false);
            } else {
                z = false;
            }
            z2 = z;
            z3 = true;
        }
        boolean z4 = z2;
        if (!z3) {
            l1(sVar, this.w);
        }
        int iK5 = this.w.f1891e == -1 ? this.s.k() - d1(this.s.k()) : c1(this.s.g()) - this.s.g();
        return iK5 > 0 ? Math.min(nVar.f1888b, iK5) : z4 ? 1 : 0;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void W(int i2) {
        super.W(i2);
        for (int i3 = 0; i3 < this.q; i3++) {
            d dVar = this.r[i3];
            int i4 = dVar.f516b;
            if (i4 != Integer.MIN_VALUE) {
                dVar.f516b = i4 + i2;
            }
            int i5 = dVar.f517c;
            if (i5 != Integer.MIN_VALUE) {
                dVar.f517c = i5 + i2;
            }
        }
    }

    public View W0(boolean z) {
        int iK = this.s.k();
        int iG = this.s.g();
        View view = null;
        for (int iX = x() - 1; iX >= 0; iX--) {
            View viewW = w(iX);
            int iE = this.s.e(viewW);
            int iB = this.s.b(viewW);
            if (iB > iK && iE < iG) {
                if (iB <= iG || !z) {
                    return viewW;
                }
                if (view == null) {
                    view = viewW;
                }
            }
        }
        return view;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void X(RecyclerView.e eVar, RecyclerView.e eVar2) {
        this.C.a();
        for (int i2 = 0; i2 < this.q; i2++) {
            this.r[i2].d();
        }
    }

    public View X0(boolean z) {
        int iK = this.s.k();
        int iG = this.s.g();
        int iX = x();
        View view = null;
        for (int i2 = 0; i2 < iX; i2++) {
            View viewW = w(i2);
            int iE = this.s.e(viewW);
            if (this.s.b(viewW) > iK && iE < iG) {
                if (iE >= iK || !z) {
                    return viewW;
                }
                if (view == null) {
                    view = viewW;
                }
            }
        }
        return view;
    }

    public final void Y0(RecyclerView.s sVar, RecyclerView.v vVar, boolean z) {
        int iG;
        int iC1 = c1(Integer.MIN_VALUE);
        if (iC1 != Integer.MIN_VALUE && (iG = this.s.g() - iC1) > 0) {
            int i2 = iG - (-p1(-iG, sVar, vVar));
            if (!z || i2 <= 0) {
                return;
            }
            this.s.p(i2);
        }
    }

    public final void Z0(RecyclerView.s sVar, RecyclerView.v vVar, boolean z) {
        int iK;
        int iD1 = d1(Integer.MAX_VALUE);
        if (iD1 != Integer.MAX_VALUE && (iK = iD1 - this.s.k()) > 0) {
            int iP1 = iK - p1(iK, sVar, vVar);
            if (!z || iP1 <= 0) {
                return;
            }
            this.s.p(-iP1);
        }
    }

    public int a1() {
        if (x() == 0) {
            return 0;
        }
        return L(w(0));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void b0(RecyclerView recyclerView, RecyclerView.s sVar) {
        a0();
        Runnable runnable = this.M;
        RecyclerView recyclerView2 = this.f436b;
        if (recyclerView2 != null) {
            recyclerView2.removeCallbacks(runnable);
        }
        for (int i2 = 0; i2 < this.q; i2++) {
            this.r[i2].d();
        }
        recyclerView.requestLayout();
    }

    public int b1() {
        int iX = x();
        if (iX == 0) {
            return 0;
        }
        return L(w(iX - 1));
    }

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

    /* JADX WARN: Removed duplicated region for block: B:45:0x0059  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x005b  */
    @Override // androidx.recyclerview.widget.RecyclerView.m
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.view.View c0(android.view.View r9, int r10, androidx.recyclerview.widget.RecyclerView.s r11, androidx.recyclerview.widget.RecyclerView.v r12) {
        /*
            Method dump skipped, instruction units count: 331
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.c0(android.view.View, int, androidx.recyclerview.widget.RecyclerView$s, androidx.recyclerview.widget.RecyclerView$v):android.view.View");
    }

    public final int c1(int i2) {
        int iH = this.r[0].h(i2);
        for (int i3 = 1; i3 < this.q; i3++) {
            int iH2 = this.r[i3].h(i2);
            if (iH2 > iH) {
                iH = iH2;
            }
        }
        return iH;
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void d0(AccessibilityEvent accessibilityEvent) {
        RecyclerView.s sVar = this.f436b.n;
        e0(accessibilityEvent);
        if (x() > 0) {
            View viewX0 = X0(false);
            View viewW0 = W0(false);
            if (viewX0 == null || viewW0 == null) {
                return;
            }
            int iL = L(viewX0);
            int iL2 = L(viewW0);
            if (iL < iL2) {
                accessibilityEvent.setFromIndex(iL);
                accessibilityEvent.setToIndex(iL2);
            } else {
                accessibilityEvent.setFromIndex(iL2);
                accessibilityEvent.setToIndex(iL);
            }
        }
    }

    public final int d1(int i2) {
        int iK = this.r[0].k(i2);
        for (int i3 = 1; i3 < this.q; i3++) {
            int iK2 = this.r[i3].k(i2);
            if (iK2 < iK) {
                iK = iK2;
            }
        }
        return iK;
    }

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

    /* JADX WARN: Removed duplicated region for block: B:15:0x0025  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x003c  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0043 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0044  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void e1(int r7, int r8, int r9) {
        /*
            r6 = this;
            boolean r0 = r6.y
            if (r0 == 0) goto L9
            int r0 = r6.b1()
            goto Ld
        L9:
            int r0 = r6.a1()
        Ld:
            r1 = 8
            if (r9 != r1) goto L1a
            if (r7 >= r8) goto L16
            int r2 = r8 + 1
            goto L1c
        L16:
            int r2 = r7 + 1
            r3 = r8
            goto L1d
        L1a:
            int r2 = r7 + r8
        L1c:
            r3 = r7
        L1d:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup r4 = r6.C
            r4.d(r3)
            r4 = 1
            if (r9 == r4) goto L3c
            r5 = 2
            if (r9 == r5) goto L36
            if (r9 == r1) goto L2b
            goto L41
        L2b:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup r9 = r6.C
            r9.f(r7, r4)
            androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup r7 = r6.C
            r7.e(r8, r4)
            goto L41
        L36:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup r9 = r6.C
            r9.f(r7, r8)
            goto L41
        L3c:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup r9 = r6.C
            r9.e(r7, r8)
        L41:
            if (r2 > r0) goto L44
            return
        L44:
            boolean r7 = r6.y
            if (r7 == 0) goto L4d
            int r7 = r6.a1()
            goto L51
        L4d:
            int r7 = r6.b1()
        L51:
            if (r3 > r7) goto L56
            r6.F0()
        L56:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.e1(int, int, int):void");
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public boolean f(RecyclerView.n nVar) {
        return nVar instanceof c;
    }

    /* JADX WARN: Removed duplicated region for block: B:51:0x00d0  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00d2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.view.View f1() {
        /*
            Method dump skipped, instruction units count: 246
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.f1():android.view.View");
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void h(int i2, int i3, RecyclerView.v vVar, RecyclerView.m.c cVar) {
        int iH;
        int iK;
        if (this.u != 0) {
            i2 = i3;
        }
        if (x() == 0 || i2 == 0) {
            return;
        }
        k1(i2, vVar);
        int[] iArr = this.L;
        if (iArr == null || iArr.length < this.q) {
            this.L = new int[this.q];
        }
        int i4 = 0;
        for (int i5 = 0; i5 < this.q; i5++) {
            n nVar = this.w;
            if (nVar.f1890d == -1) {
                iH = nVar.f1892f;
                iK = this.r[i5].k(iH);
            } else {
                iH = this.r[i5].h(nVar.f1893g);
                iK = this.w.f1893g;
            }
            int i6 = iH - iK;
            if (i6 >= 0) {
                this.L[i4] = i6;
                i4++;
            }
        }
        Arrays.sort(this.L, 0, i4);
        for (int i7 = 0; i7 < i4; i7++) {
            int i8 = this.w.f1889c;
            if (!(i8 >= 0 && i8 < vVar.b())) {
                return;
            }
            ((m.b) cVar).a(this.w.f1889c, this.L[i7]);
            n nVar2 = this.w;
            nVar2.f1889c += nVar2.f1890d;
        }
    }

    public final void h1(View view, int i2, int i3, boolean z) {
        Rect rect = this.I;
        RecyclerView recyclerView = this.f436b;
        if (recyclerView == null) {
            rect.set(0, 0, 0, 0);
        } else {
            rect.set(recyclerView.K(view));
        }
        c cVar = (c) view.getLayoutParams();
        int i4 = ((ViewGroup.MarginLayoutParams) cVar).leftMargin;
        Rect rect2 = this.I;
        int iU1 = u1(i2, i4 + rect2.left, ((ViewGroup.MarginLayoutParams) cVar).rightMargin + rect2.right);
        int i5 = ((ViewGroup.MarginLayoutParams) cVar).topMargin;
        Rect rect3 = this.I;
        int iU12 = u1(i3, i5 + rect3.top, ((ViewGroup.MarginLayoutParams) cVar).bottomMargin + rect3.bottom);
        if (z ? P0(view, iU1, iU12, cVar) : N0(view, iU1, iU12, cVar)) {
            view.measure(iU1, iU12);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:108:0x019d  */
    /* JADX WARN: Removed duplicated region for block: B:109:0x019f  */
    /* JADX WARN: Removed duplicated region for block: B:124:0x01d2  */
    /* JADX WARN: Removed duplicated region for block: B:260:0x042e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void i1(androidx.recyclerview.widget.RecyclerView.s r12, androidx.recyclerview.widget.RecyclerView.v r13, boolean r14) {
        /*
            Method dump skipped, instruction units count: 1101
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.i1(androidx.recyclerview.widget.RecyclerView$s, androidx.recyclerview.widget.RecyclerView$v, boolean):void");
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void j0(RecyclerView recyclerView, int i2, int i3) {
        e1(i2, i3, 1);
    }

    public final boolean j1(int i2) {
        if (this.u == 0) {
            return (i2 == -1) != this.y;
        }
        return ((i2 == -1) == this.y) == g1();
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void k0(RecyclerView recyclerView) {
        this.C.a();
        F0();
    }

    public void k1(int i2, RecyclerView.v vVar) {
        int i3;
        int iA1;
        if (i2 > 0) {
            iA1 = b1();
            i3 = 1;
        } else {
            i3 = -1;
            iA1 = a1();
        }
        this.w.a = true;
        s1(iA1, vVar);
        q1(i3);
        n nVar = this.w;
        nVar.f1889c = iA1 + nVar.f1890d;
        nVar.f1888b = Math.abs(i2);
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void l0(RecyclerView recyclerView, int i2, int i3, int i4) {
        e1(i2, i3, 8);
    }

    public final void l1(RecyclerView.s sVar, n nVar) {
        if (!nVar.a || nVar.f1895i) {
            return;
        }
        if (nVar.f1888b == 0) {
            if (nVar.f1891e == -1) {
                m1(sVar, nVar.f1893g);
                return;
            } else {
                n1(sVar, nVar.f1892f);
                return;
            }
        }
        int i2 = 1;
        if (nVar.f1891e == -1) {
            int i3 = nVar.f1892f;
            int iK = this.r[0].k(i3);
            while (i2 < this.q) {
                int iK2 = this.r[i2].k(i3);
                if (iK2 > iK) {
                    iK = iK2;
                }
                i2++;
            }
            int i4 = i3 - iK;
            m1(sVar, i4 < 0 ? nVar.f1893g : nVar.f1893g - Math.min(i4, nVar.f1888b));
            return;
        }
        int i5 = nVar.f1893g;
        int iH = this.r[0].h(i5);
        while (i2 < this.q) {
            int iH2 = this.r[i2].h(i5);
            if (iH2 < iH) {
                iH = iH2;
            }
            i2++;
        }
        int i6 = iH - nVar.f1893g;
        n1(sVar, i6 < 0 ? nVar.f1892f : Math.min(i6, nVar.f1888b) + nVar.f1892f);
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void m0(RecyclerView recyclerView, int i2, int i3) {
        e1(i2, i3, 2);
    }

    public final void m1(RecyclerView.s sVar, int i2) {
        for (int iX = x() - 1; iX >= 0; iX--) {
            View viewW = w(iX);
            if (this.s.e(viewW) < i2 || this.s.o(viewW) < i2) {
                return;
            }
            c cVar = (c) viewW.getLayoutParams();
            Objects.requireNonNull(cVar);
            if (cVar.f515e.a.size() == 1) {
                return;
            }
            cVar.f515e.l();
            B0(viewW, sVar);
        }
    }

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

    public final void n1(RecyclerView.s sVar, int i2) {
        while (x() > 0) {
            View viewW = w(0);
            if (this.s.b(viewW) > i2 || this.s.n(viewW) > i2) {
                return;
            }
            c cVar = (c) viewW.getLayoutParams();
            Objects.requireNonNull(cVar);
            if (cVar.f515e.a.size() == 1) {
                return;
            }
            cVar.f515e.m();
            B0(viewW, sVar);
        }
    }

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

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void o0(RecyclerView recyclerView, int i2, int i3, Object obj) {
        e1(i2, i3, 4);
    }

    public final void o1() {
        if (this.u == 1 || !g1()) {
            this.y = this.x;
        } else {
            this.y = !this.x;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void p0(RecyclerView.s sVar, RecyclerView.v vVar) {
        i1(sVar, vVar, true);
    }

    public int p1(int i2, RecyclerView.s sVar, RecyclerView.v vVar) {
        if (x() == 0 || i2 == 0) {
            return 0;
        }
        k1(i2, vVar);
        int iV0 = V0(sVar, this.w, vVar);
        if (this.w.f1888b >= iV0) {
            i2 = i2 < 0 ? -iV0 : iV0;
        }
        this.s.p(-i2);
        this.E = this.y;
        n nVar = this.w;
        nVar.f1888b = 0;
        l1(sVar, nVar);
        return i2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void q0(RecyclerView.v vVar) {
        this.A = -1;
        this.B = Integer.MIN_VALUE;
        this.G = null;
        this.J.b();
    }

    public final void q1(int i2) {
        n nVar = this.w;
        nVar.f1891e = i2;
        nVar.f1890d = this.y != (i2 == -1) ? -1 : 1;
    }

    public final void r1(int i2, int i3) {
        for (int i4 = 0; i4 < this.q; i4++) {
            if (!this.r[i4].a.isEmpty()) {
                t1(this.r[i4], i2, i3);
            }
        }
    }

    public final void s1(int i2, RecyclerView.v vVar) {
        n nVar = this.w;
        boolean z = false;
        nVar.f1888b = 0;
        nVar.f1889c = i2;
        RecyclerView recyclerView = this.f436b;
        if (recyclerView != null && recyclerView.s) {
            nVar.f1892f = this.s.k() - 0;
            this.w.f1893g = this.s.g() + 0;
        } else {
            nVar.f1893g = this.s.f() + 0;
            this.w.f1892f = 0;
        }
        n nVar2 = this.w;
        nVar2.f1894h = false;
        nVar2.a = true;
        if (this.s.i() == 0 && this.s.f() == 0) {
            z = true;
        }
        nVar2.f1895i = z;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public RecyclerView.n t() {
        return this.u == 0 ? new c(-2, -1) : new c(-1, -2);
    }

    public final void t1(d dVar, int i2, int i3) {
        int i4 = dVar.f518d;
        if (i2 == -1) {
            int i5 = dVar.f516b;
            if (i5 == Integer.MIN_VALUE) {
                dVar.c();
                i5 = dVar.f516b;
            }
            if (i5 + i4 <= i3) {
                this.z.set(dVar.f519e, false);
                return;
            }
            return;
        }
        int i6 = dVar.f517c;
        if (i6 == Integer.MIN_VALUE) {
            dVar.b();
            i6 = dVar.f517c;
        }
        if (i6 - i4 >= i3) {
            this.z.set(dVar.f519e, false);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public RecyclerView.n u(Context context, AttributeSet attributeSet) {
        return new c(context, attributeSet);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void u0(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            this.G = savedState;
            if (this.A != -1) {
                savedState.f502g = null;
                savedState.f501f = 0;
                savedState.f499b = -1;
                savedState.f500e = -1;
                savedState.f502g = null;
                savedState.f501f = 0;
                savedState.f503h = 0;
                savedState.f504i = null;
                savedState.f505j = null;
            }
            F0();
        }
    }

    public final int u1(int i2, int i3, int i4) {
        if (i3 == 0 && i4 == 0) {
            return i2;
        }
        int mode = View.MeasureSpec.getMode(i2);
        return (mode == Integer.MIN_VALUE || mode == 1073741824) ? View.MeasureSpec.makeMeasureSpec(Math.max(0, (View.MeasureSpec.getSize(i2) - i3) - i4), mode) : i2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public RecyclerView.n v(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof ViewGroup.MarginLayoutParams ? new c((ViewGroup.MarginLayoutParams) layoutParams) : new c(layoutParams);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public Parcelable v0() {
        int iK;
        int iK2;
        int[] iArr;
        SavedState savedState = this.G;
        if (savedState != null) {
            return new SavedState(savedState);
        }
        SavedState savedState2 = new SavedState();
        savedState2.f506k = this.x;
        savedState2.f507l = this.E;
        savedState2.m = this.F;
        LazySpanLookup lazySpanLookup = this.C;
        if (lazySpanLookup == null || (iArr = lazySpanLookup.a) == null) {
            savedState2.f503h = 0;
        } else {
            savedState2.f504i = iArr;
            savedState2.f503h = iArr.length;
            savedState2.f505j = lazySpanLookup.f494b;
        }
        if (x() > 0) {
            savedState2.f499b = this.E ? b1() : a1();
            View viewW0 = this.y ? W0(true) : X0(true);
            savedState2.f500e = viewW0 != null ? L(viewW0) : -1;
            int i2 = this.q;
            savedState2.f501f = i2;
            savedState2.f502g = new int[i2];
            for (int i3 = 0; i3 < this.q; i3++) {
                if (this.E) {
                    iK = this.r[i3].h(Integer.MIN_VALUE);
                    if (iK != Integer.MIN_VALUE) {
                        iK2 = this.s.g();
                        iK -= iK2;
                    }
                } else {
                    iK = this.r[i3].k(Integer.MIN_VALUE);
                    if (iK != Integer.MIN_VALUE) {
                        iK2 = this.s.k();
                        iK -= iK2;
                    }
                }
                savedState2.f502g[i3] = iK;
            }
        } else {
            savedState2.f499b = -1;
            savedState2.f500e = -1;
            savedState2.f501f = 0;
        }
        return savedState2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.m
    public void w0(int i2) {
        if (i2 == 0) {
            R0();
        }
    }

    public static class LazySpanLookup {
        public int[] a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public List<FullSpanItem> f494b;

        public void a() {
            int[] iArr = this.a;
            if (iArr != null) {
                Arrays.fill(iArr, -1);
            }
            this.f494b = null;
        }

        public void b(int i2) {
            int[] iArr = this.a;
            if (iArr == null) {
                int[] iArr2 = new int[Math.max(i2, 10) + 1];
                this.a = iArr2;
                Arrays.fill(iArr2, -1);
            } else if (i2 >= iArr.length) {
                int length = iArr.length;
                while (length <= i2) {
                    length *= 2;
                }
                int[] iArr3 = new int[length];
                this.a = iArr3;
                System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
                int[] iArr4 = this.a;
                Arrays.fill(iArr4, iArr.length, iArr4.length, -1);
            }
        }

        public FullSpanItem c(int i2) {
            List<FullSpanItem> list = this.f494b;
            if (list == null) {
                return null;
            }
            for (int size = list.size() - 1; size >= 0; size--) {
                FullSpanItem fullSpanItem = this.f494b.get(size);
                if (fullSpanItem.f495b == i2) {
                    return fullSpanItem;
                }
            }
            return null;
        }

        /* JADX WARN: Removed duplicated region for block: B:10:0x000e  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public int d(int r5) {
            /*
                r4 = this;
                int[] r0 = r4.a
                r1 = -1
                if (r0 != 0) goto L6
                return r1
            L6:
                int r0 = r0.length
                if (r5 < r0) goto La
                return r1
            La:
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r0 = r4.f494b
                if (r0 != 0) goto L10
            Le:
                r0 = r1
                goto L46
            L10:
                androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem r0 = r4.c(r5)
                if (r0 == 0) goto L1b
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r2 = r4.f494b
                r2.remove(r0)
            L1b:
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r0 = r4.f494b
                int r0 = r0.size()
                r2 = 0
            L22:
                if (r2 >= r0) goto L34
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r3 = r4.f494b
                java.lang.Object r3 = r3.get(r2)
                androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem r3 = (androidx.recyclerview.widget.StaggeredGridLayoutManager.LazySpanLookup.FullSpanItem) r3
                int r3 = r3.f495b
                if (r3 < r5) goto L31
                goto L35
            L31:
                int r2 = r2 + 1
                goto L22
            L34:
                r2 = r1
            L35:
                if (r2 == r1) goto Le
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r0 = r4.f494b
                java.lang.Object r0 = r0.get(r2)
                androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem r0 = (androidx.recyclerview.widget.StaggeredGridLayoutManager.LazySpanLookup.FullSpanItem) r0
                java.util.List<androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup$FullSpanItem> r3 = r4.f494b
                r3.remove(r2)
                int r0 = r0.f495b
            L46:
                if (r0 != r1) goto L52
                int[] r0 = r4.a
                int r2 = r0.length
                java.util.Arrays.fill(r0, r5, r2, r1)
                int[] r5 = r4.a
                int r5 = r5.length
                return r5
            L52:
                int r0 = r0 + 1
                int[] r2 = r4.a
                int r2 = r2.length
                int r0 = java.lang.Math.min(r0, r2)
                int[] r2 = r4.a
                java.util.Arrays.fill(r2, r5, r0, r1)
                return r0
            */
            throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.LazySpanLookup.d(int):int");
        }

        public void e(int i2, int i3) {
            int[] iArr = this.a;
            if (iArr == null || i2 >= iArr.length) {
                return;
            }
            int i4 = i2 + i3;
            b(i4);
            int[] iArr2 = this.a;
            System.arraycopy(iArr2, i2, iArr2, i4, (iArr2.length - i2) - i3);
            Arrays.fill(this.a, i2, i4, -1);
            List<FullSpanItem> list = this.f494b;
            if (list == null) {
                return;
            }
            for (int size = list.size() - 1; size >= 0; size--) {
                FullSpanItem fullSpanItem = this.f494b.get(size);
                int i5 = fullSpanItem.f495b;
                if (i5 >= i2) {
                    fullSpanItem.f495b = i5 + i3;
                }
            }
        }

        public void f(int i2, int i3) {
            int[] iArr = this.a;
            if (iArr == null || i2 >= iArr.length) {
                return;
            }
            int i4 = i2 + i3;
            b(i4);
            int[] iArr2 = this.a;
            System.arraycopy(iArr2, i4, iArr2, i2, (iArr2.length - i2) - i3);
            int[] iArr3 = this.a;
            Arrays.fill(iArr3, iArr3.length - i3, iArr3.length, -1);
            List<FullSpanItem> list = this.f494b;
            if (list == null) {
                return;
            }
            for (int size = list.size() - 1; size >= 0; size--) {
                FullSpanItem fullSpanItem = this.f494b.get(size);
                int i5 = fullSpanItem.f495b;
                if (i5 >= i2) {
                    if (i5 < i4) {
                        this.f494b.remove(size);
                    } else {
                        fullSpanItem.f495b = i5 - i3;
                    }
                }
            }
        }

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

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

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

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

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

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

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

            public FullSpanItem(Parcel parcel) {
                this.f495b = parcel.readInt();
                this.f496e = parcel.readInt();
                this.f498g = parcel.readInt() == 1;
                int i2 = parcel.readInt();
                if (i2 > 0) {
                    int[] iArr = new int[i2];
                    this.f497f = iArr;
                    parcel.readIntArray(iArr);
                }
            }

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

            public String toString() {
                StringBuilder sbB = d.b.a.a.a.B("FullSpanItem{mPosition=");
                sbB.append(this.f495b);
                sbB.append(", mGapDir=");
                sbB.append(this.f496e);
                sbB.append(", mHasUnwantedGapAfter=");
                sbB.append(this.f498g);
                sbB.append(", mGapPerSpan=");
                sbB.append(Arrays.toString(this.f497f));
                sbB.append('}');
                return sbB.toString();
            }

            @Override // android.os.Parcelable
            public void writeToParcel(Parcel parcel, int i2) {
                parcel.writeInt(this.f495b);
                parcel.writeInt(this.f496e);
                parcel.writeInt(this.f498g ? 1 : 0);
                int[] iArr = this.f497f;
                if (iArr == null || iArr.length <= 0) {
                    parcel.writeInt(0);
                } else {
                    parcel.writeInt(iArr.length);
                    parcel.writeIntArray(this.f497f);
                }
            }

            public FullSpanItem() {
            }
        }
    }
}
