package androidx.leanback.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.FocusFinder;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.GridView;
import androidx.leanback.widget.am;
import androidx.leanback.widget.bf;
import androidx.leanback.widget.bg;
import androidx.leanback.widget.u0;
import androidx.media3.extractor.ts.TsExtractor;
import androidx.media3.session.MediaUtils;
import androidx.recyclerview.widget.RecyclerView;
import defpackage.av6;
import defpackage.e01;
import defpackage.g01;
import defpackage.hv2;
import defpackage.i3;
import defpackage.iv2;
import defpackage.n41;
import defpackage.ol5;
import defpackage.sia;
import defpackage.yu6;
import defpackage.zu6;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public final class GridLayoutManager extends RecyclerView.o {
    public static final Rect aw = new Rect();
    public static final int[] ax = new int[2];
    public float a;
    public int aa;
    public int ab;
    public int[] ac;
    public int ad;
    public int ae;
    public int af;
    public int ag;
    public int ah;
    public int ai;
    public int aj;
    public int ak;
    public am al;
    public int am;
    public final u0 an;
    public final bf ao;
    public int ap;
    public int aq;
    public final int[] ar;
    public final t0 as;
    public iv2 at;
    public final Runnable au;
    public final b av;
    public int b;
    public m c;
    public int d;
    public androidx.recyclerview.widget.ak e;
    public int f;
    public RecyclerView.ac i;
    public int j;
    public int k;
    public final SparseIntArray l;
    public int[] m;
    public AudioManager n;
    public RecyclerView.w o;
    public int p;
    public zu6 q;
    public ArrayList r;
    public yu6 s;
    public int t;
    public int u;
    public c v;
    public e w;
    public int x;
    public int y;
    public int z;

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

        @Override // java.lang.Runnable
        public final void run() {
            GridLayoutManager.this.requestLayout();
        }
    }

    public class b implements am.b {
        public b() {
        }

        public final void a(Object obj, int i, int i2, int i3, int i4) {
            int i5;
            int i6;
            e eVar;
            int i7;
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            u0 u0Var = gridLayoutManager.an;
            View view = (View) obj;
            if (i4 == Integer.MIN_VALUE || i4 == Integer.MAX_VALUE) {
                if (gridLayoutManager.al.c) {
                    u0.a aVar = u0Var.c;
                    i4 = aVar.i - aVar.k;
                } else {
                    i4 = u0Var.c.j;
                }
            }
            if (gridLayoutManager.al.c) {
                i5 = i4 - i2;
                i6 = i4;
            } else {
                i6 = i2 + i4;
                i5 = i4;
            }
            int iV = (gridLayoutManager.v(i3) + u0Var.d.j) - gridLayoutManager.z;
            t0 t0Var = gridLayoutManager.as;
            if (t0Var.c != null) {
                SparseArray<Parcelable> sparseArray = (SparseArray) t0Var.c.remove(Integer.toString(i));
                if (sparseArray != null) {
                    view.restoreHierarchyState(sparseArray);
                }
            }
            gridLayoutManager.ad(view, i3, i5, i6, iV);
            if (!gridLayoutManager.i.g) {
                gridLayoutManager.ay();
            }
            if ((gridLayoutManager.p & 3) != 1 && (eVar = gridLayoutManager.w) != null) {
                GridLayoutManager gridLayoutManager2 = GridLayoutManager.this;
                if (eVar.c && (i7 = eVar.d) != 0) {
                    eVar.d = gridLayoutManager2.aj(i7, true);
                }
                int i8 = eVar.d;
                if (i8 == 0 || ((i8 > 0 && gridLayoutManager2.ab()) || (eVar.d < 0 && (gridLayoutManager2.getItemCount() == 0 || gridLayoutManager2.c.findViewHolderForAdapterPosition(0) != null)))) {
                    eVar.setTargetPosition(gridLayoutManager2.t);
                    eVar.stop();
                }
            }
            if (gridLayoutManager.s != null) {
                RecyclerView.ag childViewHolder = gridLayoutManager.c.getChildViewHolder(view);
                yu6 yu6Var = gridLayoutManager.s;
                if (childViewHolder != null) {
                    childViewHolder.getItemId();
                }
                yu6Var.a(i);
            }
        }

        public final int b(int i, boolean z, Object[] objArr, boolean z2) {
            int i2;
            View viewFindViewByPosition;
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            View viewAa = gridLayoutManager.aa(i - gridLayoutManager.j);
            if (!((d) viewAa.getLayoutParams()).a.isRemoved()) {
                if (z2) {
                    if (z) {
                        gridLayoutManager.addDisappearingView(viewAa);
                    } else {
                        gridLayoutManager.addDisappearingView(viewAa, 0);
                    }
                } else if (z) {
                    gridLayoutManager.addView(viewAa);
                } else {
                    gridLayoutManager.addView(viewAa, 0);
                }
                int i3 = gridLayoutManager.y;
                if (i3 != -1) {
                    viewAa.setVisibility(i3);
                }
                e eVar = gridLayoutManager.w;
                if (eVar != null) {
                    GridLayoutManager gridLayoutManager2 = GridLayoutManager.this;
                    if (!eVar.c && (i2 = eVar.d) != 0) {
                        int i4 = i2 > 0 ? gridLayoutManager2.t + gridLayoutManager2.aj : gridLayoutManager2.t - gridLayoutManager2.aj;
                        View view = null;
                        while (eVar.d != 0 && (viewFindViewByPosition = eVar.findViewByPosition(i4)) != null) {
                            if (viewFindViewByPosition.getVisibility() == 0 && (!gridLayoutManager2.hasFocus() || viewFindViewByPosition.hasFocusable())) {
                                gridLayoutManager2.t = i4;
                                gridLayoutManager2.u = 0;
                                int i5 = eVar.d;
                                if (i5 > 0) {
                                    eVar.d = i5 - 1;
                                } else {
                                    eVar.d = i5 + 1;
                                }
                                view = viewFindViewByPosition;
                            }
                            i4 = eVar.d > 0 ? i4 + gridLayoutManager2.aj : i4 - gridLayoutManager2.aj;
                        }
                        if (view != null && gridLayoutManager2.hasFocus()) {
                            gridLayoutManager2.p |= 32;
                            view.requestFocus();
                            gridLayoutManager2.p &= -33;
                        }
                    }
                }
                int iZ = GridLayoutManager.z(viewAa, viewAa.findFocus());
                int i6 = gridLayoutManager.p;
                if ((i6 & 3) != 1) {
                    if (i == gridLayoutManager.t && iZ == gridLayoutManager.u && gridLayoutManager.w == null) {
                        gridLayoutManager.o();
                    }
                } else if ((i6 & 4) == 0) {
                    int i7 = i6 & 16;
                    if (i7 == 0 && i == gridLayoutManager.t && iZ == gridLayoutManager.u) {
                        gridLayoutManager.o();
                    } else if (i7 != 0 && i >= gridLayoutManager.t && viewAa.hasFocusable()) {
                        gridLayoutManager.t = i;
                        gridLayoutManager.u = iZ;
                        gridLayoutManager.p &= -17;
                        gridLayoutManager.o();
                    }
                }
                gridLayoutManager.af(viewAa);
            }
            objArr[0] = viewAa;
            return gridLayoutManager.d == 0 ? gridLayoutManager.s(viewAa) : gridLayoutManager.r(viewAa);
        }

        public final int c() {
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            return gridLayoutManager.i.b() + gridLayoutManager.j;
        }

        public final int d(int i) {
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            View viewFindViewByPosition = gridLayoutManager.findViewByPosition(i - gridLayoutManager.j);
            return (gridLayoutManager.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? gridLayoutManager.e.d(viewFindViewByPosition) : gridLayoutManager.e.g(viewFindViewByPosition);
        }

        public final int e(int i) {
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            View viewFindViewByPosition = gridLayoutManager.findViewByPosition(i - gridLayoutManager.j);
            Rect rect = GridLayoutManager.aw;
            gridLayoutManager.getDecoratedBoundsWithMargins(viewFindViewByPosition, rect);
            return gridLayoutManager.d == 0 ? rect.width() : rect.height();
        }

        public final void f(int i) {
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            View viewFindViewByPosition = gridLayoutManager.findViewByPosition(i - gridLayoutManager.j);
            if ((gridLayoutManager.p & 3) == 1) {
                gridLayoutManager.detachAndScrapView(viewFindViewByPosition, gridLayoutManager.o);
            } else {
                gridLayoutManager.removeAndRecycleView(viewFindViewByPosition, gridLayoutManager.o);
            }
        }
    }

    public abstract class c extends androidx.recyclerview.widget.ad {
        public boolean a;

        public c() {
            super(GridLayoutManager.this.c.getContext());
        }

        public void a() {
            View viewFindViewByPosition = findViewByPosition(getTargetPosition());
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            if (viewFindViewByPosition == null) {
                if (getTargetPosition() >= 0) {
                    gridLayoutManager.ap(getTargetPosition(), 0, false);
                    return;
                }
                return;
            }
            if (gridLayoutManager.t != getTargetPosition()) {
                gridLayoutManager.t = getTargetPosition();
            }
            if (gridLayoutManager.hasFocus()) {
                gridLayoutManager.p |= 32;
                viewFindViewByPosition.requestFocus();
                gridLayoutManager.p &= -33;
            }
            gridLayoutManager.o();
            gridLayoutManager.p();
        }

        @Override // androidx.recyclerview.widget.ad
        public final float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
            return super.calculateSpeedPerPixel(displayMetrics) * GridLayoutManager.this.a;
        }

        @Override // androidx.recyclerview.widget.ad
        public final int calculateTimeForScrolling(int i) {
            int iCalculateTimeForScrolling = super.calculateTimeForScrolling(i);
            int i2 = GridLayoutManager.this.an.c.i;
            if (i2 > 0) {
                float f = (30.0f / i2) * i;
                if (iCalculateTimeForScrolling < f) {
                    return (int) f;
                }
            }
            return iCalculateTimeForScrolling;
        }

        @Override // androidx.recyclerview.widget.ad, androidx.recyclerview.widget.RecyclerView.ab
        public final void onStop() {
            super.onStop();
            if (!this.a) {
                a();
            }
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            if (gridLayoutManager.v == this) {
                gridLayoutManager.v = null;
            }
            if (gridLayoutManager.w == this) {
                gridLayoutManager.w = null;
            }
        }

        @Override // androidx.recyclerview.widget.ad, androidx.recyclerview.widget.RecyclerView.ab
        public final void onTargetFound(View view, RecyclerView.ac acVar, RecyclerView.ab.a aVar) {
            int i;
            int i2;
            int[] iArr = GridLayoutManager.ax;
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            if (gridLayoutManager.w(view, null, iArr)) {
                if (gridLayoutManager.d == 0) {
                    i = iArr[0];
                    i2 = iArr[1];
                } else {
                    i = iArr[1];
                    i2 = iArr[0];
                }
                aVar.b(i, i2, this.mDecelerateInterpolator, calculateTimeForDeceleration((int) Math.sqrt((i2 * i2) + (i * i))));
            }
        }
    }

    public static final class d extends RecyclerView.p {
        public int e;
        public int f;
        public int i;
        public int j;
        public int k;
        public int l;
        public int[] m;
        public bg n;
    }

    public final class e extends c {
        public final boolean c;
        public int d;

        public e(int i, boolean z) {
            super();
            this.d = i;
            this.c = z;
            setTargetPosition(-2);
        }

        @Override // androidx.leanback.widget.GridLayoutManager.c
        public final void a() {
            super.a();
            this.d = 0;
            View viewFindViewByPosition = findViewByPosition(getTargetPosition());
            if (viewFindViewByPosition != null) {
                GridLayoutManager.this.ar(viewFindViewByPosition, true);
            }
        }

        @Override // androidx.recyclerview.widget.RecyclerView.ab
        public final PointF computeScrollVectorForPosition(int i) {
            int i2 = this.d;
            if (i2 == 0) {
                return null;
            }
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            int i3 = ((gridLayoutManager.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) == 0 ? i2 >= 0 : i2 <= 0) ? 1 : -1;
            return gridLayoutManager.d == 0 ? new PointF(i3, 0.0f) : new PointF(0.0f, i3);
        }
    }

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

        public class a implements Parcelable.Creator<f> {
            @Override // android.os.Parcelable.Creator
            public final f createFromParcel(Parcel parcel) {
                f fVar = new f();
                fVar.b = Bundle.EMPTY;
                fVar.a = parcel.readInt();
                fVar.b = parcel.readBundle(GridLayoutManager.class.getClassLoader());
                return fVar;
            }

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

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

        @Override // android.os.Parcelable
        public final void writeToParcel(Parcel parcel, int i) {
            parcel.writeInt(this.a);
            parcel.writeBundle(this.b);
        }
    }

    public GridLayoutManager() {
        this(null);
    }

    public static int q(View view) {
        d dVar;
        if (view == null || (dVar = (d) view.getLayoutParams()) == null || dVar.a.isRemoved()) {
            return -1;
        }
        return dVar.a.getAbsoluteAdapterPosition();
    }

    public static int z(View view, View view2) {
        bg bgVar;
        if (view == null || view2 == null || (bgVar = ((d) view.getLayoutParams()).n) == null) {
            return 0;
        }
        bg.a[] aVarArr = bgVar.a;
        if (aVarArr.length <= 1) {
            return 0;
        }
        while (view2 != view) {
            int id = view2.getId();
            if (id != -1) {
                for (int i = 1; i < aVarArr.length; i++) {
                    bg.a aVar = aVarArr[i];
                    int i2 = aVar.b;
                    if (i2 == -1) {
                        i2 = aVar.a;
                    }
                    if (i2 == id) {
                        return i;
                    }
                }
            }
            view2 = (View) view2.getParent();
        }
        return 0;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final View aa(int i) {
        iv2 iv2Var;
        hv2 hv2VarC;
        View viewD = this.o.d(i);
        d dVar = (d) viewD.getLayoutParams();
        RecyclerView.ag childViewHolder = this.c.getChildViewHolder(viewD);
        Object objA = childViewHolder instanceof hv2 ? ((hv2) childViewHolder).a() : null;
        if (objA == null && (iv2Var = this.at) != null && (hv2VarC = iv2Var.c(childViewHolder.getItemViewType())) != null) {
            objA = hv2VarC.a();
        }
        dVar.n = (bg) objA;
        return viewD;
    }

    public final boolean ab() {
        int itemCount = getItemCount();
        return itemCount == 0 || this.c.findViewHolderForAdapterPosition(itemCount - 1) != null;
    }

    public final boolean ac(int i) {
        RecyclerView.ag agVarFindViewHolderForAdapterPosition = this.c.findViewHolderForAdapterPosition(i);
        return agVarFindViewHolderForAdapterPosition != null && agVarFindViewHolderForAdapterPosition.itemView.getLeft() >= 0 && agVarFindViewHolderForAdapterPosition.itemView.getRight() <= this.c.getWidth() && agVarFindViewHolderForAdapterPosition.itemView.getTop() >= 0 && agVarFindViewHolderForAdapterPosition.itemView.getBottom() <= this.c.getHeight();
    }

    public final void ad(View view, int i, int i2, int i3, int i4) {
        int iU;
        int i5;
        int i6;
        int i7;
        int i8;
        int iR = this.d == 0 ? r(view) : s(view);
        int i9 = this.ab;
        if (i9 > 0) {
            iR = Math.min(iR, i9);
        }
        int i10 = this.ai;
        int i11 = i10 & 112;
        int absoluteGravity = (this.p & 786432) != 0 ? Gravity.getAbsoluteGravity(i10 & 8388615, 1) : i10 & 7;
        int i12 = this.d;
        if ((i12 != 0 || i11 != 48) && (i12 != 1 || absoluteGravity != 3)) {
            if ((i12 == 0 && i11 == 80) || (i12 == 1 && absoluteGravity == 5)) {
                iU = u(i) - iR;
            } else if ((i12 == 0 && i11 == 16) || (i12 == 1 && absoluteGravity == 1)) {
                iU = (u(i) - iR) / 2;
            }
            i4 += iU;
        }
        if (this.d == 0) {
            i7 = i2;
            i8 = i3;
            i5 = i4;
            i6 = iR + i4;
        } else {
            i5 = i2;
            i6 = i3;
            i7 = i4;
            i8 = iR + i4;
        }
        d dVar = (d) view.getLayoutParams();
        layoutDecoratedWithMargins(view, i7, i5, i8, i6);
        Rect rect = aw;
        super.getDecoratedBoundsWithMargins(view, rect);
        int i13 = i7 - rect.left;
        int i14 = i5 - rect.top;
        int i15 = rect.right - i8;
        int i16 = rect.bottom - i6;
        dVar.e = i13;
        dVar.f = i14;
        dVar.i = i15;
        dVar.j = i16;
        av(view);
    }

    public final void ae() {
        int i = this.f - 1;
        this.f = i;
        if (i == 0) {
            this.o = null;
            this.i = null;
            this.j = 0;
            this.k = 0;
        }
    }

    public final void af(View view) {
        int childMeasureSpec;
        int childMeasureSpec2;
        d dVar = (d) view.getLayoutParams();
        Rect rect = aw;
        calculateItemDecorationsForChild(view, rect);
        int i = ((ViewGroup.MarginLayoutParams) dVar).leftMargin + ((ViewGroup.MarginLayoutParams) dVar).rightMargin + rect.left + rect.right;
        int i2 = ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin + rect.top + rect.bottom;
        int iMakeMeasureSpec = this.aa == -2 ? View.MeasureSpec.makeMeasureSpec(0, 0) : View.MeasureSpec.makeMeasureSpec(this.ab, 1073741824);
        if (this.d == 0) {
            childMeasureSpec = ViewGroup.getChildMeasureSpec(View.MeasureSpec.makeMeasureSpec(0, 0), i, ((ViewGroup.MarginLayoutParams) dVar).width);
            childMeasureSpec2 = ViewGroup.getChildMeasureSpec(iMakeMeasureSpec, i2, ((ViewGroup.MarginLayoutParams) dVar).height);
        } else {
            int childMeasureSpec3 = ViewGroup.getChildMeasureSpec(View.MeasureSpec.makeMeasureSpec(0, 0), i2, ((ViewGroup.MarginLayoutParams) dVar).height);
            childMeasureSpec = ViewGroup.getChildMeasureSpec(iMakeMeasureSpec, i, ((ViewGroup.MarginLayoutParams) dVar).width);
            childMeasureSpec2 = childMeasureSpec3;
        }
        view.measure(childMeasureSpec, childMeasureSpec2);
    }

    public final void ag() {
        this.al.m((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? this.ap + this.aq + this.k : (-this.aq) - this.k, false);
    }

    public final void ah(boolean z) {
        int i;
        if (z) {
            if (ab()) {
                return;
            }
        } else if (getItemCount() == 0 || this.c.findViewHolderForAdapterPosition(0) != null) {
            return;
        }
        e eVar = this.w;
        if (eVar == null) {
            e eVar2 = new e(z ? 1 : -1, this.aj > 1);
            this.x = 0;
            startSmoothScroll(eVar2);
        } else {
            GridLayoutManager gridLayoutManager = GridLayoutManager.this;
            if (z) {
                int i2 = eVar.d;
                if (i2 < gridLayoutManager.b) {
                    eVar.d = i2 + 1;
                }
            } else {
                int i3 = eVar.d;
                if (i3 > (-gridLayoutManager.b)) {
                    eVar.d = i3 - 1;
                }
            }
        }
        if (this.d == 0) {
            i = 4;
            if (getLayoutDirection() != 1 ? !z : z) {
                i = 3;
            }
        } else {
            i = z ? 2 : 1;
        }
        if (this.n == null) {
            this.n = (AudioManager) this.c.getContext().getSystemService("audio");
        }
        this.n.playSoundEffect(i);
    }

    /* JADX WARN: Removed duplicated region for block: B:75:0x014a  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x014e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean ai(boolean z) {
        int i;
        int i2 = 0;
        if (this.ab != 0 || this.ac == null) {
            return false;
        }
        am amVar = this.al;
        g01[] g01VarArrJ = amVar == null ? null : amVar.j(amVar.f, amVar.g);
        int i3 = 0;
        boolean z2 = false;
        int i4 = -1;
        while (i3 < this.aj) {
            g01 g01Var = g01VarArrJ == null ? null : g01VarArrJ[i3];
            int iC = g01Var == null ? i2 : g01Var.c();
            int i5 = -1;
            for (int i6 = i2; i6 < iC; i6 += 2) {
                int iB = g01Var.b(i6 + 1);
                for (int iB2 = g01Var.b(i6); iB2 <= iB; iB2++) {
                    View viewFindViewByPosition = findViewByPosition(iB2 - this.j);
                    if (viewFindViewByPosition != null) {
                        if (z) {
                            af(viewFindViewByPosition);
                        }
                        int iR = this.d == 0 ? r(viewFindViewByPosition) : s(viewFindViewByPosition);
                        if (iR > i5) {
                            i5 = iR;
                        }
                    }
                }
            }
            int iB3 = this.i.b();
            if (this.c.hasFixedSize() || !z || i5 >= 0 || iB3 <= 0) {
                i = i2;
            } else if (i4 >= 0) {
                i = i2;
                if (i4 >= 0) {
                    i5 = i4;
                }
            } else {
                int i7 = this.t;
                if (i7 < 0) {
                    i7 = i2;
                } else if (i7 >= iB3) {
                    i7 = iB3 - 1;
                }
                if (getChildCount() > 0) {
                    int layoutPosition = this.c.getChildViewHolder(getChildAt(i2)).getLayoutPosition();
                    int layoutPosition2 = this.c.getChildViewHolder(getChildAt(getChildCount() - 1)).getLayoutPosition();
                    if (i7 >= layoutPosition && i7 <= layoutPosition2) {
                        i7 = i7 - layoutPosition <= layoutPosition2 - i7 ? layoutPosition - 1 : layoutPosition2 + 1;
                        if (i7 < 0 && layoutPosition2 < iB3 - 1) {
                            i7 = layoutPosition2 + 1;
                        } else if (i7 >= iB3 && layoutPosition > 0) {
                            i7 = layoutPosition - 1;
                        }
                    }
                }
                if (i7 >= 0 && i7 < iB3) {
                    int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i2, i2);
                    int iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i2, i2);
                    View viewD = this.o.d(i7);
                    int[] iArr = this.ar;
                    if (viewD != null) {
                        d dVar = (d) viewD.getLayoutParams();
                        Rect rect = aw;
                        calculateItemDecorationsForChild(viewD, rect);
                        i = i2;
                        viewD.measure(ViewGroup.getChildMeasureSpec(iMakeMeasureSpec, getPaddingRight() + getPaddingLeft() + ((ViewGroup.MarginLayoutParams) dVar).leftMargin + ((ViewGroup.MarginLayoutParams) dVar).rightMargin + rect.left + rect.right, ((ViewGroup.MarginLayoutParams) dVar).width), ViewGroup.getChildMeasureSpec(iMakeMeasureSpec2, getPaddingBottom() + getPaddingTop() + ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin + rect.top + rect.bottom, ((ViewGroup.MarginLayoutParams) dVar).height));
                        iArr[i] = s(viewD);
                        iArr[1] = r(viewD);
                        this.o.j(viewD);
                    } else {
                        i = i2;
                    }
                    i4 = this.d == 0 ? iArr[1] : iArr[i];
                }
                if (i4 >= 0) {
                }
            }
            if (i5 < 0) {
                i5 = i;
            }
            int[] iArr2 = this.ac;
            if (iArr2[i3] != i5) {
                iArr2[i3] = i5;
                z2 = true;
            }
            i3++;
            i2 = i;
        }
        return z2;
    }

    public final int aj(int i, boolean z) {
        am.a aVarK;
        am amVar = this.al;
        if (amVar == null) {
            return i;
        }
        int i2 = this.t;
        int i3 = (i2 == -1 || (aVarK = amVar.k(i2)) == null) ? -1 : aVarK.a;
        int childCount = getChildCount();
        View view = null;
        for (int i4 = 0; i4 < childCount && i != 0; i4++) {
            int i5 = i > 0 ? i4 : (childCount - 1) - i4;
            View childAt = getChildAt(i5);
            if (childAt.getVisibility() == 0 && (!hasFocus() || childAt.hasFocusable())) {
                int iQ = q(getChildAt(i5));
                am.a aVarK2 = this.al.k(iQ);
                int i6 = aVarK2 == null ? -1 : aVarK2.a;
                if (i3 == -1) {
                    i2 = iQ;
                    view = childAt;
                    i3 = i6;
                } else if (i6 == i3 && ((i > 0 && iQ > i2) || (i < 0 && iQ < i2))) {
                    i = i > 0 ? i - 1 : i + 1;
                    i2 = iQ;
                    view = childAt;
                }
            }
        }
        if (view != null) {
            if (z) {
                if (hasFocus()) {
                    this.p |= 32;
                    view.requestFocus();
                    this.p &= -33;
                }
                this.t = i2;
                this.u = 0;
                return i;
            }
            ar(view, true);
        }
        return i;
    }

    public final void ak() {
        int i = this.p;
        if ((65600 & i) == 65536) {
            am amVar = this.al;
            int i2 = this.t;
            int i3 = (i & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? -this.aq : this.ap + this.aq;
            while (true) {
                int i4 = amVar.g;
                if (i4 >= amVar.f && i4 > i2) {
                    if (!amVar.c) {
                        if (amVar.b.d(i4) < i3) {
                            break;
                        }
                        amVar.b.f(amVar.g);
                        amVar.g--;
                    } else {
                        if (amVar.b.d(i4) > i3) {
                            break;
                        }
                        amVar.b.f(amVar.g);
                        amVar.g--;
                    }
                } else {
                    break;
                }
            }
            if (amVar.g < amVar.f) {
                amVar.g = -1;
                amVar.f = -1;
            }
        }
    }

    public final void al() {
        int i = this.p;
        if ((65600 & i) == 65536) {
            am amVar = this.al;
            int i2 = this.t;
            int i3 = (i & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? this.ap + this.aq : -this.aq;
            while (true) {
                int i4 = amVar.g;
                int i5 = amVar.f;
                if (i4 >= i5 && i5 < i2) {
                    int iE = amVar.b.e(i5);
                    if (!amVar.c) {
                        if (amVar.b.d(amVar.f) + iE > i3) {
                            break;
                        }
                        amVar.b.f(amVar.f);
                        amVar.f++;
                    } else {
                        if (amVar.b.d(amVar.f) - iE < i3) {
                            break;
                        }
                        amVar.b.f(amVar.f);
                        amVar.f++;
                    }
                } else {
                    break;
                }
            }
            if (amVar.g < amVar.f) {
                amVar.g = -1;
                amVar.f = -1;
            }
        }
    }

    public final void am(RecyclerView.w wVar, RecyclerView.ac acVar) {
        int i = this.f;
        if (i == 0) {
            this.o = wVar;
            this.i = acVar;
            this.j = 0;
            this.k = 0;
        }
        this.f = i + 1;
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x002d A[PHI: r0
      0x002d: PHI (r0v8 int) = (r0v7 int), (r0v10 int) binds: [B:19:0x002b, B:12:0x001b] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int an(int i) {
        int i2;
        int i3 = this.p;
        if ((i3 & 64) == 0 && (i3 & 3) != 1) {
            u0 u0Var = this.an;
            if (i > 0) {
                u0.a aVar = u0Var.c;
                if (aVar.a != Integer.MAX_VALUE && i > (i2 = aVar.c)) {
                    i = i2;
                }
            } else if (i < 0) {
                u0.a aVar2 = u0Var.c;
                if (aVar2.b != Integer.MIN_VALUE && i < (i2 = aVar2.d)) {
                }
            }
        }
        if (i == 0) {
            return 0;
        }
        int i4 = -i;
        int childCount = getChildCount();
        if (this.d == 1) {
            for (int i5 = 0; i5 < childCount; i5++) {
                getChildAt(i5).offsetTopAndBottom(i4);
            }
        } else {
            for (int i6 = 0; i6 < childCount; i6++) {
                getChildAt(i6).offsetLeftAndRight(i4);
            }
        }
        if ((this.p & 3) == 1) {
            ay();
            return i;
        }
        int childCount2 = getChildCount();
        if ((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) == 0 ? i >= 0 : i <= 0) {
            n();
        } else {
            ag();
        }
        boolean z = getChildCount() > childCount2;
        int childCount3 = getChildCount();
        if ((262144 & this.p) == 0 ? i >= 0 : i <= 0) {
            al();
        } else {
            ak();
        }
        if (z | (getChildCount() < childCount3)) {
            ax();
        }
        this.c.invalidate();
        ay();
        return i;
    }

    public final int ao(int i) {
        int i2 = 0;
        if (i == 0) {
            return 0;
        }
        int i3 = -i;
        int childCount = getChildCount();
        if (this.d == 0) {
            while (i2 < childCount) {
                getChildAt(i2).offsetTopAndBottom(i3);
                i2++;
            }
        } else {
            while (i2 < childCount) {
                getChildAt(i2).offsetLeftAndRight(i3);
                i2++;
            }
        }
        this.z += i;
        az();
        this.c.invalidate();
        return i;
    }

    public final void ap(int i, int i2, boolean z) {
        View viewFindViewByPosition = findViewByPosition(i);
        boolean zIsSmoothScrolling = isSmoothScrolling();
        if (!zIsSmoothScrolling && !this.c.isLayoutRequested() && viewFindViewByPosition != null && q(viewFindViewByPosition) == i) {
            this.p |= 32;
            ar(viewFindViewByPosition, z);
            this.p &= -33;
            return;
        }
        int i3 = this.p;
        if ((i3 & 512) == 0 || (i3 & 64) != 0) {
            this.t = i;
            this.u = i2;
            this.x = Integer.MIN_VALUE;
            return;
        }
        if (z && !this.c.isLayoutRequested()) {
            this.t = i;
            this.u = i2;
            this.x = Integer.MIN_VALUE;
            if (this.al == null) {
                Log.w("GridLayoutManager:" + this.c.getId(), "setSelectionSmooth should not be called before first layout pass");
                return;
            }
            ao aoVar = new ao(this);
            aoVar.setTargetPosition(i);
            startSmoothScroll(aoVar);
            int targetPosition = aoVar.getTargetPosition();
            if (targetPosition != this.t) {
                this.t = targetPosition;
                this.u = 0;
                return;
            }
            return;
        }
        if (zIsSmoothScrolling) {
            c cVar = this.v;
            if (cVar != null) {
                cVar.a = true;
            }
            this.c.stopScroll();
        }
        if (!this.c.isLayoutRequested() && viewFindViewByPosition != null && q(viewFindViewByPosition) == i) {
            this.p |= 32;
            ar(viewFindViewByPosition, z);
            this.p &= -33;
        } else {
            this.t = i;
            this.u = i2;
            this.x = Integer.MIN_VALUE;
            this.p |= 256;
            requestLayout();
        }
    }

    public final void aq(View view, View view2, boolean z, int i, int i2) {
        if ((this.p & 64) != 0) {
            return;
        }
        int iQ = q(view);
        int iZ = z(view, view2);
        if (iQ != this.t || iZ != this.u) {
            this.t = iQ;
            this.u = iZ;
            this.x = 0;
            if ((this.p & 3) != 1) {
                o();
            }
            if (this.c.g()) {
                this.c.invalidate();
            }
        }
        if (view == null) {
            return;
        }
        if (!view.hasFocus() && this.c.hasFocus()) {
            view.requestFocus();
        }
        if ((this.p & 131072) == 0 && z) {
            return;
        }
        int[] iArr = ax;
        if (!w(view, view2, iArr) && i == 0 && i2 == 0) {
            return;
        }
        int i3 = iArr[0] + i;
        int i4 = iArr[1] + i2;
        if ((this.p & 3) == 1) {
            an(i3);
            ao(i4);
            return;
        }
        if (this.d != 0) {
            i4 = i3;
            i3 = i4;
        }
        if (z) {
            this.c.smoothScrollBy(i3, i4);
        } else {
            this.c.scrollBy(i3, i4);
            p();
        }
    }

    public final void ar(View view, boolean z) {
        aq(view, view.findFocus(), z, 0, 0);
    }

    public final void as(int i) {
        if (i < 0 && i != -2) {
            throw new IllegalArgumentException(n41.k("Invalid row height: ", i));
        }
        this.aa = i;
    }

    public final void at(int i, boolean z) {
        if ((this.t == i || i == -1) && this.u == 0) {
            return;
        }
        ap(i, 0, z);
    }

    public final void au() {
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            av(getChildAt(i));
        }
    }

    public final void av(View view) {
        d dVar = (d) view.getLayoutParams();
        bg bgVar = dVar.n;
        bf bfVar = this.ao;
        if (bgVar == null) {
            bf.a aVar = bfVar.b;
            dVar.k = bh.a(view, aVar, aVar.g);
            bf.a aVar2 = bfVar.a;
            dVar.l = bh.a(view, aVar2, aVar2.g);
            return;
        }
        int i = this.d;
        bg.a[] aVarArr = bgVar.a;
        int[] iArr = dVar.m;
        if (iArr == null || iArr.length != aVarArr.length) {
            dVar.m = new int[aVarArr.length];
        }
        for (int i2 = 0; i2 < aVarArr.length; i2++) {
            dVar.m[i2] = bh.a(view, aVarArr[i2], i);
        }
        if (i == 0) {
            dVar.k = dVar.m[0];
        } else {
            dVar.l = dVar.m[0];
        }
        if (this.d == 0) {
            bf.a aVar3 = bfVar.a;
            dVar.l = bh.a(view, aVar3, aVar3.g);
        } else {
            bf.a aVar4 = bfVar.b;
            dVar.k = bh.a(view, aVar4, aVar4.g);
        }
    }

    public final void aw() {
        if (getChildCount() <= 0) {
            this.j = 0;
        } else {
            this.j = this.al.f - ((d) getChildAt(0).getLayoutParams()).a.getLayoutPosition();
        }
    }

    public final void ax() {
        int i = (this.p & (-1025)) | (ai(false) ? 1024 : 0);
        this.p = i;
        if ((i & 1024) != 0) {
            m mVar = this.c;
            WeakHashMap weakHashMap = sia.a;
            mVar.postOnAnimation(this.au);
        }
    }

    public final void ay() {
        int iB;
        int i;
        int i2;
        int i3;
        int i4;
        int i5;
        int top;
        int i6;
        int top2;
        int i7;
        if (this.i.b() == 0) {
            return;
        }
        if ((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) == 0) {
            i = this.al.g;
            int iB2 = this.i.b() - 1;
            i2 = this.al.f;
            i3 = iB2;
            iB = 0;
        } else {
            am amVar = this.al;
            int i8 = amVar.f;
            int i9 = amVar.g;
            iB = this.i.b() - 1;
            i = i8;
            i2 = i9;
            i3 = 0;
        }
        if (i < 0 || i2 < 0) {
            return;
        }
        boolean z = i == i3;
        boolean z2 = i2 == iB;
        int i10 = Integer.MIN_VALUE;
        int iG = Integer.MAX_VALUE;
        u0 u0Var = this.an;
        if (!z) {
            u0.a aVar = u0Var.c;
            if (aVar.a == Integer.MAX_VALUE && !z2 && aVar.b == Integer.MIN_VALUE) {
                return;
            }
        }
        int[] iArr = ax;
        if (z) {
            iG = this.al.g(iArr, true);
            View viewFindViewByPosition = findViewByPosition(iArr[1]);
            if (this.d == 0) {
                d dVar = (d) viewFindViewByPosition.getLayoutParams();
                dVar.getClass();
                top2 = viewFindViewByPosition.getLeft() + dVar.e;
                i7 = dVar.k;
            } else {
                d dVar2 = (d) viewFindViewByPosition.getLayoutParams();
                dVar2.getClass();
                top2 = viewFindViewByPosition.getTop() + dVar2.f;
                i7 = dVar2.l;
            }
            int i11 = top2 + i7;
            int[] iArr2 = ((d) viewFindViewByPosition.getLayoutParams()).m;
            i4 = (iArr2 == null || iArr2.length <= 0) ? i11 : (iArr2[iArr2.length - 1] - iArr2[0]) + i11;
        } else {
            i4 = Integer.MAX_VALUE;
        }
        if (z2) {
            i10 = this.al.i(iArr, false);
            View viewFindViewByPosition2 = findViewByPosition(iArr[1]);
            if (this.d == 0) {
                d dVar3 = (d) viewFindViewByPosition2.getLayoutParams();
                dVar3.getClass();
                top = viewFindViewByPosition2.getLeft() + dVar3.e;
                i6 = dVar3.k;
            } else {
                d dVar4 = (d) viewFindViewByPosition2.getLayoutParams();
                dVar4.getClass();
                top = viewFindViewByPosition2.getTop() + dVar4.f;
                i6 = dVar4.l;
            }
            i5 = top + i6;
        } else {
            i5 = Integer.MIN_VALUE;
        }
        u0Var.c.c(i10, iG, i5, i4);
    }

    public final void az() {
        u0.a aVar = this.an.d;
        int i = aVar.j - this.z;
        int iX = x() + i;
        aVar.c(i, iX, i, iX);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean canScrollHorizontally() {
        return this.d == 0 || this.aj > 1;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean canScrollVertically() {
        return this.d == 1 || this.aj > 1;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean checkLayoutParams(RecyclerView.p pVar) {
        return pVar instanceof d;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void collectAdjacentPrefetchPositions(int i, int i2, RecyclerView.ac acVar, RecyclerView.o.c cVar) {
        try {
            am(null, acVar);
            if (this.d != 0) {
                i = i2;
            }
            if (getChildCount() != 0 && i != 0) {
                this.al.e(i < 0 ? -this.aq : this.ap + this.aq, i, cVar);
                ae();
            }
        } finally {
            ae();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void collectInitialPrefetchPositions(int i, RecyclerView.o.c cVar) {
        int i2 = this.c.l;
        if (i == 0 || i2 == 0) {
            return;
        }
        int iMax = Math.max(0, Math.min(this.t - ((i2 - 1) / 2), i - i2));
        for (int i3 = iMax; i3 < i && i3 < iMax + i2; i3++) {
            cVar.a(i3, 0);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final RecyclerView.p generateDefaultLayoutParams() {
        return new d(-2, -2);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final RecyclerView.p generateLayoutParams(Context context, AttributeSet attributeSet) {
        return new d(context, attributeSet);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getColumnCountForAccessibility(RecyclerView.w wVar, RecyclerView.ac acVar) {
        am amVar;
        return (this.d != 1 || (amVar = this.al) == null) ? super.getColumnCountForAccessibility(wVar, acVar) : amVar.e;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getDecoratedBottom(View view) {
        return super.getDecoratedBottom(view) - ((d) view.getLayoutParams()).j;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void getDecoratedBoundsWithMargins(View view, Rect rect) {
        super.getDecoratedBoundsWithMargins(view, rect);
        d dVar = (d) view.getLayoutParams();
        rect.left += dVar.e;
        rect.top += dVar.f;
        rect.right -= dVar.i;
        rect.bottom -= dVar.j;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getDecoratedLeft(View view) {
        return super.getDecoratedLeft(view) + ((d) view.getLayoutParams()).e;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getDecoratedRight(View view) {
        return super.getDecoratedRight(view) - ((d) view.getLayoutParams()).i;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getDecoratedTop(View view) {
        return super.getDecoratedTop(view) + ((d) view.getLayoutParams()).f;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int getRowCountForAccessibility(RecyclerView.w wVar, RecyclerView.ac acVar) {
        am amVar;
        return (this.d != 0 || (amVar = this.al) == null) ? super.getRowCountForAccessibility(wVar, acVar) : amVar.e;
    }

    public final void n() {
        this.al.b((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? (-this.aq) - this.k : this.ap + this.aq + this.k, false);
    }

    public final void o() {
        ArrayList arrayList;
        if (this.q != null || ((arrayList = this.r) != null && arrayList.size() > 0)) {
            int i = this.t;
            View viewFindViewByPosition = i == -1 ? null : findViewByPosition(i);
            if (viewFindViewByPosition != null) {
                RecyclerView.ag childViewHolder = this.c.getChildViewHolder(viewFindViewByPosition);
                zu6 zu6Var = this.q;
                if (zu6Var != null) {
                    if (childViewHolder != null) {
                        childViewHolder.getItemId();
                    }
                    zu6Var.a(viewFindViewByPosition);
                }
                m mVar = this.c;
                int i2 = this.t;
                int i3 = this.u;
                ArrayList arrayList2 = this.r;
                if (arrayList2 != null) {
                    for (int size = arrayList2.size() - 1; size >= 0; size--) {
                        ((av6) this.r.get(size)).a(mVar, childViewHolder, i2, i3);
                    }
                }
            } else {
                zu6 zu6Var2 = this.q;
                if (zu6Var2 != null) {
                    zu6Var2.a(null);
                }
                m mVar2 = this.c;
                ArrayList arrayList3 = this.r;
                if (arrayList3 != null) {
                    for (int size2 = arrayList3.size() - 1; size2 >= 0; size2--) {
                        ((av6) this.r.get(size2)).a(mVar2, null, -1, 0);
                    }
                }
            }
            if ((this.p & 3) == 1 || this.c.isLayoutRequested()) {
                return;
            }
            int childCount = getChildCount();
            for (int i4 = 0; i4 < childCount; i4++) {
                if (getChildAt(i4).isLayoutRequested()) {
                    m mVar3 = this.c;
                    WeakHashMap weakHashMap = sia.a;
                    mVar3.postOnAnimation(this.au);
                    return;
                }
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onAdapterChanged(RecyclerView.g gVar, RecyclerView.g gVar2) {
        if (gVar != null) {
            this.al = null;
            this.ac = null;
            this.p &= -1025;
            this.t = -1;
            this.x = 0;
            ol5 ol5Var = this.as.c;
            if (ol5Var != null) {
                ol5Var.evictAll();
            }
        }
        if (gVar2 instanceof iv2) {
            this.at = (iv2) gVar2;
        } else {
            this.at = null;
        }
        super.onAdapterChanged(gVar, gVar2);
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0053  */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0055  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x005b  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x007a A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0083  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x008f  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x009b  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00ab  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x00b1  */
    /* JADX WARN: Removed duplicated region for block: B:64:0x00b4  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x00b6  */
    @Override // androidx.recyclerview.widget.RecyclerView.o
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onAddFocusables(RecyclerView recyclerView, ArrayList arrayList, int i, int i2) {
        int i3;
        int iQ;
        View viewFindViewByPosition;
        char c2;
        char c3;
        int i4;
        int childCount;
        boolean z;
        char c4;
        char c5;
        m mVar;
        View viewFindContainingItemView;
        boolean z2 = true;
        if ((this.p & 32768) == 0) {
            if (!recyclerView.hasFocus()) {
                int size = arrayList.size();
                if (this.am != 0) {
                    u0.a aVar = this.an.c;
                    int i5 = aVar.j;
                    int i6 = ((aVar.i - i5) - aVar.k) + i5;
                    int childCount2 = getChildCount();
                    for (int i7 = 0; i7 < childCount2; i7++) {
                        View childAt = getChildAt(i7);
                        if (childAt.getVisibility() == 0 && this.e.g(childAt) >= i5 && this.e.d(childAt) <= i6) {
                            childAt.addFocusables(arrayList, i, i2);
                        }
                    }
                    if (arrayList.size() == size) {
                        int childCount3 = getChildCount();
                        for (int i8 = 0; i8 < childCount3; i8++) {
                            View childAt2 = getChildAt(i8);
                            if (childAt2.getVisibility() == 0) {
                                childAt2.addFocusables(arrayList, i, i2);
                            }
                        }
                    }
                } else {
                    View viewFindViewByPosition2 = findViewByPosition(this.t);
                    if (viewFindViewByPosition2 != null) {
                        viewFindViewByPosition2.addFocusables(arrayList, i, i2);
                    }
                }
                if (arrayList.size() != size || !recyclerView.isFocusable()) {
                    return true;
                }
                arrayList.add(recyclerView);
                return true;
            }
            if (this.w == null) {
                int iT = t(i);
                View viewFindFocus = recyclerView.findFocus();
                if (viewFindFocus == null || (mVar = this.c) == null || viewFindFocus == mVar || (viewFindContainingItemView = findContainingItemView(viewFindFocus)) == null) {
                    i3 = -1;
                    iQ = q(getChildAt(i3));
                    viewFindViewByPosition = iQ != -1 ? null : findViewByPosition(iQ);
                    if (viewFindViewByPosition != null) {
                        viewFindViewByPosition.addFocusables(arrayList, i, i2);
                    }
                    if (this.al != null && getChildCount() != 0) {
                        c2 = 2;
                        c3 = 3;
                        if ((iT == 3 && iT != 2) || this.al.e > 1) {
                            am amVar = this.al;
                            int i9 = (amVar == null || viewFindViewByPosition == null) ? -1 : amVar.k(iQ).a;
                            int size2 = arrayList.size();
                            i4 = (iT != 1 || iT == 3) ? 1 : -1;
                            int childCount4 = i4 <= 0 ? getChildCount() - 1 : 0;
                            childCount = i3 != -1 ? i4 > 0 ? 0 : getChildCount() - 1 : i3 + i4;
                            while (true) {
                                if (i4 > 0) {
                                    if (childCount < childCount4) {
                                        break;
                                    }
                                } else {
                                    if (childCount > childCount4) {
                                        break;
                                    }
                                    View childAt3 = getChildAt(childCount);
                                    if (childAt3.getVisibility() != 0 || !childAt3.hasFocusable()) {
                                        z = z2;
                                        c4 = c2;
                                        c5 = c3;
                                    } else if (viewFindViewByPosition == null) {
                                        childAt3.addFocusables(arrayList, i, i2);
                                        if (arrayList.size() > size2) {
                                            break;
                                        }
                                        z = z2;
                                        c4 = c2;
                                        c5 = c3;
                                    } else {
                                        int iQ2 = q(getChildAt(childCount));
                                        am.a aVarK = this.al.k(iQ2);
                                        if (aVarK == null) {
                                            z = z2;
                                            c4 = 2;
                                            c5 = 3;
                                        } else {
                                            int i10 = aVarK.a;
                                            if (iT == z2) {
                                                if (i10 == i9 && iQ2 > iQ) {
                                                    childAt3.addFocusables(arrayList, i, i2);
                                                    if (arrayList.size() > size2) {
                                                        break;
                                                    }
                                                }
                                                z = z2;
                                                c4 = 2;
                                                c5 = 3;
                                            } else if (iT == 0) {
                                                if (i10 == i9 && iQ2 < iQ) {
                                                    childAt3.addFocusables(arrayList, i, i2);
                                                    if (arrayList.size() > size2) {
                                                        break;
                                                    }
                                                }
                                                z = z2;
                                                c4 = 2;
                                                c5 = 3;
                                            } else {
                                                c5 = 3;
                                                if (iT == 3) {
                                                    if (i10 != i9) {
                                                        if (i10 < i9) {
                                                            break;
                                                        }
                                                        childAt3.addFocusables(arrayList, i, i2);
                                                    }
                                                    z = z2;
                                                    c4 = 2;
                                                } else {
                                                    z = z2;
                                                    c4 = 2;
                                                    if (iT == 2 && i10 != i9) {
                                                        if (i10 > i9) {
                                                            return z;
                                                        }
                                                        childAt3.addFocusables(arrayList, i, i2);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    childCount += i4;
                                    c3 = c5;
                                    c2 = c4;
                                    z2 = z;
                                }
                            }
                        }
                    }
                } else {
                    int childCount5 = getChildCount();
                    i3 = 0;
                    while (i3 < childCount5) {
                        if (getChildAt(i3) == viewFindContainingItemView) {
                            break;
                        }
                        i3++;
                    }
                    i3 = -1;
                    iQ = q(getChildAt(i3));
                    if (iQ != -1) {
                    }
                    if (viewFindViewByPosition != null) {
                    }
                    if (this.al != null) {
                        c2 = 2;
                        c3 = 3;
                        if (iT == 3) {
                            am amVar2 = this.al;
                            if (amVar2 == null) {
                                int size22 = arrayList.size();
                                if (iT != 1) {
                                    if (i4 <= 0) {
                                    }
                                    childCount = i3 != -1 ? i4 > 0 ? 0 : getChildCount() - 1 : i3 + i4;
                                    while (true) {
                                        if (i4 > 0) {
                                        }
                                        childCount += i4;
                                        c3 = c5;
                                        c2 = c4;
                                        z2 = z;
                                    }
                                }
                            }
                        } else {
                            am amVar22 = this.al;
                            if (amVar22 == null) {
                            }
                        }
                    }
                }
            }
        }
        return z2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onInitializeAccessibilityNodeInfo(RecyclerView.w wVar, RecyclerView.ac acVar, i3 i3Var) {
        am(wVar, acVar);
        int iB = acVar.b();
        int i = this.p;
        boolean z = (262144 & i) != 0;
        if ((i & 2048) == 0 || (iB > 1 && !ac(0))) {
            if (this.d == 0) {
                i3Var.b(z ? i3.a.p : i3.a.n);
            } else {
                i3Var.b(i3.a.m);
            }
            i3Var.m(true);
        }
        if ((this.p & 4096) == 0 || (iB > 1 && !ac(iB - 1))) {
            if (this.d == 0) {
                i3Var.b(z ? i3.a.n : i3.a.p);
            } else {
                i3Var.b(i3.a.o);
            }
            i3Var.m(true);
        }
        i3Var.j(i3.g.a(getRowCountForAccessibility(wVar, acVar), getColumnCountForAccessibility(wVar, acVar), getSelectionModeForAccessibility(wVar, acVar), isLayoutHierarchical(wVar, acVar)));
        i3Var.i(GridView.class.getName());
        ae();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onInitializeAccessibilityNodeInfoForItem(RecyclerView.w wVar, RecyclerView.ac acVar, View view, i3 i3Var) {
        am.a aVarK;
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (this.al == null || !(layoutParams instanceof d)) {
            return;
        }
        int absoluteAdapterPosition = ((d) layoutParams).a.getAbsoluteAdapterPosition();
        int i = -1;
        if (absoluteAdapterPosition >= 0 && (aVarK = this.al.k(absoluteAdapterPosition)) != null) {
            i = aVarK.a;
        }
        int i2 = i;
        if (i2 < 0) {
            return;
        }
        int i3 = absoluteAdapterPosition / this.al.e;
        if (this.d == 0) {
            i3Var.k(i3.h.a(i2, 1, i3, 1, false, false));
        } else {
            i3Var.k(i3.h.a(i3, 1, i2, 1, false, false));
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final View onInterceptFocusSearch(View view, int i) {
        View viewFindNextFocus;
        View viewFindNextFocus2;
        if ((this.p & 32768) != 0) {
            return view;
        }
        FocusFinder focusFinder = FocusFinder.getInstance();
        if (i == 2 || i == 1) {
            if (canScrollVertically()) {
                viewFindNextFocus = focusFinder.findNextFocus(this.c, view, i == 2 ? TsExtractor.TS_STREAM_TYPE_HDMV_DTS : 33);
            } else {
                viewFindNextFocus = null;
            }
            if (canScrollHorizontally()) {
                viewFindNextFocus2 = focusFinder.findNextFocus(this.c, view, (getLayoutDirection() == 1) ^ (i == 2) ? 66 : 17);
            } else {
                viewFindNextFocus2 = viewFindNextFocus;
            }
        } else {
            viewFindNextFocus2 = focusFinder.findNextFocus(this.c, view, i);
        }
        if (viewFindNextFocus2 != null) {
            return viewFindNextFocus2;
        }
        if (this.c.getDescendantFocusability() == 393216) {
            return this.c.getParent().focusSearch(view, i);
        }
        int iT = t(i);
        boolean z = this.c.getScrollState() != 0;
        if (iT == 1) {
            if (z || (this.p & 4096) == 0) {
                viewFindNextFocus2 = view;
            }
            if ((this.p & 131072) != 0 && !ab()) {
                ah(true);
                viewFindNextFocus2 = view;
            }
        } else if (iT == 0) {
            if (z || (this.p & 2048) == 0) {
                viewFindNextFocus2 = view;
            }
            if ((this.p & 131072) != 0 && getItemCount() != 0 && this.c.findViewHolderForAdapterPosition(0) == null) {
                ah(false);
                viewFindNextFocus2 = view;
            }
        } else if (iT == 3) {
        }
        if (viewFindNextFocus2 != null) {
            return viewFindNextFocus2;
        }
        View viewFocusSearch = this.c.getParent().focusSearch(view, i);
        return viewFocusSearch != null ? viewFocusSearch : view != null ? view : this.c;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onItemsAdded(RecyclerView recyclerView, int i, int i2) {
        am amVar;
        int i3;
        int i4 = this.t;
        if (i4 != -1 && (amVar = this.al) != null && amVar.f >= 0 && (i3 = this.x) != Integer.MIN_VALUE && i <= i4 + i3) {
            this.x = i3 + i2;
        }
        ol5 ol5Var = this.as.c;
        if (ol5Var != null) {
            ol5Var.evictAll();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onItemsChanged(RecyclerView recyclerView) {
        this.x = 0;
        ol5 ol5Var = this.as.c;
        if (ol5Var != null) {
            ol5Var.evictAll();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onItemsMoved(RecyclerView recyclerView, int i, int i2, int i3) {
        int i4;
        int i5 = this.t;
        if (i5 != -1 && (i4 = this.x) != Integer.MIN_VALUE) {
            int i6 = i5 + i4;
            if (i <= i6 && i6 < i + i3) {
                this.x = (i2 - i) + i4;
            } else if (i < i6 && i2 > i6 - i3) {
                this.x = i4 - i3;
            } else if (i > i6 && i2 < i6) {
                this.x = i4 + i3;
            }
        }
        ol5 ol5Var = this.as.c;
        if (ol5Var != null) {
            ol5Var.evictAll();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onItemsRemoved(RecyclerView recyclerView, int i, int i2) {
        am amVar;
        int i3;
        int i4;
        int i5 = this.t;
        if (i5 != -1 && (amVar = this.al) != null && amVar.f >= 0 && (i3 = this.x) != Integer.MIN_VALUE && i <= (i4 = i5 + i3)) {
            if (i + i2 > i4) {
                this.t = (i - i4) + i3 + i5;
                this.x = Integer.MIN_VALUE;
            } else {
                this.x = i3 - i2;
            }
        }
        ol5 ol5Var = this.as.c;
        if (ol5Var != null) {
            ol5Var.evictAll();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onItemsUpdated(RecyclerView recyclerView, int i, int i2) {
        int i3 = i2 + i;
        while (i < i3) {
            t0 t0Var = this.as;
            ol5 ol5Var = t0Var.c;
            if (ol5Var != null && ol5Var.size() != 0) {
                t0Var.c.remove(Integer.toString(i));
            }
            i++;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:125:0x02bb A[LOOP:3: B:124:0x02b9->B:125:0x02bb, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:128:0x02d3  */
    /* JADX WARN: Removed duplicated region for block: B:134:0x02e8 A[LOOP:11: B:134:0x02e8->B:336:?, LOOP_START] */
    /* JADX WARN: Removed duplicated region for block: B:152:0x033f  */
    /* JADX WARN: Removed duplicated region for block: B:167:0x03ee  */
    /* JADX WARN: Removed duplicated region for block: B:168:0x03f1  */
    /* JADX WARN: Removed duplicated region for block: B:178:0x0406 A[LOOP:12: B:178:0x0406->B:337:?, LOOP_START] */
    @Override // androidx.recyclerview.widget.RecyclerView.o
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onLayoutChildren(RecyclerView.w wVar, RecyclerView.ac acVar) {
        int i;
        int i2;
        int i3;
        int i4;
        boolean z;
        View view;
        int i5;
        boolean z2;
        am h0Var;
        int i6;
        int i7;
        List list;
        int size;
        am amVar;
        int i8;
        int i9;
        int i10;
        int i11;
        am.a aVarK;
        int i12;
        am.a aVarK2;
        if (this.aj != 0 && acVar.b() >= 0) {
            if ((this.p & 64) != 0 && getChildCount() > 0) {
                this.p |= 128;
                return;
            }
            int i13 = this.p;
            if ((i13 & 512) == 0) {
                this.al = null;
                this.ac = null;
                this.p = i13 & (-1025);
                removeAndRecycleAllViews(wVar);
                return;
            }
            this.p = (i13 & (-4)) | 1;
            am(wVar, acVar);
            int iMax = Integer.MIN_VALUE;
            if (acVar.g) {
                aw();
                int childCount = getChildCount();
                if (this.al != null && childCount > 0) {
                    int oldPosition = this.c.getChildViewHolder(getChildAt(0)).getOldPosition();
                    int oldPosition2 = this.c.getChildViewHolder(getChildAt(childCount - 1)).getOldPosition();
                    int iMin = Integer.MAX_VALUE;
                    for (int i14 = 0; i14 < childCount; i14++) {
                        View childAt = getChildAt(i14);
                        d dVar = (d) childAt.getLayoutParams();
                        int childAdapterPosition = this.c.getChildAdapterPosition(childAt);
                        if (dVar.a.isUpdated() || dVar.a.isRemoved() || childAt.isLayoutRequested() || ((!childAt.hasFocus() && this.t == dVar.a.getAbsoluteAdapterPosition()) || ((childAt.hasFocus() && this.t != dVar.a.getAbsoluteAdapterPosition()) || childAdapterPosition < oldPosition || childAdapterPosition > oldPosition2))) {
                            iMin = Math.min(iMin, this.e.g(childAt));
                            iMax = Math.max(iMax, this.e.d(childAt));
                        }
                    }
                    if (iMax > iMin) {
                        this.k = iMax - iMin;
                    }
                    n();
                    ag();
                }
                this.p &= -4;
                ae();
                return;
            }
            boolean z3 = acVar.k;
            SparseIntArray sparseIntArray = this.l;
            if (z3) {
                sparseIntArray.clear();
                int childCount2 = getChildCount();
                for (int i15 = 0; i15 < childCount2; i15++) {
                    int oldPosition3 = this.c.getChildViewHolder(getChildAt(i15)).getOldPosition();
                    if (oldPosition3 >= 0 && (aVarK2 = this.al.k(oldPosition3)) != null) {
                        sparseIntArray.put(oldPosition3, aVarK2.a);
                    }
                }
            }
            boolean z4 = !isSmoothScrolling() && this.am == 0;
            int i16 = this.t;
            if (i16 != -1 && (i12 = this.x) != Integer.MIN_VALUE) {
                this.t = i16 + i12;
                this.u = 0;
            }
            this.x = 0;
            View viewFindViewByPosition = findViewByPosition(this.t);
            int i17 = this.t;
            int i18 = this.u;
            boolean zHasFocus = this.c.hasFocus();
            am amVar2 = this.al;
            int i19 = amVar2 != null ? amVar2.f : -1;
            int i20 = amVar2 != null ? amVar2.g : -1;
            if (this.d == 0) {
                i2 = acVar.o;
                i = acVar.p;
            } else {
                i = acVar.o;
                i2 = acVar.p;
            }
            int i21 = i2;
            int i22 = i;
            int i23 = i21;
            int iB = this.i.b();
            if (iB == 0) {
                this.t = -1;
                this.u = 0;
                i3 = 1;
            } else {
                i3 = 1;
                int i24 = this.t;
                if (i24 >= iB) {
                    this.t = iB - 1;
                    this.u = 0;
                } else if (i24 == -1 && iB > 0) {
                    this.t = 0;
                    this.u = 0;
                }
            }
            boolean z5 = this.i.f;
            u0 u0Var = this.an;
            if (z5 || (amVar = this.al) == null || amVar.f < 0 || (this.p & 256) != 0 || amVar.e != this.aj) {
                i4 = i23;
                z = z4;
                view = viewFindViewByPosition;
                i5 = i18;
                z2 = zHasFocus;
                int i25 = this.p;
                this.p = i25 & (-257);
                am amVar3 = this.al;
                if (amVar3 == null || this.aj != amVar3.e) {
                    int i26 = this.aj;
                    int i27 = i3;
                    if (i26 == i27) {
                        h0Var = new h0();
                    } else {
                        j0 j0Var = new j0();
                        e01 e01Var = new e01();
                        int iHighestOneBit = Integer.bitCount(64) != i27 ? Integer.highestOneBit(63) << i27 : 64;
                        e01Var.d = iHighestOneBit - 1;
                        e01Var.a = new Object[iHighestOneBit];
                        j0Var.j = e01Var;
                        j0Var.k = -1;
                        j0Var.n(i26);
                        h0Var = j0Var;
                    }
                    this.al = h0Var;
                    h0Var.b = this.av;
                    h0Var.c = (this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0;
                    u0.a aVar = u0Var.c;
                    u0.a aVar2 = u0Var.a;
                    u0.a aVar3 = u0Var.b;
                    aVar.b = Integer.MIN_VALUE;
                    aVar.a = Integer.MAX_VALUE;
                    aVar3.i = getWidth();
                    aVar2.i = getHeight();
                    int paddingLeft = getPaddingLeft();
                    int paddingRight = getPaddingRight();
                    aVar3.j = paddingLeft;
                    aVar3.k = paddingRight;
                    int paddingTop = getPaddingTop();
                    int paddingBottom = getPaddingBottom();
                    aVar2.j = paddingTop;
                    aVar2.k = paddingBottom;
                    this.ap = u0Var.c.i;
                    this.z = 0;
                    az();
                    this.al.d = this.ag;
                    detachAndScrapAttachedViews(this.o);
                    am amVar4 = this.al;
                    amVar4.g = -1;
                    amVar4.f = -1;
                    u0.a aVar4 = u0Var.c;
                    aVar4.b = Integer.MIN_VALUE;
                    aVar4.d = Integer.MIN_VALUE;
                    aVar4.a = Integer.MAX_VALUE;
                    aVar4.c = Integer.MAX_VALUE;
                    int i28 = this.p;
                    this.p = i28 & (-5);
                    this.p = (i28 & (-21)) | (!z ? 16 : 0);
                    if (z && (i19 < 0 || (i6 = this.t) > i20 || i6 < i19)) {
                        i19 = this.t;
                        i20 = i19;
                    }
                    amVar4.i = i19;
                    if (i20 != -1) {
                        while (this.al.a() && findViewByPosition(i20) == null) {
                        }
                    }
                } else {
                    if (((i25 & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0 ? i3 : 0) != amVar3.c) {
                    }
                    u0.a aVar5 = u0Var.c;
                    u0.a aVar22 = u0Var.a;
                    u0.a aVar32 = u0Var.b;
                    aVar5.b = Integer.MIN_VALUE;
                    aVar5.a = Integer.MAX_VALUE;
                    aVar32.i = getWidth();
                    aVar22.i = getHeight();
                    int paddingLeft2 = getPaddingLeft();
                    int paddingRight2 = getPaddingRight();
                    aVar32.j = paddingLeft2;
                    aVar32.k = paddingRight2;
                    int paddingTop2 = getPaddingTop();
                    int paddingBottom2 = getPaddingBottom();
                    aVar22.j = paddingTop2;
                    aVar22.k = paddingBottom2;
                    this.ap = u0Var.c.i;
                    this.z = 0;
                    az();
                    this.al.d = this.ag;
                    detachAndScrapAttachedViews(this.o);
                    am amVar42 = this.al;
                    amVar42.g = -1;
                    amVar42.f = -1;
                    u0.a aVar42 = u0Var.c;
                    aVar42.b = Integer.MIN_VALUE;
                    aVar42.d = Integer.MIN_VALUE;
                    aVar42.a = Integer.MAX_VALUE;
                    aVar42.c = Integer.MAX_VALUE;
                    int i282 = this.p;
                    this.p = i282 & (-5);
                    this.p = (i282 & (-21)) | (!z ? 16 : 0);
                    if (z) {
                        i19 = this.t;
                        i20 = i19;
                    }
                    amVar42.i = i19;
                    if (i20 != -1) {
                    }
                }
            } else {
                u0.a aVar6 = u0Var.b;
                u0.a aVar7 = u0Var.a;
                aVar6.i = getWidth();
                aVar7.i = getHeight();
                u0.a aVar8 = u0Var.b;
                int paddingLeft3 = getPaddingLeft();
                int paddingRight3 = getPaddingRight();
                aVar8.j = paddingLeft3;
                aVar8.k = paddingRight3;
                int paddingTop3 = getPaddingTop();
                int paddingBottom3 = getPaddingBottom();
                aVar7.j = paddingTop3;
                aVar7.k = paddingBottom3;
                this.ap = u0Var.c.i;
                az();
                am amVar5 = this.al;
                amVar5.d = this.ag;
                this.p |= 4;
                amVar5.i = this.t;
                int childCount3 = getChildCount();
                int i29 = this.al.f;
                this.p &= -9;
                int i30 = 0;
                while (i30 < childCount3) {
                    View childAt2 = getChildAt(i30);
                    if (i29 == q(childAt2) && (aVarK = this.al.k(i29)) != null) {
                        int i31 = i23;
                        int iV = (v(aVarK.a) + u0Var.d.j) - this.z;
                        int iG = this.e.g(childAt2);
                        Rect rect = aw;
                        getDecoratedBoundsWithMargins(childAt2, rect);
                        int iWidth = this.d == 0 ? rect.width() : rect.height();
                        if (((d) childAt2.getLayoutParams()).a.needsUpdate()) {
                            this.p |= 8;
                            detachAndScrapView(childAt2, this.o);
                            childAt2 = aa(i29);
                            addView(childAt2, i30);
                        }
                        af(childAt2);
                        int iS = this.d == 0 ? s(childAt2) : r(childAt2);
                        boolean z6 = zHasFocus;
                        i9 = i29;
                        z2 = z6;
                        view = viewFindViewByPosition;
                        i8 = childCount3;
                        i5 = i18;
                        i4 = i31;
                        int i32 = iS;
                        z = z4;
                        i10 = i30;
                        ad(childAt2, aVarK.a, iG, iG + iS, iV);
                        if (iWidth != i32) {
                            int i33 = this.al.g;
                            for (i11 = i8 - 1; i11 >= i10; i11--) {
                                detachAndScrapView(getChildAt(i11), this.o);
                            }
                            this.al.l(i9);
                            if ((this.p & 65536) == 0) {
                                n();
                                int i34 = this.t;
                                if (i34 >= 0 && i34 <= i33) {
                                    while (true) {
                                        am amVar6 = this.al;
                                        if (amVar6.g >= this.t) {
                                            break;
                                        } else {
                                            amVar6.a();
                                        }
                                    }
                                }
                            } else {
                                while (this.al.a() && this.al.g < i33) {
                                }
                            }
                            ay();
                            az();
                        } else {
                            i30 = i10 + 1;
                            i29 = i9 + 1;
                            i23 = i4;
                            z4 = z;
                            zHasFocus = z2;
                            viewFindViewByPosition = view;
                            childCount3 = i8;
                            i18 = i5;
                        }
                    } else {
                        i8 = childCount3;
                        z = z4;
                        view = viewFindViewByPosition;
                        i5 = i18;
                        z2 = zHasFocus;
                        i9 = i29;
                        i4 = i23;
                        i10 = i30;
                        int i332 = this.al.g;
                        while (i11 >= i10) {
                        }
                        this.al.l(i9);
                        if ((this.p & 65536) == 0) {
                        }
                        ay();
                        az();
                    }
                }
                i4 = i23;
                z = z4;
                view = viewFindViewByPosition;
                i5 = i18;
                z2 = zHasFocus;
                ay();
                az();
            }
            while (true) {
                ay();
                am amVar7 = this.al;
                int i35 = amVar7.f;
                int i36 = amVar7.g;
                int i37 = -i4;
                int i38 = -i22;
                View viewFindViewByPosition2 = findViewByPosition(this.t);
                if (viewFindViewByPosition2 != null && z) {
                    aq(viewFindViewByPosition2, viewFindViewByPosition2.findFocus(), false, i37, i38);
                }
                if (viewFindViewByPosition2 != null && z2 && !viewFindViewByPosition2.hasFocus()) {
                    viewFindViewByPosition2.requestFocus();
                } else if (!z2 && !this.c.hasFocus()) {
                    if (viewFindViewByPosition2 == null || !viewFindViewByPosition2.hasFocusable()) {
                        int childCount4 = getChildCount();
                        int i39 = 0;
                        while (true) {
                            if (i39 >= childCount4) {
                                break;
                            }
                            viewFindViewByPosition2 = getChildAt(i39);
                            if (viewFindViewByPosition2 != null && viewFindViewByPosition2.hasFocusable()) {
                                this.c.focusableViewAvailable(viewFindViewByPosition2);
                                break;
                            }
                            i39++;
                        }
                    } else {
                        this.c.focusableViewAvailable(viewFindViewByPosition2);
                    }
                    if (z && viewFindViewByPosition2 != null && viewFindViewByPosition2.hasFocus()) {
                        aq(viewFindViewByPosition2, viewFindViewByPosition2.findFocus(), false, i37, i38);
                    }
                }
                n();
                ag();
                am amVar8 = this.al;
                if (amVar8.f == i35 && amVar8.g == i36) {
                    break;
                }
            }
            al();
            ak();
            if (acVar.k && (size = (list = this.o.d).size()) != 0) {
                int[] iArr = this.m;
                if (iArr == null || size > iArr.length) {
                    int length = iArr == null ? 16 : iArr.length;
                    while (length < size) {
                        length <<= 1;
                    }
                    this.m = new int[length];
                }
                int i40 = 0;
                for (int i41 = 0; i41 < size; i41++) {
                    int absoluteAdapterPosition = ((RecyclerView.ag) list.get(i41)).getAbsoluteAdapterPosition();
                    if (absoluteAdapterPosition >= 0) {
                        this.m[i40] = absoluteAdapterPosition;
                        i40++;
                    }
                }
                if (i40 > 0) {
                    Arrays.sort(this.m, 0, i40);
                    am amVar9 = this.al;
                    int[] iArr2 = this.m;
                    Object[] objArr = amVar9.a;
                    int i42 = amVar9.g;
                    int iBinarySearch = i42 >= 0 ? Arrays.binarySearch(iArr2, 0, i40, i42) : 0;
                    if (iBinarySearch < 0) {
                        int iD = amVar9.c ? (amVar9.b.d(i42) - amVar9.b.e(i42)) - amVar9.d : amVar9.b.d(i42) + amVar9.b.e(i42) + amVar9.d;
                        for (int i43 = (-iBinarySearch) - 1; i43 < i40; i43++) {
                            int i44 = iArr2[i43];
                            int i45 = sparseIntArray.get(i44);
                            int i46 = i45 < 0 ? 0 : i45;
                            int iB2 = amVar9.b.b(i44, true, objArr, true);
                            amVar9.b.a(objArr[0], i44, iB2, i46, iD);
                            iD = amVar9.c ? (iD - iB2) - amVar9.d : iD + iB2 + amVar9.d;
                        }
                    }
                    int i47 = amVar9.f;
                    int iBinarySearch2 = i47 >= 0 ? Arrays.binarySearch(iArr2, 0, i40, i47) : 0;
                    if (iBinarySearch2 < 0) {
                        int i48 = (-iBinarySearch2) - 2;
                        int iD2 = amVar9.c ? amVar9.b.d(i47) : amVar9.b.d(i47);
                        while (i48 >= 0) {
                            int i49 = iArr2[i48];
                            int i50 = sparseIntArray.get(i49);
                            int i51 = i50 < 0 ? 0 : i50;
                            int iB3 = amVar9.b.b(i49, false, objArr, true);
                            int i52 = amVar9.c ? iD2 + amVar9.d + iB3 : (iD2 - amVar9.d) - iB3;
                            amVar9.b.a(objArr[0], i49, iB3, i51, i52);
                            i48--;
                            iD2 = i52;
                        }
                    }
                }
                sparseIntArray.clear();
            }
            int i53 = this.p;
            if ((i53 & 1024) != 0) {
                this.p = i53 & (-1025);
            } else {
                ax();
            }
            if (((this.p & 4) != 0 && ((i7 = this.t) != i17 || this.u != i5 || findViewByPosition(i7) != view || (this.p & 8) != 0)) || (this.p & 20) == 16) {
                o();
            }
            p();
            if ((this.p & 64) != 0) {
                an(y());
            }
            this.p &= -4;
            ae();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onLayoutCompleted(RecyclerView.ac acVar) {
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onMeasure(RecyclerView.w wVar, RecyclerView.ac acVar, int i, int i2) {
        int size;
        int size2;
        int mode;
        int paddingLeft;
        int paddingRight;
        int iX;
        am(wVar, acVar);
        if (this.d == 0) {
            size2 = View.MeasureSpec.getSize(i);
            size = View.MeasureSpec.getSize(i2);
            mode = View.MeasureSpec.getMode(i2);
            paddingLeft = getPaddingTop();
            paddingRight = getPaddingBottom();
        } else {
            size = View.MeasureSpec.getSize(i);
            size2 = View.MeasureSpec.getSize(i2);
            mode = View.MeasureSpec.getMode(i);
            paddingLeft = getPaddingLeft();
            paddingRight = getPaddingRight();
        }
        int i3 = paddingRight + paddingLeft;
        this.ad = size;
        int i4 = this.aa;
        if (i4 == -2) {
            int i5 = this.ak;
            if (i5 == 0) {
                i5 = 1;
            }
            this.aj = i5;
            this.ab = 0;
            int[] iArr = this.ac;
            if (iArr == null || iArr.length != i5) {
                this.ac = new int[i5];
            }
            if (this.i.g) {
                aw();
            }
            ai(true);
            if (mode == Integer.MIN_VALUE) {
                size = Math.min(x() + i3, this.ad);
            } else if (mode == 0) {
                iX = x();
                size = iX + i3;
            } else {
                if (mode != 1073741824) {
                    throw new IllegalStateException("wrong spec");
                }
                size = this.ad;
            }
        } else {
            if (mode != Integer.MIN_VALUE) {
                if (mode == 0) {
                    if (i4 == 0) {
                        i4 = size - i3;
                    }
                    this.ab = i4;
                    int i6 = this.ak;
                    if (i6 == 0) {
                        i6 = 1;
                    }
                    this.aj = i6;
                    iX = ((i6 - 1) * this.ah) + (i4 * i6);
                    size = iX + i3;
                } else if (mode != 1073741824) {
                    throw new IllegalStateException("wrong spec");
                }
            }
            int i7 = this.ak;
            if (i7 == 0 && i4 == 0) {
                this.aj = 1;
                this.ab = size - i3;
            } else if (i7 == 0) {
                this.ab = i4;
                int i8 = this.ah;
                this.aj = (size + i8) / (i4 + i8);
            } else if (i4 == 0) {
                this.aj = i7;
                this.ab = ((size - i3) - ((i7 - 1) * this.ah)) / i7;
            } else {
                this.aj = i7;
                this.ab = i4;
            }
            if (mode == Integer.MIN_VALUE) {
                int i9 = this.ab;
                int i10 = this.aj;
                int i11 = ((i10 - 1) * this.ah) + (i9 * i10) + i3;
                if (i11 < size) {
                    size = i11;
                }
            }
        }
        if (this.d == 0) {
            setMeasuredDimension(size2, size);
        } else {
            setMeasuredDimension(size, size2);
        }
        ae();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean onRequestChildFocus(RecyclerView recyclerView, RecyclerView.ac acVar, View view, View view2) {
        if ((this.p & 32768) == 0 && q(view) != -1 && (this.p & 35) == 0) {
            aq(view, view2, true, 0, 0);
        }
        return true;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof f) {
            f fVar = (f) parcelable;
            this.t = fVar.a;
            this.x = 0;
            Bundle bundle = fVar.b;
            t0 t0Var = this.as;
            ol5 ol5Var = t0Var.c;
            if (ol5Var != null && bundle != null) {
                ol5Var.evictAll();
                for (String str : bundle.keySet()) {
                    t0Var.c.put(str, bundle.getSparseParcelableArray(str));
                }
            }
            this.p |= 256;
            requestLayout();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final Parcelable onSaveInstanceState() {
        Bundle bundle;
        f fVar = new f();
        fVar.b = Bundle.EMPTY;
        fVar.a = this.t;
        t0 t0Var = this.as;
        ol5 ol5Var = t0Var.c;
        if (ol5Var == null || ol5Var.size() == 0) {
            bundle = null;
        } else {
            Map mapSnapshot = t0Var.c.snapshot();
            bundle = new Bundle();
            for (Map.Entry entry : mapSnapshot.entrySet()) {
                bundle.putSparseParcelableArray((String) entry.getKey(), (SparseArray) entry.getValue());
            }
        }
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = getChildAt(i);
            int iQ = q(childAt);
            if (iQ != -1 && t0Var.a != 0) {
                String string = Integer.toString(iQ);
                SparseArray<Parcelable> sparseArray = new SparseArray<>();
                childAt.saveHierarchyState(sparseArray);
                if (bundle == null) {
                    bundle = new Bundle();
                }
                bundle.putSparseParcelableArray(string, sparseArray);
            }
        }
        fVar.b = bundle;
        return fVar;
    }

    public final void p() {
        ArrayList arrayList = this.r;
        if (arrayList == null || arrayList.size() <= 0) {
            return;
        }
        int i = this.t;
        View viewFindViewByPosition = i == -1 ? null : findViewByPosition(i);
        if (viewFindViewByPosition != null) {
            RecyclerView.ag childViewHolder = this.c.getChildViewHolder(viewFindViewByPosition);
            int i2 = this.t;
            ArrayList arrayList2 = this.r;
            if (arrayList2 == null) {
                return;
            }
            for (int size = arrayList2.size() - 1; size >= 0; size--) {
                ((av6) this.r.get(size)).b(childViewHolder, i2);
            }
            return;
        }
        zu6 zu6Var = this.q;
        if (zu6Var != null) {
            zu6Var.a(null);
        }
        ArrayList arrayList3 = this.r;
        if (arrayList3 == null) {
            return;
        }
        for (int size2 = arrayList3.size() - 1; size2 >= 0; size2--) {
            ((av6) this.r.get(size2)).b(null, -1);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x003c  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0046  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x004f  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x005b  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0075  */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // androidx.recyclerview.widget.RecyclerView.o
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean performAccessibilityAction(RecyclerView.w wVar, RecyclerView.ac acVar, int i, Bundle bundle) {
        boolean z;
        if ((this.p & 131072) != 0) {
            am(wVar, acVar);
            boolean z2 = (this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0;
            if (this.d == 0) {
                if (i == i3.a.n.a()) {
                    i = z2 ? 4096 : 8192;
                } else if (i == i3.a.p.a()) {
                    if (z2) {
                    }
                }
                int i2 = this.t;
                z = i2 != 0 && i == 8192;
                boolean z3 = i2 != acVar.b() - 1 && i == 4096;
                if (!z || z3) {
                    AccessibilityEvent accessibilityEventObtain = AccessibilityEvent.obtain(4096);
                    this.c.onInitializeAccessibilityEvent(accessibilityEventObtain);
                    m mVar = this.c;
                    mVar.requestSendAccessibilityEvent(mVar, accessibilityEventObtain);
                } else if (i == 4096) {
                    ah(true);
                    aj(1, false);
                } else if (i == 8192) {
                    ah(false);
                    aj(-1, false);
                }
                ae();
            } else {
                if (i != i3.a.m.a()) {
                    if (i == i3.a.o.a()) {
                    }
                }
                int i22 = this.t;
                if (i22 != 0) {
                    if (i22 != acVar.b() - 1) {
                        if (z) {
                            AccessibilityEvent accessibilityEventObtain2 = AccessibilityEvent.obtain(4096);
                            this.c.onInitializeAccessibilityEvent(accessibilityEventObtain2);
                            m mVar2 = this.c;
                            mVar2.requestSendAccessibilityEvent(mVar2, accessibilityEventObtain2);
                            ae();
                        }
                    }
                }
            }
        }
        return true;
    }

    public final int r(View view) {
        d dVar = (d) view.getLayoutParams();
        return getDecoratedMeasuredHeight(view) + ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void removeAndRecycleAllViews(RecyclerView.w wVar) {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            removeAndRecycleViewAt(childCount, wVar);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean requestChildRectangleOnScreen(RecyclerView recyclerView, View view, Rect rect, boolean z) {
        return false;
    }

    public final int s(View view) {
        d dVar = (d) view.getLayoutParams();
        return getDecoratedMeasuredWidth(view) + ((ViewGroup.MarginLayoutParams) dVar).leftMargin + ((ViewGroup.MarginLayoutParams) dVar).rightMargin;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int scrollHorizontallyBy(int i, RecyclerView.w wVar, RecyclerView.ac acVar) {
        if ((this.p & 512) == 0 || this.al == null) {
            return 0;
        }
        am(wVar, acVar);
        this.p = (this.p & (-4)) | 2;
        int iAn = this.d == 0 ? an(i) : ao(i);
        ae();
        this.p &= -4;
        return iAn;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void scrollToPosition(int i) {
        at(i, false);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final int scrollVerticallyBy(int i, RecyclerView.w wVar, RecyclerView.ac acVar) {
        int i2 = this.p;
        if ((i2 & 512) == 0 || this.al == null) {
            return 0;
        }
        this.p = (i2 & (-4)) | 2;
        am(wVar, acVar);
        int iAn = this.d == 1 ? an(i) : ao(i);
        ae();
        this.p &= -4;
        return iAn;
    }

    public final void setOrientation(int i) {
        if (i == 0 || i == 1) {
            this.d = i;
            this.e = androidx.recyclerview.widget.ak.b(this, i);
            u0 u0Var = this.an;
            u0.a aVar = u0Var.a;
            u0.a aVar2 = u0Var.b;
            if (i == 0) {
                u0Var.c = aVar2;
                u0Var.d = aVar;
            } else {
                u0Var.c = aVar;
                u0Var.d = aVar2;
            }
            bf bfVar = this.ao;
            bfVar.getClass();
            if (i == 0) {
                bfVar.c = bfVar.b;
            } else {
                bfVar.c = bfVar.a;
            }
            this.p |= 256;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.ac acVar, int i) {
        at(i, true);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final void startSmoothScroll(RecyclerView.ab abVar) {
        c cVar = this.v;
        if (cVar != null) {
            cVar.a = true;
        }
        super.startSmoothScroll(abVar);
        if (!abVar.isRunning() || !(abVar instanceof c)) {
            this.v = null;
            this.w = null;
            return;
        }
        c cVar2 = (c) abVar;
        this.v = cVar2;
        if (cVar2 instanceof e) {
            this.w = (e) cVar2;
        } else {
            this.w = null;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final boolean supportsPredictiveItemAnimations() {
        return true;
    }

    public final int t(int i) {
        int i2 = this.d;
        if (i2 != 0) {
            if (i2 == 1) {
                if (i == 17) {
                    return (this.p & 524288) == 0 ? 2 : 3;
                }
                if (i == 33) {
                    return 0;
                }
                if (i == 66) {
                    return (this.p & 524288) == 0 ? 3 : 2;
                }
                if (i == 130) {
                    return 1;
                }
            }
        }
        if (i != 17) {
            if (i == 33) {
                return 2;
            }
            if (i != 66) {
                return i != 130 ? 17 : 3;
            }
            if ((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0) {
                return 0;
            }
        } else if ((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) == 0) {
            return 0;
        }
        return 1;
    }

    public final int u(int i) {
        int i2 = this.ab;
        if (i2 != 0) {
            return i2;
        }
        int[] iArr = this.ac;
        if (iArr == null) {
            return 0;
        }
        return iArr[i];
    }

    public final int v(int i) {
        int iU = 0;
        if ((this.p & 524288) != 0) {
            for (int i2 = this.aj - 1; i2 > i; i2--) {
                iU += u(i2) + this.ah;
            }
            return iU;
        }
        int iU2 = 0;
        while (iU < i) {
            iU2 += u(iU) + this.ah;
            iU++;
        }
        return iU2;
    }

    /* JADX WARN: Removed duplicated region for block: B:73:0x0159  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x015b  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x0162  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0176  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean w(View view, View view2, int[] iArr) {
        View viewFindViewByPosition;
        int i;
        int iD;
        int left;
        int i2;
        int iB;
        int top;
        int i3;
        int left2;
        int i4;
        int iZ;
        int i5 = this.am;
        u0 u0Var = this.an;
        if (i5 != 1 && i5 != 2) {
            u0.a aVar = u0Var.c;
            if (this.d == 0) {
                d dVar = (d) view.getLayoutParams();
                dVar.getClass();
                top = view.getLeft() + dVar.e;
                i3 = dVar.k;
            } else {
                d dVar2 = (d) view.getLayoutParams();
                dVar2.getClass();
                top = view.getTop() + dVar2.f;
                i3 = dVar2.l;
            }
            int iB2 = aVar.b(top + i3);
            if (view2 != null && (iZ = z(view, view2)) != 0) {
                int[] iArr2 = ((d) view.getLayoutParams()).m;
                iB2 += iArr2[iZ] - iArr2[0];
            }
            if (this.d == 0) {
                d dVar3 = (d) view.getLayoutParams();
                dVar3.getClass();
                left2 = view.getTop() + dVar3.f;
                i4 = dVar3.l;
            } else {
                d dVar4 = (d) view.getLayoutParams();
                dVar4.getClass();
                left2 = view.getLeft() + dVar4.e;
                i4 = dVar4.k;
            }
            int iB3 = u0Var.d.b(left2 + i4);
            if (iB2 == 0 && iB3 == 0) {
                iArr[0] = 0;
                iArr[1] = 0;
                return false;
            }
            iArr[0] = iB2;
            iArr[1] = iB3;
            return true;
        }
        int iQ = q(view);
        int iG = this.e.g(view);
        int iD2 = this.e.d(view);
        u0.a aVar2 = u0Var.c;
        int i6 = aVar2.j;
        int i7 = (aVar2.i - i6) - aVar2.k;
        am.a aVarK = this.al.k(iQ);
        int i8 = aVarK == null ? -1 : aVarK.a;
        View viewFindViewByPosition2 = null;
        if (iG < i6) {
            if (this.am == 2) {
                View view3 = view;
                while (true) {
                    am amVar = this.al;
                    if (!amVar.m(amVar.c ? Integer.MIN_VALUE : Integer.MAX_VALUE, true)) {
                        viewFindViewByPosition = null;
                        viewFindViewByPosition2 = view3;
                        break;
                    }
                    am amVar2 = this.al;
                    g01 g01Var = amVar2.j(amVar2.f, iQ)[i8];
                    View viewFindViewByPosition3 = findViewByPosition(g01Var.b(0));
                    if (iD2 - this.e.g(viewFindViewByPosition3) <= i7) {
                        view3 = viewFindViewByPosition3;
                    } else if (g01Var.c() > 2) {
                        viewFindViewByPosition = null;
                        viewFindViewByPosition2 = findViewByPosition(g01Var.b(2));
                    } else {
                        viewFindViewByPosition = null;
                        viewFindViewByPosition2 = viewFindViewByPosition3;
                    }
                }
            } else {
                viewFindViewByPosition = null;
                viewFindViewByPosition2 = view;
            }
        } else if (iD2 <= i7 + i6) {
            viewFindViewByPosition = null;
        } else if (this.am == 2) {
            while (true) {
                am amVar3 = this.al;
                g01 g01Var2 = amVar3.j(iQ, amVar3.g)[i8];
                viewFindViewByPosition = findViewByPosition(g01Var2.b(g01Var2.c() - 1));
                if (this.e.d(viewFindViewByPosition) - iG > i7) {
                    viewFindViewByPosition = null;
                    break;
                }
                if (!this.al.a()) {
                    break;
                }
            }
            if (viewFindViewByPosition == null) {
                viewFindViewByPosition2 = view;
            }
        } else {
            viewFindViewByPosition = view;
        }
        if (viewFindViewByPosition2 != null) {
            iD = this.e.g(viewFindViewByPosition2);
        } else {
            if (viewFindViewByPosition == null) {
                i = 0;
                if (viewFindViewByPosition2 == null) {
                    view = viewFindViewByPosition2;
                } else if (viewFindViewByPosition != null) {
                    view = viewFindViewByPosition;
                }
                if (this.d != 0) {
                    d dVar5 = (d) view.getLayoutParams();
                    dVar5.getClass();
                    left = view.getTop() + dVar5.f;
                    i2 = dVar5.l;
                } else {
                    d dVar6 = (d) view.getLayoutParams();
                    dVar6.getClass();
                    left = view.getLeft() + dVar6.e;
                    i2 = dVar6.k;
                }
                iB = u0Var.d.b(left + i2);
                if (i != 0 && iB == 0) {
                    return false;
                }
                iArr[0] = i;
                iArr[1] = iB;
                return true;
            }
            iD = this.e.d(viewFindViewByPosition);
            i6 += i7;
        }
        i = iD - i6;
        if (viewFindViewByPosition2 == null) {
        }
        if (this.d != 0) {
        }
        iB = u0Var.d.b(left + i2);
        if (i != 0) {
        }
        iArr[0] = i;
        iArr[1] = iB;
        return true;
    }

    public final int x() {
        int i = (this.p & 524288) != 0 ? 0 : this.aj - 1;
        return u(i) + v(i);
    }

    public final int y() {
        int left;
        int right;
        int top;
        if (this.d == 1) {
            int i = -getHeight();
            return (getChildCount() <= 0 || (top = getChildAt(0).getTop()) >= 0) ? i : i + top;
        }
        if ((this.p & MediaUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES) != 0) {
            int width = getWidth();
            return (getChildCount() <= 0 || (right = getChildAt(0).getRight()) <= width) ? width : right;
        }
        int i2 = -getWidth();
        return (getChildCount() <= 0 || (left = getChildAt(0).getLeft()) >= 0) ? i2 : i2 + left;
    }

    public GridLayoutManager(m mVar) {
        this.a = 1.0f;
        this.b = 10;
        this.d = 0;
        this.e = androidx.recyclerview.widget.ak.a(this);
        this.l = new SparseIntArray();
        this.p = 221696;
        this.q = null;
        this.r = null;
        this.s = null;
        this.t = -1;
        this.u = 0;
        this.x = 0;
        this.ai = 8388659;
        this.ak = 1;
        this.am = 0;
        this.an = new u0();
        this.ao = new bf();
        this.ar = new int[2];
        t0 t0Var = new t0();
        t0Var.a = 0;
        t0Var.b = 100;
        this.as = t0Var;
        this.au = new a();
        this.av = new b();
        this.c = mVar;
        this.y = -1;
        setItemPrefetchEnabled(false);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.o
    public final RecyclerView.p generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof d) {
            return new d((d) layoutParams);
        }
        if (layoutParams instanceof RecyclerView.p) {
            return new d((RecyclerView.p) layoutParams);
        }
        if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
            return new d((ViewGroup.MarginLayoutParams) layoutParams);
        }
        return new d(layoutParams);
    }
}
