package androidx.recyclerview.widget; import android.content.Context; import android.graphics.PointF; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.view.View; import android.view.accessibility.AccessibilityEvent; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.common.api.Api; import java.util.List; /* loaded from: classes.dex */ public class LinearLayoutManager extends RecyclerView.o implements RecyclerView.z.b { int A; int B; private boolean C; d D; final a E; private final b F; private int G; private int[] H; /* renamed from: s, reason: collision with root package name */ int f2179s; /* renamed from: t, reason: collision with root package name */ private c f2180t; /* renamed from: u, reason: collision with root package name */ j f2181u; /* renamed from: v, reason: collision with root package name */ private boolean f2182v; /* renamed from: w, reason: collision with root package name */ private boolean f2183w; /* renamed from: x, reason: collision with root package name */ boolean f2184x; /* renamed from: y, reason: collision with root package name */ private boolean f2185y; /* renamed from: z, reason: collision with root package name */ private boolean f2186z; static class a { /* renamed from: a, reason: collision with root package name */ j f2187a; /* renamed from: b, reason: collision with root package name */ int f2188b; /* renamed from: c, reason: collision with root package name */ int f2189c; /* renamed from: d, reason: collision with root package name */ boolean f2190d; /* renamed from: e, reason: collision with root package name */ boolean f2191e; a() { e(); } void a() { this.f2189c = this.f2190d ? this.f2187a.i() : this.f2187a.m(); } public void b(View view, int i10) { if (this.f2190d) { this.f2189c = this.f2187a.d(view) + this.f2187a.o(); } else { this.f2189c = this.f2187a.g(view); } this.f2188b = i10; } public void c(View view, int i10) { int o10 = this.f2187a.o(); if (o10 >= 0) { b(view, i10); return; } this.f2188b = i10; if (this.f2190d) { int i11 = (this.f2187a.i() - o10) - this.f2187a.d(view); this.f2189c = this.f2187a.i() - i11; if (i11 > 0) { int e10 = this.f2189c - this.f2187a.e(view); int m10 = this.f2187a.m(); int min = e10 - (m10 + Math.min(this.f2187a.g(view) - m10, 0)); if (min < 0) { this.f2189c += Math.min(i11, -min); return; } return; } return; } int g10 = this.f2187a.g(view); int m11 = g10 - this.f2187a.m(); this.f2189c = g10; if (m11 > 0) { int i12 = (this.f2187a.i() - Math.min(0, (this.f2187a.i() - o10) - this.f2187a.d(view))) - (g10 + this.f2187a.e(view)); if (i12 < 0) { this.f2189c -= Math.min(m11, -i12); } } } boolean d(View view, RecyclerView.a0 a0Var) { RecyclerView.p pVar = (RecyclerView.p) view.getLayoutParams(); return !pVar.c() && pVar.a() >= 0 && pVar.a() < a0Var.b(); } void e() { this.f2188b = -1; this.f2189c = RecyclerView.UNDEFINED_DURATION; this.f2190d = false; this.f2191e = false; } public String toString() { return "AnchorInfo{mPosition=" + this.f2188b + ", mCoordinate=" + this.f2189c + ", mLayoutFromEnd=" + this.f2190d + ", mValid=" + this.f2191e + '}'; } } protected static class b { /* renamed from: a, reason: collision with root package name */ public int f2192a; /* renamed from: b, reason: collision with root package name */ public boolean f2193b; /* renamed from: c, reason: collision with root package name */ public boolean f2194c; /* renamed from: d, reason: collision with root package name */ public boolean f2195d; protected b() { } void a() { this.f2192a = 0; this.f2193b = false; this.f2194c = false; this.f2195d = false; } } static class c { /* renamed from: b, reason: collision with root package name */ int f2197b; /* renamed from: c, reason: collision with root package name */ int f2198c; /* renamed from: d, reason: collision with root package name */ int f2199d; /* renamed from: e, reason: collision with root package name */ int f2200e; /* renamed from: f, reason: collision with root package name */ int f2201f; /* renamed from: g, reason: collision with root package name */ int f2202g; /* renamed from: k, reason: collision with root package name */ int f2206k; /* renamed from: m, reason: collision with root package name */ boolean f2208m; /* renamed from: a, reason: collision with root package name */ boolean f2196a = true; /* renamed from: h, reason: collision with root package name */ int f2203h = 0; /* renamed from: i, reason: collision with root package name */ int f2204i = 0; /* renamed from: j, reason: collision with root package name */ boolean f2205j = false; /* renamed from: l, reason: collision with root package name */ List f2207l = null; c() { } private View e() { int size = this.f2207l.size(); for (int i10 = 0; i10 < size; i10++) { View view = ((RecyclerView.d0) this.f2207l.get(i10)).f2240a; RecyclerView.p pVar = (RecyclerView.p) view.getLayoutParams(); if (!pVar.c() && this.f2199d == pVar.a()) { b(view); return view; } } return null; } public void a() { b(null); } public void b(View view) { View f10 = f(view); if (f10 == null) { this.f2199d = -1; } else { this.f2199d = ((RecyclerView.p) f10.getLayoutParams()).a(); } } boolean c(RecyclerView.a0 a0Var) { int i10 = this.f2199d; return i10 >= 0 && i10 < a0Var.b(); } View d(RecyclerView.v vVar) { if (this.f2207l != null) { return e(); } View o10 = vVar.o(this.f2199d); this.f2199d += this.f2200e; return o10; } public View f(View view) { int a10; int size = this.f2207l.size(); View view2 = null; int i10 = Api.BaseClientBuilder.API_PRIORITY_OTHER; for (int i11 = 0; i11 < size; i11++) { View view3 = ((RecyclerView.d0) this.f2207l.get(i11)).f2240a; RecyclerView.p pVar = (RecyclerView.p) view3.getLayoutParams(); if (view3 != view && !pVar.c() && (a10 = (pVar.a() - this.f2199d) * this.f2200e) >= 0 && a10 < i10) { view2 = view3; if (a10 == 0) { break; } i10 = a10; } } return view2; } } public static class d implements Parcelable { public static final Parcelable.Creator CREATOR = new a(); /* renamed from: a, reason: collision with root package name */ int f2209a; /* renamed from: b, reason: collision with root package name */ int f2210b; /* renamed from: c, reason: collision with root package name */ boolean f2211c; static class a implements Parcelable.Creator { a() { } @Override // android.os.Parcelable.Creator /* renamed from: a, reason: merged with bridge method [inline-methods] */ public d createFromParcel(Parcel parcel) { return new d(parcel); } @Override // android.os.Parcelable.Creator /* renamed from: b, reason: merged with bridge method [inline-methods] */ public d[] newArray(int i10) { return new d[i10]; } } public d() { } boolean a() { return this.f2209a >= 0; } void b() { this.f2209a = -1; } @Override // android.os.Parcelable public int describeContents() { return 0; } @Override // android.os.Parcelable public void writeToParcel(Parcel parcel, int i10) { parcel.writeInt(this.f2209a); parcel.writeInt(this.f2210b); parcel.writeInt(this.f2211c ? 1 : 0); } d(Parcel parcel) { this.f2209a = parcel.readInt(); this.f2210b = parcel.readInt(); this.f2211c = parcel.readInt() == 1; } public d(d dVar) { this.f2209a = dVar.f2209a; this.f2210b = dVar.f2210b; this.f2211c = dVar.f2211c; } } public LinearLayoutManager(Context context, int i10, boolean z10) { this.f2179s = 1; this.f2183w = false; this.f2184x = false; this.f2185y = false; this.f2186z = true; this.A = -1; this.B = RecyclerView.UNDEFINED_DURATION; this.D = null; this.E = new a(); this.F = new b(); this.G = 2; this.H = new int[2]; C2(i10); D2(z10); } private void A2() { if (this.f2179s == 1 || !q2()) { this.f2184x = this.f2183w; } else { this.f2184x = !this.f2183w; } } private boolean F2(RecyclerView.v vVar, RecyclerView.a0 a0Var, a aVar) { if (J() == 0) { return false; } View V = V(); if (V != null && aVar.d(V, a0Var)) { aVar.c(V, h0(V)); return true; } if (this.f2182v != this.f2185y) { return false; } View i22 = aVar.f2190d ? i2(vVar, a0Var) : j2(vVar, a0Var); if (i22 == null) { return false; } aVar.b(i22, h0(i22)); if (!a0Var.e() && L1()) { if (this.f2181u.g(i22) >= this.f2181u.i() || this.f2181u.d(i22) < this.f2181u.m()) { aVar.f2189c = aVar.f2190d ? this.f2181u.i() : this.f2181u.m(); } } return true; } private boolean G2(RecyclerView.a0 a0Var, a aVar) { int i10; if (!a0Var.e() && (i10 = this.A) != -1) { if (i10 >= 0 && i10 < a0Var.b()) { aVar.f2188b = this.A; d dVar = this.D; if (dVar != null && dVar.a()) { boolean z10 = this.D.f2211c; aVar.f2190d = z10; if (z10) { aVar.f2189c = this.f2181u.i() - this.D.f2210b; } else { aVar.f2189c = this.f2181u.m() + this.D.f2210b; } return true; } if (this.B != Integer.MIN_VALUE) { boolean z11 = this.f2184x; aVar.f2190d = z11; if (z11) { aVar.f2189c = this.f2181u.i() - this.B; } else { aVar.f2189c = this.f2181u.m() + this.B; } return true; } View C = C(this.A); if (C == null) { if (J() > 0) { aVar.f2190d = (this.A < h0(I(0))) == this.f2184x; } aVar.a(); } else { if (this.f2181u.e(C) > this.f2181u.n()) { aVar.a(); return true; } if (this.f2181u.g(C) - this.f2181u.m() < 0) { aVar.f2189c = this.f2181u.m(); aVar.f2190d = false; return true; } if (this.f2181u.i() - this.f2181u.d(C) < 0) { aVar.f2189c = this.f2181u.i(); aVar.f2190d = true; return true; } aVar.f2189c = aVar.f2190d ? this.f2181u.d(C) + this.f2181u.o() : this.f2181u.g(C); } return true; } this.A = -1; this.B = RecyclerView.UNDEFINED_DURATION; } return false; } private void H2(RecyclerView.v vVar, RecyclerView.a0 a0Var, a aVar) { if (G2(a0Var, aVar) || F2(vVar, a0Var, aVar)) { return; } aVar.a(); aVar.f2188b = this.f2185y ? a0Var.b() - 1 : 0; } private void I2(int i10, int i11, boolean z10, RecyclerView.a0 a0Var) { int m10; this.f2180t.f2208m = z2(); this.f2180t.f2201f = i10; int[] iArr = this.H; iArr[0] = 0; iArr[1] = 0; M1(a0Var, iArr); int max = Math.max(0, this.H[0]); int max2 = Math.max(0, this.H[1]); boolean z11 = i10 == 1; c cVar = this.f2180t; int i12 = z11 ? max2 : max; cVar.f2203h = i12; if (!z11) { max = max2; } cVar.f2204i = max; if (z11) { cVar.f2203h = i12 + this.f2181u.j(); View m22 = m2(); c cVar2 = this.f2180t; cVar2.f2200e = this.f2184x ? -1 : 1; int h02 = h0(m22); c cVar3 = this.f2180t; cVar2.f2199d = h02 + cVar3.f2200e; cVar3.f2197b = this.f2181u.d(m22); m10 = this.f2181u.d(m22) - this.f2181u.i(); } else { View n22 = n2(); this.f2180t.f2203h += this.f2181u.m(); c cVar4 = this.f2180t; cVar4.f2200e = this.f2184x ? 1 : -1; int h03 = h0(n22); c cVar5 = this.f2180t; cVar4.f2199d = h03 + cVar5.f2200e; cVar5.f2197b = this.f2181u.g(n22); m10 = (-this.f2181u.g(n22)) + this.f2181u.m(); } c cVar6 = this.f2180t; cVar6.f2198c = i11; if (z10) { cVar6.f2198c = i11 - m10; } cVar6.f2202g = m10; } private void J2(int i10, int i11) { this.f2180t.f2198c = this.f2181u.i() - i11; c cVar = this.f2180t; cVar.f2200e = this.f2184x ? -1 : 1; cVar.f2199d = i10; cVar.f2201f = 1; cVar.f2197b = i11; cVar.f2202g = RecyclerView.UNDEFINED_DURATION; } private void K2(a aVar) { J2(aVar.f2188b, aVar.f2189c); } private void L2(int i10, int i11) { this.f2180t.f2198c = i11 - this.f2181u.m(); c cVar = this.f2180t; cVar.f2199d = i10; cVar.f2200e = this.f2184x ? 1 : -1; cVar.f2201f = -1; cVar.f2197b = i11; cVar.f2202g = RecyclerView.UNDEFINED_DURATION; } private void M2(a aVar) { L2(aVar.f2188b, aVar.f2189c); } private int O1(RecyclerView.a0 a0Var) { if (J() == 0) { return 0; } T1(); return m.a(a0Var, this.f2181u, Y1(!this.f2186z, true), X1(!this.f2186z, true), this, this.f2186z); } private int P1(RecyclerView.a0 a0Var) { if (J() == 0) { return 0; } T1(); return m.b(a0Var, this.f2181u, Y1(!this.f2186z, true), X1(!this.f2186z, true), this, this.f2186z, this.f2184x); } private int Q1(RecyclerView.a0 a0Var) { if (J() == 0) { return 0; } T1(); return m.c(a0Var, this.f2181u, Y1(!this.f2186z, true), X1(!this.f2186z, true), this, this.f2186z); } private View V1() { return d2(0, J()); } private View W1(RecyclerView.v vVar, RecyclerView.a0 a0Var) { return h2(vVar, a0Var, 0, J(), a0Var.b()); } private View a2() { return d2(J() - 1, -1); } private View b2(RecyclerView.v vVar, RecyclerView.a0 a0Var) { return h2(vVar, a0Var, J() - 1, -1, a0Var.b()); } private View f2() { return this.f2184x ? V1() : a2(); } private View g2() { return this.f2184x ? a2() : V1(); } private View i2(RecyclerView.v vVar, RecyclerView.a0 a0Var) { return this.f2184x ? W1(vVar, a0Var) : b2(vVar, a0Var); } private View j2(RecyclerView.v vVar, RecyclerView.a0 a0Var) { return this.f2184x ? b2(vVar, a0Var) : W1(vVar, a0Var); } private int k2(int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var, boolean z10) { int i11; int i12 = this.f2181u.i() - i10; if (i12 <= 0) { return 0; } int i13 = -B2(-i12, vVar, a0Var); int i14 = i10 + i13; if (!z10 || (i11 = this.f2181u.i() - i14) <= 0) { return i13; } this.f2181u.r(i11); return i11 + i13; } private int l2(int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var, boolean z10) { int m10; int m11 = i10 - this.f2181u.m(); if (m11 <= 0) { return 0; } int i11 = -B2(m11, vVar, a0Var); int i12 = i10 + i11; if (!z10 || (m10 = i12 - this.f2181u.m()) <= 0) { return i11; } this.f2181u.r(-m10); return i11 - m10; } private View m2() { return I(this.f2184x ? 0 : J() - 1); } private View n2() { return I(this.f2184x ? J() - 1 : 0); } private void t2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i10, int i11) { if (!a0Var.g() || J() == 0 || a0Var.e() || !L1()) { return; } List k10 = vVar.k(); int size = k10.size(); int h02 = h0(I(0)); int i12 = 0; int i13 = 0; for (int i14 = 0; i14 < size; i14++) { RecyclerView.d0 d0Var = (RecyclerView.d0) k10.get(i14); if (!d0Var.v()) { if (((d0Var.m() < h02) != this.f2184x ? (char) 65535 : (char) 1) == 65535) { i12 += this.f2181u.e(d0Var.f2240a); } else { i13 += this.f2181u.e(d0Var.f2240a); } } } this.f2180t.f2207l = k10; if (i12 > 0) { L2(h0(n2()), i10); c cVar = this.f2180t; cVar.f2203h = i12; cVar.f2198c = 0; cVar.a(); U1(vVar, this.f2180t, a0Var, false); } if (i13 > 0) { J2(h0(m2()), i11); c cVar2 = this.f2180t; cVar2.f2203h = i13; cVar2.f2198c = 0; cVar2.a(); U1(vVar, this.f2180t, a0Var, false); } this.f2180t.f2207l = null; } private void v2(RecyclerView.v vVar, c cVar) { if (!cVar.f2196a || cVar.f2208m) { return; } int i10 = cVar.f2202g; int i11 = cVar.f2204i; if (cVar.f2201f == -1) { x2(vVar, i10, i11); } else { y2(vVar, i10, i11); } } private void w2(RecyclerView.v vVar, int i10, int i11) { if (i10 == i11) { return; } if (i11 <= i10) { while (i10 > i11) { n1(i10, vVar); i10--; } } else { for (int i12 = i11 - 1; i12 >= i10; i12--) { n1(i12, vVar); } } } private void x2(RecyclerView.v vVar, int i10, int i11) { int J = J(); if (i10 < 0) { return; } int h10 = (this.f2181u.h() - i10) + i11; if (this.f2184x) { for (int i12 = 0; i12 < J; i12++) { View I = I(i12); if (this.f2181u.g(I) < h10 || this.f2181u.q(I) < h10) { w2(vVar, 0, i12); return; } } return; } int i13 = J - 1; for (int i14 = i13; i14 >= 0; i14--) { View I2 = I(i14); if (this.f2181u.g(I2) < h10 || this.f2181u.q(I2) < h10) { w2(vVar, i13, i14); return; } } } private void y2(RecyclerView.v vVar, int i10, int i11) { if (i10 < 0) { return; } int i12 = i10 - i11; int J = J(); if (!this.f2184x) { for (int i13 = 0; i13 < J; i13++) { View I = I(i13); if (this.f2181u.d(I) > i12 || this.f2181u.p(I) > i12) { w2(vVar, 0, i13); return; } } return; } int i14 = J - 1; for (int i15 = i14; i15 >= 0; i15--) { View I2 = I(i15); if (this.f2181u.d(I2) > i12 || this.f2181u.p(I2) > i12) { w2(vVar, i14, i15); return; } } } int B2(int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var) { if (J() == 0 || i10 == 0) { return 0; } T1(); this.f2180t.f2196a = true; int i11 = i10 > 0 ? 1 : -1; int abs = Math.abs(i10); I2(i11, abs, true, a0Var); c cVar = this.f2180t; int U1 = cVar.f2202g + U1(vVar, cVar, a0Var, false); if (U1 < 0) { return 0; } if (abs > U1) { i10 = i11 * U1; } this.f2181u.r(-i10); this.f2180t.f2206k = i10; return i10; } @Override // androidx.recyclerview.widget.RecyclerView.o public View C(int i10) { int J = J(); if (J == 0) { return null; } int h02 = i10 - h0(I(0)); if (h02 >= 0 && h02 < J) { View I = I(h02); if (h0(I) == i10) { return I; } } return super.C(i10); } public void C2(int i10) { if (i10 != 0 && i10 != 1) { throw new IllegalArgumentException("invalid orientation:" + i10); } g(null); if (i10 != this.f2179s || this.f2181u == null) { j b10 = j.b(this, i10); this.f2181u = b10; this.E.f2187a = b10; this.f2179s = i10; t1(); } } @Override // androidx.recyclerview.widget.RecyclerView.o public RecyclerView.p D() { return new RecyclerView.p(-2, -2); } public void D2(boolean z10) { g(null); if (z10 == this.f2183w) { return; } this.f2183w = z10; t1(); } public void E2(boolean z10) { g(null); if (this.f2185y == z10) { return; } this.f2185y = z10; t1(); } @Override // androidx.recyclerview.widget.RecyclerView.o boolean G1() { return (X() == 1073741824 || p0() == 1073741824 || !q0()) ? false : true; } @Override // androidx.recyclerview.widget.RecyclerView.o public void I0(RecyclerView recyclerView, RecyclerView.v vVar) { super.I0(recyclerView, vVar); if (this.C) { k1(vVar); vVar.c(); } } @Override // androidx.recyclerview.widget.RecyclerView.o public void I1(RecyclerView recyclerView, RecyclerView.a0 a0Var, int i10) { g gVar = new g(recyclerView.getContext()); gVar.p(i10); J1(gVar); } @Override // androidx.recyclerview.widget.RecyclerView.o public View J0(View view, int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var) { int R1; A2(); if (J() == 0 || (R1 = R1(i10)) == Integer.MIN_VALUE) { return null; } T1(); I2(R1, (int) (this.f2181u.n() * 0.33333334f), false, a0Var); c cVar = this.f2180t; cVar.f2202g = RecyclerView.UNDEFINED_DURATION; cVar.f2196a = false; U1(vVar, cVar, a0Var, true); View g22 = R1 == -1 ? g2() : f2(); View n22 = R1 == -1 ? n2() : m2(); if (!n22.hasFocusable()) { return g22; } if (g22 == null) { return null; } return n22; } @Override // androidx.recyclerview.widget.RecyclerView.o public void K0(AccessibilityEvent accessibilityEvent) { super.K0(accessibilityEvent); if (J() > 0) { accessibilityEvent.setFromIndex(Z1()); accessibilityEvent.setToIndex(c2()); } } @Override // androidx.recyclerview.widget.RecyclerView.o public boolean L1() { return this.D == null && this.f2182v == this.f2185y; } protected void M1(RecyclerView.a0 a0Var, int[] iArr) { int i10; int o22 = o2(a0Var); if (this.f2180t.f2201f == -1) { i10 = 0; } else { i10 = o22; o22 = 0; } iArr[0] = o22; iArr[1] = i10; } void N1(RecyclerView.a0 a0Var, c cVar, RecyclerView.o.c cVar2) { int i10 = cVar.f2199d; if (i10 < 0 || i10 >= a0Var.b()) { return; } cVar2.a(i10, Math.max(0, cVar.f2202g)); } int R1(int i10) { if (i10 == 1) { return (this.f2179s != 1 && q2()) ? 1 : -1; } if (i10 == 2) { return (this.f2179s != 1 && q2()) ? -1 : 1; } if (i10 == 17) { if (this.f2179s == 0) { return -1; } return RecyclerView.UNDEFINED_DURATION; } if (i10 == 33) { if (this.f2179s == 1) { return -1; } return RecyclerView.UNDEFINED_DURATION; } if (i10 == 66) { if (this.f2179s == 0) { return 1; } return RecyclerView.UNDEFINED_DURATION; } if (i10 != 130) { return RecyclerView.UNDEFINED_DURATION; } if (this.f2179s == 1) { return 1; } return RecyclerView.UNDEFINED_DURATION; } c S1() { return new c(); } void T1() { if (this.f2180t == null) { this.f2180t = S1(); } } int U1(RecyclerView.v vVar, c cVar, RecyclerView.a0 a0Var, boolean z10) { int i10 = cVar.f2198c; int i11 = cVar.f2202g; if (i11 != Integer.MIN_VALUE) { if (i10 < 0) { cVar.f2202g = i11 + i10; } v2(vVar, cVar); } int i12 = cVar.f2198c + cVar.f2203h; b bVar = this.F; while (true) { if ((!cVar.f2208m && i12 <= 0) || !cVar.c(a0Var)) { break; } bVar.a(); s2(vVar, a0Var, cVar, bVar); if (!bVar.f2193b) { cVar.f2197b += bVar.f2192a * cVar.f2201f; if (!bVar.f2194c || cVar.f2207l != null || !a0Var.e()) { int i13 = cVar.f2198c; int i14 = bVar.f2192a; cVar.f2198c = i13 - i14; i12 -= i14; } int i15 = cVar.f2202g; if (i15 != Integer.MIN_VALUE) { int i16 = i15 + bVar.f2192a; cVar.f2202g = i16; int i17 = cVar.f2198c; if (i17 < 0) { cVar.f2202g = i16 + i17; } v2(vVar, cVar); } if (z10 && bVar.f2195d) { break; } } else { break; } } return i10 - cVar.f2198c; } @Override // androidx.recyclerview.widget.RecyclerView.o public void X0(RecyclerView.v vVar, RecyclerView.a0 a0Var) { int i10; int i11; int i12; int i13; int k22; int i14; View C; int g10; int i15; int i16 = -1; if (!(this.D == null && this.A == -1) && a0Var.b() == 0) { k1(vVar); return; } d dVar = this.D; if (dVar != null && dVar.a()) { this.A = this.D.f2209a; } T1(); this.f2180t.f2196a = false; A2(); View V = V(); a aVar = this.E; if (!aVar.f2191e || this.A != -1 || this.D != null) { aVar.e(); a aVar2 = this.E; aVar2.f2190d = this.f2184x ^ this.f2185y; H2(vVar, a0Var, aVar2); this.E.f2191e = true; } else if (V != null && (this.f2181u.g(V) >= this.f2181u.i() || this.f2181u.d(V) <= this.f2181u.m())) { this.E.c(V, h0(V)); } c cVar = this.f2180t; cVar.f2201f = cVar.f2206k >= 0 ? 1 : -1; int[] iArr = this.H; iArr[0] = 0; iArr[1] = 0; M1(a0Var, iArr); int max = Math.max(0, this.H[0]) + this.f2181u.m(); int max2 = Math.max(0, this.H[1]) + this.f2181u.j(); if (a0Var.e() && (i14 = this.A) != -1 && this.B != Integer.MIN_VALUE && (C = C(i14)) != null) { if (this.f2184x) { i15 = this.f2181u.i() - this.f2181u.d(C); g10 = this.B; } else { g10 = this.f2181u.g(C) - this.f2181u.m(); i15 = this.B; } int i17 = i15 - g10; if (i17 > 0) { max += i17; } else { max2 -= i17; } } a aVar3 = this.E; if (!aVar3.f2190d ? !this.f2184x : this.f2184x) { i16 = 1; } u2(vVar, a0Var, aVar3, i16); w(vVar); this.f2180t.f2208m = z2(); this.f2180t.f2205j = a0Var.e(); this.f2180t.f2204i = 0; a aVar4 = this.E; if (aVar4.f2190d) { M2(aVar4); c cVar2 = this.f2180t; cVar2.f2203h = max; U1(vVar, cVar2, a0Var, false); c cVar3 = this.f2180t; i11 = cVar3.f2197b; int i18 = cVar3.f2199d; int i19 = cVar3.f2198c; if (i19 > 0) { max2 += i19; } K2(this.E); c cVar4 = this.f2180t; cVar4.f2203h = max2; cVar4.f2199d += cVar4.f2200e; U1(vVar, cVar4, a0Var, false); c cVar5 = this.f2180t; i10 = cVar5.f2197b; int i20 = cVar5.f2198c; if (i20 > 0) { L2(i18, i11); c cVar6 = this.f2180t; cVar6.f2203h = i20; U1(vVar, cVar6, a0Var, false); i11 = this.f2180t.f2197b; } } else { K2(aVar4); c cVar7 = this.f2180t; cVar7.f2203h = max2; U1(vVar, cVar7, a0Var, false); c cVar8 = this.f2180t; i10 = cVar8.f2197b; int i21 = cVar8.f2199d; int i22 = cVar8.f2198c; if (i22 > 0) { max += i22; } M2(this.E); c cVar9 = this.f2180t; cVar9.f2203h = max; cVar9.f2199d += cVar9.f2200e; U1(vVar, cVar9, a0Var, false); c cVar10 = this.f2180t; i11 = cVar10.f2197b; int i23 = cVar10.f2198c; if (i23 > 0) { J2(i21, i10); c cVar11 = this.f2180t; cVar11.f2203h = i23; U1(vVar, cVar11, a0Var, false); i10 = this.f2180t.f2197b; } } if (J() > 0) { if (this.f2184x ^ this.f2185y) { int k23 = k2(i10, vVar, a0Var, true); i12 = i11 + k23; i13 = i10 + k23; k22 = l2(i12, vVar, a0Var, false); } else { int l22 = l2(i11, vVar, a0Var, true); i12 = i11 + l22; i13 = i10 + l22; k22 = k2(i13, vVar, a0Var, false); } i11 = i12 + k22; i10 = i13 + k22; } t2(vVar, a0Var, i11, i10); if (a0Var.e()) { this.E.e(); } else { this.f2181u.s(); } this.f2182v = this.f2185y; } View X1(boolean z10, boolean z11) { return this.f2184x ? e2(0, J(), z10, z11) : e2(J() - 1, -1, z10, z11); } @Override // androidx.recyclerview.widget.RecyclerView.o public void Y0(RecyclerView.a0 a0Var) { super.Y0(a0Var); this.D = null; this.A = -1; this.B = RecyclerView.UNDEFINED_DURATION; this.E.e(); } View Y1(boolean z10, boolean z11) { return this.f2184x ? e2(J() - 1, -1, z10, z11) : e2(0, J(), z10, z11); } public int Z1() { View e22 = e2(0, J(), false, true); if (e22 == null) { return -1; } return h0(e22); } @Override // androidx.recyclerview.widget.RecyclerView.z.b public PointF a(int i10) { if (J() == 0) { return null; } int i11 = (i10 < h0(I(0))) != this.f2184x ? -1 : 1; return this.f2179s == 0 ? new PointF(i11, 0.0f) : new PointF(0.0f, i11); } @Override // androidx.recyclerview.widget.RecyclerView.o public void c1(Parcelable parcelable) { if (parcelable instanceof d) { this.D = (d) parcelable; t1(); } } public int c2() { View e22 = e2(J() - 1, -1, false, true); if (e22 == null) { return -1; } return h0(e22); } @Override // androidx.recyclerview.widget.RecyclerView.o public Parcelable d1() { if (this.D != null) { return new d(this.D); } d dVar = new d(); if (J() > 0) { T1(); boolean z10 = this.f2182v ^ this.f2184x; dVar.f2211c = z10; if (z10) { View m22 = m2(); dVar.f2210b = this.f2181u.i() - this.f2181u.d(m22); dVar.f2209a = h0(m22); } else { View n22 = n2(); dVar.f2209a = h0(n22); dVar.f2210b = this.f2181u.g(n22) - this.f2181u.m(); } } else { dVar.b(); } return dVar; } View d2(int i10, int i11) { int i12; int i13; T1(); if ((i11 > i10 ? (char) 1 : i11 < i10 ? (char) 65535 : (char) 0) == 0) { return I(i10); } if (this.f2181u.g(I(i10)) < this.f2181u.m()) { i12 = 16644; i13 = 16388; } else { i12 = 4161; i13 = 4097; } return this.f2179s == 0 ? this.f2277e.a(i10, i11, i12, i13) : this.f2278f.a(i10, i11, i12, i13); } View e2(int i10, int i11, boolean z10, boolean z11) { T1(); int i12 = z10 ? 24579 : 320; int i13 = z11 ? 320 : 0; return this.f2179s == 0 ? this.f2277e.a(i10, i11, i12, i13) : this.f2278f.a(i10, i11, i12, i13); } @Override // androidx.recyclerview.widget.RecyclerView.o public void g(String str) { if (this.D == null) { super.g(str); } } View h2(RecyclerView.v vVar, RecyclerView.a0 a0Var, int i10, int i11, int i12) { T1(); int m10 = this.f2181u.m(); int i13 = this.f2181u.i(); int i14 = i11 > i10 ? 1 : -1; View view = null; View view2 = null; while (i10 != i11) { View I = I(i10); int h02 = h0(I); if (h02 >= 0 && h02 < i12) { if (((RecyclerView.p) I.getLayoutParams()).c()) { if (view2 == null) { view2 = I; } } else { if (this.f2181u.g(I) < i13 && this.f2181u.d(I) >= m10) { return I; } if (view == null) { view = I; } } } i10 += i14; } return view != null ? view : view2; } @Override // androidx.recyclerview.widget.RecyclerView.o public boolean k() { return this.f2179s == 0; } @Override // androidx.recyclerview.widget.RecyclerView.o public boolean l() { return this.f2179s == 1; } @Override // androidx.recyclerview.widget.RecyclerView.o public void o(int i10, int i11, RecyclerView.a0 a0Var, RecyclerView.o.c cVar) { if (this.f2179s != 0) { i10 = i11; } if (J() == 0 || i10 == 0) { return; } T1(); I2(i10 > 0 ? 1 : -1, Math.abs(i10), true, a0Var); N1(a0Var, this.f2180t, cVar); } protected int o2(RecyclerView.a0 a0Var) { if (a0Var.d()) { return this.f2181u.n(); } return 0; } @Override // androidx.recyclerview.widget.RecyclerView.o public void p(int i10, RecyclerView.o.c cVar) { boolean z10; int i11; d dVar = this.D; if (dVar == null || !dVar.a()) { A2(); z10 = this.f2184x; i11 = this.A; if (i11 == -1) { i11 = z10 ? i10 - 1 : 0; } } else { d dVar2 = this.D; z10 = dVar2.f2211c; i11 = dVar2.f2209a; } int i12 = z10 ? -1 : 1; for (int i13 = 0; i13 < this.G && i11 >= 0 && i11 < i10; i13++) { cVar.a(i11, 0); i11 += i12; } } public int p2() { return this.f2179s; } @Override // androidx.recyclerview.widget.RecyclerView.o public int q(RecyclerView.a0 a0Var) { return O1(a0Var); } protected boolean q2() { return Z() == 1; } @Override // androidx.recyclerview.widget.RecyclerView.o public int r(RecyclerView.a0 a0Var) { return P1(a0Var); } public boolean r2() { return this.f2186z; } @Override // androidx.recyclerview.widget.RecyclerView.o public int s(RecyclerView.a0 a0Var) { return Q1(a0Var); } @Override // androidx.recyclerview.widget.RecyclerView.o public boolean s0() { return true; } void s2(RecyclerView.v vVar, RecyclerView.a0 a0Var, c cVar, b bVar) { int i10; int i11; int i12; int i13; int f10; View d10 = cVar.d(vVar); if (d10 == null) { bVar.f2193b = true; return; } RecyclerView.p pVar = (RecyclerView.p) d10.getLayoutParams(); if (cVar.f2207l == null) { if (this.f2184x == (cVar.f2201f == -1)) { d(d10); } else { e(d10, 0); } } else { if (this.f2184x == (cVar.f2201f == -1)) { b(d10); } else { c(d10, 0); } } A0(d10, 0, 0); bVar.f2192a = this.f2181u.e(d10); if (this.f2179s == 1) { if (q2()) { f10 = o0() - f0(); i13 = f10 - this.f2181u.f(d10); } else { i13 = e0(); f10 = this.f2181u.f(d10) + i13; } if (cVar.f2201f == -1) { int i14 = cVar.f2197b; i12 = i14; i11 = f10; i10 = i14 - bVar.f2192a; } else { int i15 = cVar.f2197b; i10 = i15; i11 = f10; i12 = bVar.f2192a + i15; } } else { int g02 = g0(); int f11 = this.f2181u.f(d10) + g02; if (cVar.f2201f == -1) { int i16 = cVar.f2197b; i11 = i16; i10 = g02; i12 = f11; i13 = i16 - bVar.f2192a; } else { int i17 = cVar.f2197b; i10 = g02; i11 = bVar.f2192a + i17; i12 = f11; i13 = i17; } } z0(d10, i13, i10, i11, i12); if (pVar.c() || pVar.b()) { bVar.f2194c = true; } bVar.f2195d = d10.hasFocusable(); } @Override // androidx.recyclerview.widget.RecyclerView.o public int t(RecyclerView.a0 a0Var) { return O1(a0Var); } @Override // androidx.recyclerview.widget.RecyclerView.o public int u(RecyclerView.a0 a0Var) { return P1(a0Var); } void u2(RecyclerView.v vVar, RecyclerView.a0 a0Var, a aVar, int i10) { } @Override // androidx.recyclerview.widget.RecyclerView.o public int v(RecyclerView.a0 a0Var) { return Q1(a0Var); } @Override // androidx.recyclerview.widget.RecyclerView.o public int w1(int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var) { if (this.f2179s == 1) { return 0; } return B2(i10, vVar, a0Var); } @Override // androidx.recyclerview.widget.RecyclerView.o public void x1(int i10) { this.A = i10; this.B = RecyclerView.UNDEFINED_DURATION; d dVar = this.D; if (dVar != null) { dVar.b(); } t1(); } @Override // androidx.recyclerview.widget.RecyclerView.o public int y1(int i10, RecyclerView.v vVar, RecyclerView.a0 a0Var) { if (this.f2179s == 0) { return 0; } return B2(i10, vVar, a0Var); } boolean z2() { return this.f2181u.k() == 0 && this.f2181u.h() == 0; } public LinearLayoutManager(Context context, AttributeSet attributeSet, int i10, int i11) { this.f2179s = 1; this.f2183w = false; this.f2184x = false; this.f2185y = false; this.f2186z = true; this.A = -1; this.B = RecyclerView.UNDEFINED_DURATION; this.D = null; this.E = new a(); this.F = new b(); this.G = 2; this.H = new int[2]; RecyclerView.o.d i02 = RecyclerView.o.i0(context, attributeSet, i10, i11); C2(i02.f2293a); D2(i02.f2295c); E2(i02.f2296d); } }