package androidx.recyclerview.widget;

import X.AnonymousClass0E0;
import X.AnonymousClass0E1;
import X.AnonymousClass0ED;
import X.AnonymousClass0EE;
import X.AnonymousClass0EF;
import X.AnonymousClass0EG;
import X.AnonymousClass0EL;
import X.AnonymousClass0EO;
import X.AnonymousClass0EP;
import X.AnonymousClass0EQ;
import X.AnonymousClass0EX;
import X.AnonymousClass0FU;
import X.C03650Dz;
import X.C03940Fc;
import X.C28851Cx;
import android.content.Context;
import android.graphics.PointF;
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 com.bytedance.covode.number.Covode;
import java.util.List;

public class LinearLayoutManager extends AnonymousClass0EF implements AnonymousClass0EO, AnonymousClass0FU {
    public AnonymousClass0E1 LIZ;
    public boolean LIZIZ;
    public final AnonymousClass0E0 LIZJ;
    public int[] LIZLLL;
    public int LJIIIZ;
    public C03940Fc LJIIJ;
    public boolean LJIIJJI;
    public boolean LJIIL;
    public boolean LJIILIIL;
    public boolean LJIILJJIL;
    public int LJIILL;
    public int LJIILLIIL;
    public boolean LJIIZILJ;
    public SavedState LJIJ;
    public final C03650Dz LJIJI;
    public int LJIJJ;

    static {
        Covode.recordClassIndex(1477);
    }

    public void LIZ(AnonymousClass0EL r1, AnonymousClass0EQ r2, C03650Dz r3, int i) {
    }

    public final boolean Q_() {
        return true;
    }

    public static class SavedState implements Parcelable {
        public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
            static {
                Covode.recordClassIndex(1479);
            }

            public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
                return new SavedState[i];
            }

            public final /* synthetic */ Object createFromParcel(Parcel parcel) {
                return new SavedState(parcel);
            }
        };
        public int LIZ;
        public int LIZIZ;
        public boolean LIZJ;

        public int describeContents() {
            return 0;
        }

        public SavedState() {
        }

        public final boolean LIZ() {
            if (this.LIZ >= 0) {
                return true;
            }
            return false;
        }

        static {
            Covode.recordClassIndex(1478);
        }

        public SavedState(SavedState savedState) {
            this.LIZ = savedState.LIZ;
            this.LIZIZ = savedState.LIZIZ;
            this.LIZJ = savedState.LIZJ;
        }

        public SavedState(Parcel parcel) {
            this.LIZ = parcel.readInt();
            this.LIZIZ = parcel.readInt();
            this.LIZJ = parcel.readInt() != 1 ? false : true;
        }

        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeInt(this.LIZ);
            parcel.writeInt(this.LIZIZ);
            parcel.writeInt(this.LIZJ ? 1 : 0);
        }
    }

    public void LIZ(RecyclerView recyclerView, AnonymousClass0EL r3) {
        super.LIZ(recyclerView, r3);
        if (this.LJIIZILJ) {
            LIZJ(r3);
            r3.LIZ();
        }
    }

    public final void LIZ(AccessibilityEvent accessibilityEvent) {
        super.LIZ(accessibilityEvent);
        if (LJIJI() > 0) {
            accessibilityEvent.setFromIndex(LJIIJ());
            accessibilityEvent.setToIndex(LJIIL());
        }
    }

    public void LIZ(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            this.LJIJ = savedState;
            if (this.LJIILL != -1) {
                savedState.LIZ = -1;
            }
            LJIILJJIL();
        }
    }

    public void LIZ(boolean z) {
        LIZ((String) null);
        if (this.LJIILIIL != z) {
            this.LJIILIIL = z;
            LJIILJJIL();
        }
    }

    public void LIZ(RecyclerView recyclerView, AnonymousClass0EQ r4, int i) {
        C28851Cx r1 = new C28851Cx(recyclerView.getContext());
        r1.LJI = i;
        LIZ((AnonymousClass0EP) r1);
    }

    public void LIZ(AnonymousClass0EQ r2) {
        super.LIZ(r2);
        this.LJIJ = null;
        this.LJIILL = -1;
        this.LJIILLIIL = Integer.MIN_VALUE;
        this.LJIJI.LIZ();
    }

    public void LIZ(int i, int i2) {
        this.LJIILL = i;
        this.LJIILLIIL = i2;
        SavedState savedState = this.LJIJ;
        if (savedState != null) {
            savedState.LIZ = -1;
        }
        LJIILJJIL();
    }

    public void LIZ(AnonymousClass0EQ r4, AnonymousClass0E1 r5, AnonymousClass0ED r6) {
        int i = r5.LIZLLL;
        if (i >= 0 && i < r4.LIZ()) {
            r6.LIZ(i, Math.max(0, r5.LJI));
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:5:0x0014, code lost:
        if (r1 != false) goto L_0x0016;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(int r6, X.AnonymousClass0ED r7) {
        /*
            r5 = this;
            androidx.recyclerview.widget.LinearLayoutManager$SavedState r0 = r5.LJIJ
            r4 = -1
            r3 = 0
            if (r0 == 0) goto L_0x0026
            boolean r0 = r0.LIZ()
            if (r0 == 0) goto L_0x0026
            androidx.recyclerview.widget.LinearLayoutManager$SavedState r0 = r5.LJIJ
            boolean r1 = r0.LIZJ
            androidx.recyclerview.widget.LinearLayoutManager$SavedState r0 = r5.LJIJ
            int r2 = r0.LIZ
        L_0x0014:
            if (r1 == 0) goto L_0x0035
        L_0x0016:
            r1 = 0
        L_0x0017:
            int r0 = r5.LJIJJ
            if (r1 >= r0) goto L_0x0037
            if (r2 < 0) goto L_0x0037
            if (r2 >= r6) goto L_0x0037
            r7.LIZ(r2, r3)
            int r2 = r2 + r4
            int r1 = r1 + 1
            goto L_0x0017
        L_0x0026:
            r5.LJJIIZI()
            boolean r1 = r5.LJIIL
            int r2 = r5.LJIILL
            if (r2 != r4) goto L_0x0014
            if (r1 == 0) goto L_0x0034
            int r2 = r6 + -1
            goto L_0x0016
        L_0x0034:
            r2 = 0
        L_0x0035:
            r4 = 1
            goto L_0x0016
        L_0x0037:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.LinearLayoutManager.LIZ(int, X.0ED):void");
    }

    public final void LIZ(int i, int i2, AnonymousClass0EQ r6, AnonymousClass0ED r7) {
        if (this.LJIIIZ != 0) {
            i = i2;
        }
        if (LJIJI() != 0 && i != 0) {
            LJIIIIZZ();
            LIZ(i > 0 ? 1 : -1, Math.abs(i), true, r6);
            LIZ(r6, this.LIZ, r7);
        }
    }

    public void LIZ(String str) {
        if (this.LJIJ == null) {
            super.LIZ(str);
        }
    }

    public void LIZ(AnonymousClass0EL r12, AnonymousClass0EQ r13, AnonymousClass0E1 r14, AnonymousClass0E0 r15) {
        int LJIJJLI;
        int LJFF;
        int i;
        int i2;
        View LIZ2 = r14.LIZ(r12);
        if (LIZ2 == null) {
            r15.LIZIZ = true;
            return;
        }
        AnonymousClass0EG r2 = (AnonymousClass0EG) LIZ2.getLayoutParams();
        boolean z = false;
        if (r14.LJIIJJI == null) {
            if (this.LJIIL == (r14.LJFF == -1)) {
                LJ(LIZ2);
            } else {
                LIZ(LIZ2, 0);
            }
        } else {
            boolean z2 = this.LJIIL;
            if (r14.LJFF == -1) {
                z = true;
            }
            if (z2 == z) {
                LIZJ(LIZ2);
            } else {
                LIZLLL(LIZ2);
            }
        }
        LJIILIIL(LIZ2);
        r15.LIZ = this.LJIIJ.LJ(LIZ2);
        if (this.LJIIIZ == 1) {
            if (LJII()) {
                i2 = this.LJJIJIL - LJIL();
                i = i2 - this.LJIIJ.LJFF(LIZ2);
            } else {
                i = LJIJJ();
                i2 = this.LJIIJ.LJFF(LIZ2) + i;
            }
            if (r14.LJFF == -1) {
                LJFF = r14.LIZIZ;
                LJIJJLI = r14.LIZIZ - r15.LIZ;
            } else {
                LJIJJLI = r14.LIZIZ;
                LJFF = r14.LIZIZ + r15.LIZ;
            }
        } else {
            LJIJJLI = LJIJJLI();
            LJFF = this.LJIIJ.LJFF(LIZ2) + LJIJJLI;
            if (r14.LJFF == -1) {
                i2 = r14.LIZIZ;
                i = r14.LIZIZ - r15.LIZ;
            } else {
                i = r14.LIZIZ;
                i2 = r14.LIZIZ + r15.LIZ;
            }
        }
        LIZIZ(LIZ2, i, LJIJJLI, i2, LJFF);
        if (r2.LIZJ.isRemoved() || r2.LIZJ.isUpdated()) {
            r15.LIZJ = true;
        }
        r15.LIZLLL = LIZ2.hasFocusable();
    }

    public View LIZ(AnonymousClass0EL r16, AnonymousClass0EQ r17, boolean z, boolean z2) {
        int i;
        int i2;
        LJIIIIZZ();
        int LJIJI2 = LJIJI();
        int i3 = -1;
        if (z2) {
            i = LJIJI() - 1;
            i2 = -1;
        } else {
            i3 = LJIJI2;
            i = 0;
            i2 = 1;
        }
        int LIZ2 = r17.LIZ();
        int LIZIZ2 = this.LJIIJ.LIZIZ();
        int LIZJ2 = this.LJIIJ.LIZJ();
        View view = null;
        View view2 = null;
        View view3 = null;
        while (i != i3) {
            View LJI = LJI(i);
            int LJI2 = LJI(LJI);
            int LIZ3 = this.LJIIJ.LIZ(LJI);
            int LIZIZ3 = this.LJIIJ.LIZIZ(LJI);
            if (LJI2 >= 0 && LJI2 < LIZ2) {
                if (!((AnonymousClass0EG) LJI.getLayoutParams()).LIZJ.isRemoved()) {
                    boolean z3 = LIZIZ3 <= LIZIZ2 && LIZ3 < LIZIZ2;
                    boolean z4 = LIZ3 >= LIZJ2 && LIZIZ3 > LIZJ2;
                    if (!z3 && !z4) {
                        return LJI;
                    }
                    if (z) {
                        if (!z4) {
                            if (view != null) {
                            }
                            view = LJI;
                        }
                    } else if (!z3) {
                        if (view != null) {
                        }
                        view = LJI;
                    }
                    view2 = LJI;
                } else if (view3 == null) {
                    view3 = LJI;
                }
            }
            i += i2;
        }
        if (view != null) {
            return view;
        }
        return view2 != null ? view2 : view3;
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x004a  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0068 A[RETURN] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public android.view.View LIZ(android.view.View r6, int r7, X.AnonymousClass0EL r8, X.AnonymousClass0EQ r9) {
        /*
            r5 = this;
            r5.LJJIIZI()
            int r0 = r5.LJIJI()
            r4 = 0
            if (r0 != 0) goto L_0x000b
            return r4
        L_0x000b:
            int r3 = r5.LJFF((int) r7)
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            if (r3 != r2) goto L_0x0014
            return r4
        L_0x0014:
            r5.LJIIIIZZ()
            r1 = 1051372203(0x3eaaaaab, float:0.33333334)
            X.0Fc r0 = r5.LJIIJ
            int r0 = r0.LJ()
            float r0 = (float) r0
            float r0 = r0 * r1
            int r0 = (int) r0
            r1 = 0
            r5.LIZ((int) r3, (int) r0, (boolean) r1, (X.AnonymousClass0EQ) r9)
            X.0E1 r0 = r5.LIZ
            r0.LJI = r2
            X.0E1 r0 = r5.LIZ
            r0.LIZ = r1
            X.0E1 r1 = r5.LIZ
            r0 = 1
            r5.LIZ((X.AnonymousClass0EL) r8, (X.AnonymousClass0E1) r1, (X.AnonymousClass0EQ) r9, (boolean) r0)
            r1 = -1
            if (r3 != r1) goto L_0x0052
            boolean r0 = r5.LJIIL
            if (r0 == 0) goto L_0x004d
            android.view.View r2 = r5.LJJIJL()
        L_0x0040:
            android.view.View r1 = r5.LJJIJIIJI()
        L_0x0044:
            boolean r0 = r1.hasFocusable()
            if (r0 == 0) goto L_0x0068
            if (r2 != 0) goto L_0x0067
            return r4
        L_0x004d:
            android.view.View r2 = r5.LJJIJIL()
            goto L_0x0040
        L_0x0052:
            boolean r0 = r5.LJIIL
            if (r0 == 0) goto L_0x005d
            android.view.View r2 = r5.LJJIJIL()
        L_0x005a:
            if (r3 != r1) goto L_0x0062
            goto L_0x0040
        L_0x005d:
            android.view.View r2 = r5.LJJIJL()
            goto L_0x005a
        L_0x0062:
            android.view.View r1 = r5.LJJIJIIJIL()
            goto L_0x0044
        L_0x0067:
            return r1
        L_0x0068:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.LinearLayoutManager.LIZ(android.view.View, int, X.0EL, X.0EQ):android.view.View");
    }

    public final void LIZ(View view, View view2) {
        LIZ("Cannot drop a view during a scroll or layout calculation");
        LJIIIIZZ();
        LJJIIZI();
        int LJI = LJI(view);
        int LJI2 = LJI(view2);
        char c = LJI < LJI2 ? (char) 1 : 65535;
        if (this.LJIIL) {
            if (c == 1) {
                LIZ(LJI2, this.LJIIJ.LIZJ() - (this.LJIIJ.LIZ(view2) + this.LJIIJ.LJ(view)));
            } else {
                LIZ(LJI2, this.LJIIJ.LIZJ() - this.LJIIJ.LIZIZ(view2));
            }
        } else if (c == 65535) {
            LIZ(LJI2, this.LJIIJ.LIZ(view2));
        } else {
            LIZ(LJI2, this.LJIIJ.LIZIZ(view2) - this.LJIIJ.LJ(view));
        }
    }

    public LinearLayoutManager() {
        this(1, false);
    }

    private View LJJIJIL() {
        return LJI(0, LJIJI());
    }

    private View LJJIJL() {
        return LJI(LJIJI() - 1, -1);
    }

    public boolean LJFF() {
        if (this.LJIIIZ == 0) {
            return true;
        }
        return false;
    }

    public boolean LJI() {
        if (this.LJIIIZ == 1) {
            return true;
        }
        return false;
    }

    public final boolean LJII() {
        if (this.LJIL.getLayoutDirection() == 1) {
            return true;
        }
        return false;
    }

    public final void LJIIIIZZ() {
        if (this.LIZ == null) {
            this.LIZ = new AnonymousClass0E1();
        }
    }

    public boolean R_() {
        if (this.LJIJ == null && this.LIZIZ == this.LJIILIIL) {
            return true;
        }
        return false;
    }

    private void LJJIIZI() {
        boolean z = true;
        if (this.LJIIIZ == 1 || !LJII()) {
            z = this.LJIIJJI;
        } else if (this.LJIIJJI) {
            z = false;
        }
        this.LJIIL = z;
    }

    private boolean LJJIJ() {
        if (this.LJIIJ.LJI() == 0 && this.LJIIJ.LIZLLL() == 0) {
            return true;
        }
        return false;
    }

    private View LJJIJIIJI() {
        int i;
        if (this.LJIIL) {
            i = LJIJI() - 1;
        } else {
            i = 0;
        }
        return LJI(i);
    }

    private View LJJIJIIJIL() {
        int LJIJI2;
        if (this.LJIIL) {
            LJIJI2 = 0;
        } else {
            LJIJI2 = LJIJI() - 1;
        }
        return LJI(LJIJI2);
    }

    public final int LJIIJ() {
        View LIZ2 = LIZ(0, LJIJI(), false, true);
        if (LIZ2 == null) {
            return -1;
        }
        return LJI(LIZ2);
    }

    public final int LJIIJJI() {
        View LIZ2 = LIZ(0, LJIJI(), true, false);
        if (LIZ2 == null) {
            return -1;
        }
        return LJI(LIZ2);
    }

    public final int LJIIL() {
        View LIZ2 = LIZ(LJIJI() - 1, -1, false, true);
        if (LIZ2 == null) {
            return -1;
        }
        return LJI(LIZ2);
    }

    public final int LJIILIIL() {
        View LIZ2 = LIZ(LJIJI() - 1, -1, true, false);
        if (LIZ2 == null) {
            return -1;
        }
        return LJI(LIZ2);
    }

    public final boolean T_() {
        if (!(this.LJJIJIIJIL == 1073741824 || this.LJJIJIIJI == 1073741824)) {
            int LJIJI2 = LJIJI();
            for (int i = 0; i < LJIJI2; i++) {
                ViewGroup.LayoutParams layoutParams = LJI(i).getLayoutParams();
                if (layoutParams.width < 0 && layoutParams.height < 0) {
                    return true;
                }
            }
        }
        return false;
    }

    public AnonymousClass0EG LIZIZ() {
        return new AnonymousClass0EG(-2, -2);
    }

    public Parcelable LJ() {
        if (this.LJIJ != null) {
            return new SavedState(this.LJIJ);
        }
        SavedState savedState = new SavedState();
        if (LJIJI() > 0) {
            LJIIIIZZ();
            boolean z = this.LIZIZ ^ this.LJIIL;
            savedState.LIZJ = z;
            if (z) {
                View LJJIJIIJIL = LJJIJIIJIL();
                savedState.LIZIZ = this.LJIIJ.LIZJ() - this.LJIIJ.LIZIZ(LJJIJIIJIL);
                savedState.LIZ = LJI(LJJIJIIJIL);
            } else {
                View LJJIJIIJI = LJJIJIIJI();
                savedState.LIZ = LJI(LJJIJIIJI);
                savedState.LIZIZ = this.LJIIJ.LIZ(LJJIJIIJI) - this.LJIIJ.LIZIZ();
            }
        } else {
            savedState.LIZ = -1;
        }
        return savedState;
    }

    private void LIZ(C03650Dz r3) {
        LJ(r3.LIZIZ, r3.LIZJ);
    }

    private void LIZIZ(C03650Dz r3) {
        LJFF(r3.LIZIZ, r3.LIZJ);
    }

    public int LIZJ(AnonymousClass0EQ r2) {
        return LJIIIZ(r2);
    }

    public int LIZLLL(AnonymousClass0EQ r2) {
        return LJII(r2);
    }

    public int LJ(AnonymousClass0EQ r2) {
        return LJII(r2);
    }

    public int LJFF(AnonymousClass0EQ r2) {
        return LJIIIIZZ(r2);
    }

    public int LJI(AnonymousClass0EQ r2) {
        return LJIIIIZZ(r2);
    }

    public int LIZIZ(AnonymousClass0EQ r2) {
        return LJIIIZ(r2);
    }

    public final View LIZJ(boolean z) {
        if (this.LJIIL) {
            return LIZ(LJIJI() - 1, -1, z, true);
        }
        return LIZ(0, LJIJI(), z, true);
    }

    public final View LIZLLL(boolean z) {
        if (this.LJIIL) {
            return LIZ(0, LJIJI(), z, true);
        }
        return LIZ(LJIJI() - 1, -1, z, true);
    }

    public void LJ(int i) {
        this.LJIILL = i;
        this.LJIILLIIL = Integer.MIN_VALUE;
        SavedState savedState = this.LJIJ;
        if (savedState != null) {
            savedState.LIZ = -1;
        }
        LJIILJJIL();
    }

    private int LJII(AnonymousClass0EQ r8) {
        if (LJIJI() == 0) {
            return 0;
        }
        LJIIIIZZ();
        return AnonymousClass0EX.LIZ(r8, this.LJIIJ, LIZJ(!this.LJIILJJIL), LIZLLL(!this.LJIILJJIL), this, this.LJIILJJIL, this.LJIIL);
    }

    private int LJIIIIZZ(AnonymousClass0EQ r7) {
        if (LJIJI() == 0) {
            return 0;
        }
        LJIIIIZZ();
        return AnonymousClass0EX.LIZ(r7, this.LJIIJ, LIZJ(!this.LJIILJJIL), LIZLLL(!this.LJIILJJIL), this, this.LJIILJJIL);
    }

    private int LJIIIZ(AnonymousClass0EQ r7) {
        if (LJIJI() == 0) {
            return 0;
        }
        LJIIIIZZ();
        return AnonymousClass0EX.LIZIZ(r7, this.LJIIJ, LIZJ(!this.LJIILJJIL), LIZLLL(!this.LJIILJJIL), this, this.LJIILJJIL);
    }

    public PointF LIZLLL(int i) {
        if (LJIJI() == 0) {
            return null;
        }
        boolean z = false;
        int i2 = 1;
        if (i < LJI(LJI(0))) {
            z = true;
        }
        if (z != this.LJIIL) {
            i2 = -1;
        }
        if (this.LJIIIZ == 0) {
            return new PointF((float) i2, 0.0f);
        }
        return new PointF(0.0f, (float) i2);
    }

    public final View LIZJ(int i) {
        int LJIJI2 = LJIJI();
        if (LJIJI2 == 0) {
            return null;
        }
        int LJI = i - LJI(LJI(0));
        if (LJI >= 0 && LJI < LJIJI2) {
            View LJI2 = LJI(LJI);
            if (LJI(LJI2) == i) {
                return LJI2;
            }
        }
        return super.LIZJ(i);
    }

    public final int LJFF(int i) {
        if (i != 1) {
            if (i != 2) {
                if (i != 17) {
                    if (i != 33) {
                        if (i != 66) {
                            if (i == 130 && this.LJIIIZ == 1) {
                                return 1;
                            }
                            return Integer.MIN_VALUE;
                        } else if (this.LJIIIZ == 0) {
                            return 1;
                        } else {
                            return Integer.MIN_VALUE;
                        }
                    } else if (this.LJIIIZ == 1) {
                        return -1;
                    } else {
                        return Integer.MIN_VALUE;
                    }
                } else if (this.LJIIIZ == 0) {
                    return -1;
                } else {
                    return Integer.MIN_VALUE;
                }
            } else if (this.LJIIIZ != 1 && LJII()) {
                return -1;
            } else {
                return 1;
            }
        } else if (this.LJIIIZ != 1 && LJII()) {
            return 1;
        } else {
            return -1;
        }
    }

    public final void LIZIZ(int i) {
        if (i == 0 || i == 1) {
            LIZ((String) null);
            if (i != this.LJIIIZ || this.LJIIJ == null) {
                C03940Fc LIZ2 = C03940Fc.LIZ(this, i);
                this.LJIIJ = LIZ2;
                this.LJIJI.LIZ = LIZ2;
                this.LJIIIZ = i;
                LJIILJJIL();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("invalid orientation:".concat(String.valueOf(i)));
    }

    public final void LIZIZ(boolean z) {
        LIZ((String) null);
        if (z != this.LJIIJJI) {
            this.LJIIJJI = z;
            LJIILJJIL();
        }
    }

    public LinearLayoutManager(int i, boolean z) {
        this.LJIIIZ = 1;
        this.LJIILJJIL = true;
        this.LJIILL = -1;
        this.LJIILLIIL = Integer.MIN_VALUE;
        this.LJIJI = new C03650Dz();
        this.LIZJ = new AnonymousClass0E0();
        this.LJIJJ = 2;
        this.LIZLLL = new int[2];
        LIZIZ(i);
        LIZIZ(z);
    }

    private void LJ(int i, int i2) {
        int i3;
        this.LIZ.LIZJ = this.LJIIJ.LIZJ() - i2;
        AnonymousClass0E1 r2 = this.LIZ;
        if (this.LJIIL) {
            i3 = -1;
        } else {
            i3 = 1;
        }
        r2.LJ = i3;
        this.LIZ.LIZLLL = i;
        this.LIZ.LJFF = 1;
        this.LIZ.LIZIZ = i2;
        this.LIZ.LJI = Integer.MIN_VALUE;
    }

    private void LJFF(int i, int i2) {
        int i3;
        this.LIZ.LIZJ = i2 - this.LJIIJ.LIZIZ();
        this.LIZ.LIZLLL = i;
        AnonymousClass0E1 r2 = this.LIZ;
        if (this.LJIIL) {
            i3 = 1;
        } else {
            i3 = -1;
        }
        r2.LJ = i3;
        this.LIZ.LJFF = -1;
        this.LIZ.LIZIZ = i2;
        this.LIZ.LJI = Integer.MIN_VALUE;
    }

    private View LJI(int i, int i2) {
        int i3;
        int i4;
        LJIIIIZZ();
        if (i2 <= i && i2 >= i) {
            return LJI(i);
        }
        if (this.LJIIJ.LIZ(LJI(i)) < this.LJIIJ.LIZIZ()) {
            i3 = 16644;
            i4 = 16388;
        } else {
            i3 = 4161;
            i4 = 4097;
        }
        if (this.LJIIIZ == 0) {
            return this.LJJ.LIZ(i, i2, i3, i4);
        }
        return this.LJJI.LIZ(i, i2, i3, i4);
    }

    private void LIZ(AnonymousClass0EL r8, AnonymousClass0E1 r9) {
        if (r9.LIZ && !r9.LJIIL) {
            int i = r9.LJI;
            int i2 = r9.LJIIIIZZ;
            if (r9.LJFF == -1) {
                int LJIJI2 = LJIJI();
                if (i >= 0) {
                    int LIZLLL2 = (this.LJIIJ.LIZLLL() - i) + i2;
                    if (this.LJIIL) {
                        for (int i3 = 0; i3 < LJIJI2; i3++) {
                            View LJI = LJI(i3);
                            if (this.LJIIJ.LIZ(LJI) < LIZLLL2 || this.LJIIJ.LIZLLL(LJI) < LIZLLL2) {
                                LIZ(r8, 0, i3);
                                return;
                            }
                        }
                        return;
                    }
                    int i4 = LJIJI2 - 1;
                    for (int i5 = i4; i5 >= 0; i5--) {
                        View LJI2 = LJI(i5);
                        if (this.LJIIJ.LIZ(LJI2) < LIZLLL2 || this.LJIIJ.LIZLLL(LJI2) < LIZLLL2) {
                            LIZ(r8, i4, i5);
                            return;
                        }
                    }
                }
            } else if (i >= 0) {
                int i6 = i - i2;
                int LJIJI3 = LJIJI();
                if (this.LJIIL) {
                    int i7 = LJIJI3 - 1;
                    for (int i8 = i7; i8 >= 0; i8--) {
                        View LJI3 = LJI(i8);
                        if (this.LJIIJ.LIZIZ(LJI3) > i6 || this.LJIIJ.LIZJ(LJI3) > i6) {
                            LIZ(r8, i7, i8);
                            return;
                        }
                    }
                    return;
                }
                for (int i9 = 0; i9 < LJIJI3; i9++) {
                    View LJI4 = LJI(i9);
                    if (this.LJIIJ.LIZIZ(LJI4) > i6 || this.LJIIJ.LIZJ(LJI4) > i6) {
                        LIZ(r8, 0, i9);
                        return;
                    }
                }
            }
        }
    }

    private void LIZ(AnonymousClass0EQ r6, int[] iArr) {
        int i;
        int i2;
        if (r6.LIZ != -1) {
            i = this.LJIIJ.LJ();
        } else {
            i = 0;
        }
        if (this.LIZ.LJFF == -1) {
            i2 = 0;
        } else {
            i2 = i;
            i = 0;
        }
        iArr[0] = i;
        iArr[1] = i2;
    }

    public void LIZJ(AnonymousClass0EL r14, AnonymousClass0EQ r15) {
        int i;
        int i2;
        int i3;
        int i4;
        boolean z;
        int i5;
        int i6;
        int LIZ2;
        int i7;
        View LIZJ2;
        int LIZ3;
        int i8;
        int i9;
        View LIZ4;
        boolean z2;
        boolean z3;
        int i10;
        boolean z4;
        boolean z5;
        int LIZ5;
        if (!(this.LJIJ == null && this.LJIILL == -1) && r15.LIZ() == 0) {
            LIZJ(r14);
            return;
        }
        SavedState savedState = this.LJIJ;
        if (savedState != null && savedState.LIZ()) {
            this.LJIILL = this.LJIJ.LIZ;
        }
        LJIIIIZZ();
        this.LIZ.LIZ = false;
        LJJIIZI();
        View LJJII = LJJII();
        if (!this.LJIJI.LJ || this.LJIILL != -1 || this.LJIJ != null) {
            this.LJIJI.LIZ();
            this.LJIJI.LIZLLL = this.LJIIL ^ this.LJIILIIL;
            C03650Dz r4 = this.LJIJI;
            if (!r15.LJI && (i10 = this.LJIILL) != -1) {
                if (i10 < 0 || i10 >= r15.LIZ()) {
                    this.LJIILL = -1;
                    this.LJIILLIIL = Integer.MIN_VALUE;
                } else {
                    r4.LIZIZ = this.LJIILL;
                    SavedState savedState2 = this.LJIJ;
                    if (savedState2 == null || !savedState2.LIZ()) {
                        if (this.LJIILLIIL == Integer.MIN_VALUE) {
                            View LIZJ3 = LIZJ(this.LJIILL);
                            if (LIZJ3 == null) {
                                if (LJIJI() > 0) {
                                    if (this.LJIILL < LJI(LJI(0))) {
                                        z4 = true;
                                    } else {
                                        z4 = false;
                                    }
                                    if (z4 == this.LJIIL) {
                                        z5 = true;
                                    } else {
                                        z5 = false;
                                    }
                                    r4.LIZLLL = z5;
                                }
                                r4.LIZIZ();
                            } else if (this.LJIIJ.LJ(LIZJ3) > this.LJIIJ.LJ()) {
                                r4.LIZIZ();
                            } else if (this.LJIIJ.LIZ(LIZJ3) - this.LJIIJ.LIZIZ() < 0) {
                                r4.LIZJ = this.LJIIJ.LIZIZ();
                                r4.LIZLLL = false;
                            } else if (this.LJIIJ.LIZJ() - this.LJIIJ.LIZIZ(LIZJ3) < 0) {
                                r4.LIZJ = this.LJIIJ.LIZJ();
                                r4.LIZLLL = true;
                            } else {
                                if (r4.LIZLLL) {
                                    LIZ5 = this.LJIIJ.LIZIZ(LIZJ3) + this.LJIIJ.LIZ();
                                } else {
                                    LIZ5 = this.LJIIJ.LIZ(LIZJ3);
                                }
                                r4.LIZJ = LIZ5;
                            }
                        } else {
                            r4.LIZLLL = this.LJIIL;
                            if (this.LJIIL) {
                                r4.LIZJ = this.LJIIJ.LIZJ() - this.LJIILLIIL;
                            } else {
                                r4.LIZJ = this.LJIIJ.LIZIZ() + this.LJIILLIIL;
                            }
                        }
                        this.LJIJI.LJ = true;
                    } else {
                        r4.LIZLLL = this.LJIJ.LIZJ;
                        if (r4.LIZLLL) {
                            r4.LIZJ = this.LJIIJ.LIZJ() - this.LJIJ.LIZIZ;
                        } else {
                            r4.LIZJ = this.LJIIJ.LIZIZ() + this.LJIJ.LIZIZ;
                        }
                        this.LJIJI.LJ = true;
                    }
                }
            }
            if (LJIJI() != 0) {
                View LJJII2 = LJJII();
                if (LJJII2 != null) {
                    AnonymousClass0EG r1 = (AnonymousClass0EG) LJJII2.getLayoutParams();
                    if (!r1.LIZJ.isRemoved() && r1.LIZJ.getLayoutPosition() >= 0 && r1.LIZJ.getLayoutPosition() < r15.LIZ()) {
                        r4.LIZ(LJJII2, LJI(LJJII2));
                        this.LJIJI.LJ = true;
                    }
                }
                if (this.LIZIZ == this.LJIILIIL && (LIZ4 = LIZ(r14, r15, r4.LIZLLL, this.LJIILIIL)) != null) {
                    r4.LIZIZ(LIZ4, LJI(LIZ4));
                    if (!r15.LJI && R_()) {
                        int LIZ6 = this.LJIIJ.LIZ(LIZ4);
                        int LIZIZ2 = this.LJIIJ.LIZIZ(LIZ4);
                        int LIZIZ3 = this.LJIIJ.LIZIZ();
                        int LIZJ4 = this.LJIIJ.LIZJ();
                        if (LIZIZ2 > LIZIZ3 || LIZ6 >= LIZIZ3) {
                            z2 = false;
                        } else {
                            z2 = true;
                        }
                        if (LIZ6 < LIZJ4 || LIZIZ2 <= LIZJ4) {
                            z3 = false;
                        } else {
                            z3 = true;
                        }
                        if (z2 || z3) {
                            if (r4.LIZLLL) {
                                LIZIZ3 = LIZJ4;
                            }
                            r4.LIZJ = LIZIZ3;
                        }
                    }
                    this.LJIJI.LJ = true;
                }
            }
            r4.LIZIZ();
            if (this.LJIILIIL) {
                i9 = r15.LIZ() - 1;
            } else {
                i9 = 0;
            }
            r4.LIZIZ = i9;
            this.LJIJI.LJ = true;
        } else if (LJJII != null && (this.LJIIJ.LIZ(LJJII) >= this.LJIIJ.LIZJ() || this.LJIIJ.LIZIZ(LJJII) <= this.LJIIJ.LIZIZ())) {
            this.LJIJI.LIZ(LJJII, LJI(LJJII));
        }
        AnonymousClass0E1 r12 = this.LIZ;
        if (r12.LJIIJ >= 0) {
            i = 1;
        } else {
            i = -1;
        }
        r12.LJFF = i;
        int[] iArr = this.LIZLLL;
        iArr[0] = 0;
        iArr[1] = 0;
        LIZ(r15, iArr);
        int max = Math.max(0, this.LIZLLL[0]) + this.LJIIJ.LIZIZ();
        int max2 = Math.max(0, this.LIZLLL[1]) + this.LJIIJ.LJFF();
        if (!(!r15.LJI || (i7 = this.LJIILL) == -1 || this.LJIILLIIL == Integer.MIN_VALUE || (LIZJ2 = LIZJ(i7)) == null)) {
            if (this.LJIIL) {
                i8 = this.LJIIJ.LIZJ() - this.LJIIJ.LIZIZ(LIZJ2);
                LIZ3 = this.LJIILLIIL;
            } else {
                LIZ3 = this.LJIIJ.LIZ(LIZJ2) - this.LJIIJ.LIZIZ();
                i8 = this.LJIILLIIL;
            }
            int i11 = i8 - LIZ3;
            if (i11 > 0) {
                max += i11;
            } else {
                max2 -= i11;
            }
        }
        if (!this.LJIJI.LIZLLL ? !this.LJIIL : this.LJIIL) {
            i2 = 1;
        } else {
            i2 = -1;
        }
        LIZ(r14, r15, this.LJIJI, i2);
        LIZ(r14);
        this.LIZ.LJIIL = LJJIJ();
        this.LIZ.LJIIIZ = r15.LJI;
        this.LIZ.LJIIIIZZ = 0;
        if (this.LJIJI.LIZLLL) {
            LIZIZ(this.LJIJI);
            this.LIZ.LJII = max;
            LIZ(r14, this.LIZ, r15, false);
            i4 = this.LIZ.LIZIZ;
            int i12 = this.LIZ.LIZLLL;
            if (this.LIZ.LIZJ > 0) {
                max2 += this.LIZ.LIZJ;
            }
            LIZ(this.LJIJI);
            this.LIZ.LJII = max2;
            this.LIZ.LIZLLL += this.LIZ.LJ;
            LIZ(r14, this.LIZ, r15, false);
            i3 = this.LIZ.LIZIZ;
            if (this.LIZ.LIZJ > 0) {
                int i13 = this.LIZ.LIZJ;
                LJFF(i12, i4);
                this.LIZ.LJII = i13;
                LIZ(r14, this.LIZ, r15, false);
                i4 = this.LIZ.LIZIZ;
            }
        } else {
            LIZ(this.LJIJI);
            this.LIZ.LJII = max2;
            LIZ(r14, this.LIZ, r15, false);
            i3 = this.LIZ.LIZIZ;
            int i14 = this.LIZ.LIZLLL;
            if (this.LIZ.LIZJ > 0) {
                max += this.LIZ.LIZJ;
            }
            LIZIZ(this.LJIJI);
            this.LIZ.LJII = max;
            this.LIZ.LIZLLL += this.LIZ.LJ;
            LIZ(r14, this.LIZ, r15, false);
            i4 = this.LIZ.LIZIZ;
            if (this.LIZ.LIZJ > 0) {
                int i15 = this.LIZ.LIZJ;
                LJ(i14, i3);
                this.LIZ.LJII = i15;
                LIZ(r14, this.LIZ, r15, false);
                i3 = this.LIZ.LIZIZ;
            }
        }
        if (LJIJI() > 0) {
            if (this.LJIIL ^ this.LJIILIIL) {
                int LIZ7 = LIZ(i3, r14, r15, true);
                i5 = i4 + LIZ7;
                i6 = i3 + LIZ7;
                LIZ2 = LIZIZ(i5, r14, r15, false);
            } else {
                int LIZIZ4 = LIZIZ(i4, r14, r15, true);
                i5 = i4 + LIZIZ4;
                i6 = i3 + LIZIZ4;
                LIZ2 = LIZ(i6, r14, r15, false);
            }
            i4 = i5 + LIZ2;
            i3 = i6 + LIZ2;
        }
        if (r15.LJIIJ && LJIJI() != 0 && !r15.LJI && R_()) {
            List<RecyclerView.ViewHolder> list = r14.LIZLLL;
            int size = list.size();
            int LJI = LJI(LJI(0));
            int i16 = 0;
            int i17 = 0;
            for (int i18 = 0; i18 < size; i18++) {
                RecyclerView.ViewHolder viewHolder = list.get(i18);
                if (!viewHolder.isRemoved()) {
                    if (viewHolder.getLayoutPosition() < LJI) {
                        z = true;
                    } else {
                        z = false;
                    }
                    if (z != this.LJIIL) {
                        i16 += this.LJIIJ.LJ(viewHolder.itemView);
                    } else {
                        i17 += this.LJIIJ.LJ(viewHolder.itemView);
                    }
                }
            }
            this.LIZ.LJIIJJI = list;
            if (i16 > 0) {
                LJFF(LJI(LJJIJIIJI()), i4);
                this.LIZ.LJII = i16;
                this.LIZ.LIZJ = 0;
                this.LIZ.LIZ((View) null);
                LIZ(r14, this.LIZ, r15, false);
            }
            if (i17 > 0) {
                LJ(LJI(LJJIJIIJIL()), i3);
                this.LIZ.LJII = i17;
                this.LIZ.LIZJ = 0;
                this.LIZ.LIZ((View) null);
                LIZ(r14, this.LIZ, r15, false);
            }
            this.LIZ.LJIIJJI = null;
        }
        if (!r15.LJI) {
            C03940Fc r13 = this.LJIIJ;
            r13.LIZIZ = r13.LJ();
        } else {
            this.LJIJI.LIZ();
        }
        this.LIZIZ = this.LJIILIIL;
    }

    public int LIZ(int i, AnonymousClass0EL r4, AnonymousClass0EQ r5) {
        if (this.LJIIIZ == 1) {
            return 0;
        }
        return LIZJ(i, r4, r5);
    }

    public int LIZIZ(int i, AnonymousClass0EL r3, AnonymousClass0EQ r4) {
        if (this.LJIIIZ == 0) {
            return 0;
        }
        return LIZJ(i, r3, r4);
    }

    private void LIZ(AnonymousClass0EL r2, int i, int i2) {
        if (i != i2) {
            if (i2 > i) {
                for (int i3 = i2 - 1; i3 >= i; i3--) {
                    LIZ(i3, r2);
                }
                return;
            }
            while (i > i2) {
                LIZ(i, r2);
                i--;
            }
        }
    }

    private int LIZJ(int i, AnonymousClass0EL r7, AnonymousClass0EQ r8) {
        int i2;
        if (LJIJI() == 0 || i == 0) {
            return 0;
        }
        LJIIIIZZ();
        this.LIZ.LIZ = true;
        if (i > 0) {
            i2 = 1;
        } else {
            i2 = -1;
        }
        int abs = Math.abs(i);
        LIZ(i2, abs, true, r8);
        int LIZ2 = this.LIZ.LJI + LIZ(r7, this.LIZ, r8, false);
        if (LIZ2 < 0) {
            return 0;
        }
        if (abs > LIZ2) {
            i = i2 * LIZ2;
        }
        this.LJIIJ.LIZ(-i);
        this.LIZ.LJIIJ = i;
        return i;
    }

    private int LIZ(int i, AnonymousClass0EL r5, AnonymousClass0EQ r6, boolean z) {
        int LIZJ2;
        int LIZJ3 = this.LJIIJ.LIZJ() - i;
        if (LIZJ3 <= 0) {
            return 0;
        }
        int i2 = -LIZJ(-LIZJ3, r5, r6);
        int i3 = i + i2;
        if (!z || (LIZJ2 = this.LJIIJ.LIZJ() - i3) <= 0) {
            return i2;
        }
        this.LJIIJ.LIZ(LIZJ2);
        return LIZJ2 + i2;
    }

    private int LIZIZ(int i, AnonymousClass0EL r5, AnonymousClass0EQ r6, boolean z) {
        int LIZIZ2;
        int LIZIZ3 = i - this.LJIIJ.LIZIZ();
        if (LIZIZ3 <= 0) {
            return 0;
        }
        int i2 = -LIZJ(LIZIZ3, r5, r6);
        int i3 = i + i2;
        if (!z || (LIZIZ2 = i3 - this.LJIIJ.LIZIZ()) <= 0) {
            return i2;
        }
        this.LJIIJ.LIZ(-LIZIZ2);
        return i2 - LIZIZ2;
    }

    public LinearLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
        this.LJIIIZ = 1;
        this.LJIILJJIL = true;
        this.LJIILL = -1;
        this.LJIILLIIL = Integer.MIN_VALUE;
        this.LJIJI = new C03650Dz();
        this.LIZJ = new AnonymousClass0E0();
        this.LJIJJ = 2;
        this.LIZLLL = new int[2];
        AnonymousClass0EE LIZ2 = AnonymousClass0EF.LIZ(context, attributeSet, i, i2);
        LIZIZ(LIZ2.LIZ);
        LIZIZ(LIZ2.LIZJ);
        LIZ(LIZ2.LIZLLL);
    }

    private int LIZ(AnonymousClass0EL r8, AnonymousClass0E1 r9, AnonymousClass0EQ r10, boolean z) {
        int i = r9.LIZJ;
        if (r9.LJI != Integer.MIN_VALUE) {
            if (r9.LIZJ < 0) {
                r9.LJI += r9.LIZJ;
            }
            LIZ(r8, r9);
        }
        int i2 = r9.LIZJ + r9.LJII;
        AnonymousClass0E0 r2 = this.LIZJ;
        while (true) {
            if ((!r9.LJIIL && i2 <= 0) || !r9.LIZ(r10)) {
                break;
            }
            r2.LIZ();
            LIZ(r8, r10, r9, r2);
            if (r2.LIZIZ) {
                break;
            }
            r9.LIZIZ += r2.LIZ * r9.LJFF;
            if (!r2.LIZJ || r9.LJIIJJI != null || !r10.LJI) {
                r9.LIZJ -= r2.LIZ;
                i2 -= r2.LIZ;
            }
            if (r9.LJI != Integer.MIN_VALUE) {
                r9.LJI += r2.LIZ;
                if (r9.LIZJ < 0) {
                    r9.LJI += r9.LIZJ;
                }
                LIZ(r8, r9);
            }
            if (z && r2.LIZLLL) {
                break;
            }
        }
        return i - r9.LIZJ;
    }

    private View LIZ(int i, int i2, boolean z, boolean z2) {
        int i3;
        LJIIIIZZ();
        int i4 = 320;
        if (z) {
            i3 = 24579;
        } else {
            i3 = 320;
        }
        if (!z2) {
            i4 = 0;
        }
        if (this.LJIIIZ == 0) {
            return this.LJJ.LIZ(i, i2, i3, i4);
        }
        return this.LJJI.LIZ(i, i2, i3, i4);
    }

    private void LIZ(int i, int i2, boolean z, AnonymousClass0EQ r10) {
        int i3;
        int LIZIZ2;
        this.LIZ.LJIIL = LJJIJ();
        this.LIZ.LJFF = i;
        int[] iArr = this.LIZLLL;
        boolean z2 = false;
        iArr[0] = 0;
        int i4 = 1;
        iArr[1] = 0;
        LIZ(r10, iArr);
        int max = Math.max(0, this.LIZLLL[0]);
        int max2 = Math.max(0, this.LIZLLL[1]);
        if (i == 1) {
            z2 = true;
        }
        AnonymousClass0E1 r1 = this.LIZ;
        if (z2) {
            i3 = max2;
        } else {
            i3 = max;
        }
        r1.LJII = i3;
        AnonymousClass0E1 r0 = this.LIZ;
        if (!z2) {
            max = max2;
        }
        r0.LJIIIIZZ = max;
        if (z2) {
            this.LIZ.LJII += this.LJIIJ.LJFF();
            View LJJIJIIJIL = LJJIJIIJIL();
            AnonymousClass0E1 r12 = this.LIZ;
            if (this.LJIIL) {
                i4 = -1;
            }
            r12.LJ = i4;
            this.LIZ.LIZLLL = LJI(LJJIJIIJIL) + this.LIZ.LJ;
            this.LIZ.LIZIZ = this.LJIIJ.LIZIZ(LJJIJIIJIL);
            LIZIZ2 = this.LJIIJ.LIZIZ(LJJIJIIJIL) - this.LJIIJ.LIZJ();
        } else {
            View LJJIJIIJI = LJJIJIIJI();
            this.LIZ.LJII += this.LJIIJ.LIZIZ();
            AnonymousClass0E1 r13 = this.LIZ;
            if (!this.LJIIL) {
                i4 = -1;
            }
            r13.LJ = i4;
            this.LIZ.LIZLLL = LJI(LJJIJIIJI) + this.LIZ.LJ;
            this.LIZ.LIZIZ = this.LJIIJ.LIZ(LJJIJIIJI);
            LIZIZ2 = (-this.LJIIJ.LIZ(LJJIJIIJI)) + this.LJIIJ.LIZIZ();
        }
        this.LIZ.LIZJ = i2;
        if (z) {
            this.LIZ.LIZJ -= LIZIZ2;
        }
        this.LIZ.LJI = LIZIZ2;
    }
}
