jimu-decompiled/sources/androidx/recyclerview/widget/LinearLayoutManager.java
2025-05-13 19:24:51 +02:00

1439 lines
42 KiB
Java

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.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
/* loaded from: classes.dex */
public class LinearLayoutManager extends RecyclerView.LayoutManager implements ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider {
int A;
int B;
private boolean C;
SavedState D;
final AnchorInfo E;
private final LayoutChunkResult F;
private int G;
int s;
private LayoutState t;
OrientationHelper u;
private boolean v;
private boolean w;
boolean x;
private boolean y;
private boolean z;
protected static class LayoutChunkResult {
public int a;
public boolean b;
public boolean c;
public boolean d;
protected LayoutChunkResult() {
}
void a() {
this.a = 0;
this.b = false;
this.c = false;
this.d = false;
}
}
static class LayoutState {
int b;
int c;
int d;
int e;
int f;
int g;
boolean i;
int j;
boolean l;
boolean a = true;
int h = 0;
List<RecyclerView.ViewHolder> k = null;
LayoutState() {
}
private View b() {
int size = this.k.size();
for (int i = 0; i < size; i++) {
View view = this.k.get(i).itemView;
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
if (!layoutParams.c() && this.d == layoutParams.a()) {
a(view);
return view;
}
}
return null;
}
boolean a(RecyclerView.State state) {
int i = this.d;
return i >= 0 && i < state.a();
}
View a(RecyclerView.Recycler recycler) {
if (this.k != null) {
return b();
}
View d = recycler.d(this.d);
this.d += this.e;
return d;
}
public void a() {
a((View) null);
}
public void a(View view) {
View b = b(view);
if (b == null) {
this.d = -1;
} else {
this.d = ((RecyclerView.LayoutParams) b.getLayoutParams()).a();
}
}
public View b(View view) {
int a;
int size = this.k.size();
View view2 = null;
int i = Integer.MAX_VALUE;
for (int i2 = 0; i2 < size; i2++) {
View view3 = this.k.get(i2).itemView;
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view3.getLayoutParams();
if (view3 != view && !layoutParams.c() && (a = (layoutParams.a() - this.d) * this.e) >= 0 && a < i) {
view2 = view3;
if (a == 0) {
break;
}
i = a;
}
}
return view2;
}
}
public static class SavedState implements Parcelable {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { // from class: androidx.recyclerview.widget.LinearLayoutManager.SavedState.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
};
boolean mAnchorLayoutFromEnd;
int mAnchorOffset;
int mAnchorPosition;
public SavedState() {
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
boolean hasValidAnchor() {
return this.mAnchorPosition >= 0;
}
void invalidateAnchor() {
this.mAnchorPosition = -1;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.mAnchorPosition);
parcel.writeInt(this.mAnchorOffset);
parcel.writeInt(this.mAnchorLayoutFromEnd ? 1 : 0);
}
SavedState(Parcel parcel) {
this.mAnchorPosition = parcel.readInt();
this.mAnchorOffset = parcel.readInt();
this.mAnchorLayoutFromEnd = parcel.readInt() == 1;
}
public SavedState(SavedState savedState) {
this.mAnchorPosition = savedState.mAnchorPosition;
this.mAnchorOffset = savedState.mAnchorOffset;
this.mAnchorLayoutFromEnd = savedState.mAnchorLayoutFromEnd;
}
}
public LinearLayoutManager(Context context) {
this(context, 1, false);
}
private View N() {
return d(this.x ? 0 : e() - 1);
}
private View O() {
return d(this.x ? e() - 1 : 0);
}
private void P() {
if (this.s == 1 || !L()) {
this.x = this.w;
} else {
this.x = !this.w;
}
}
private int j(RecyclerView.State state) {
if (e() == 0) {
return 0;
}
F();
return ScrollbarHelper.a(state, this.u, b(!this.z, true), a(!this.z, true), this, this.z, this.x);
}
private View l(RecyclerView.Recycler recycler, RecyclerView.State state) {
return this.x ? g(recycler, state) : i(recycler, state);
}
private View m(RecyclerView.Recycler recycler, RecyclerView.State state) {
return this.x ? i(recycler, state) : g(recycler, state);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
boolean B() {
return (i() == 1073741824 || s() == 1073741824 || !t()) ? false : true;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean D() {
return this.D == null && this.v == this.y;
}
LayoutState E() {
return new LayoutState();
}
void F() {
if (this.t == null) {
this.t = E();
}
}
public int G() {
View a = a(0, e(), true, false);
if (a == null) {
return -1;
}
return l(a);
}
public int H() {
View a = a(0, e(), false, true);
if (a == null) {
return -1;
}
return l(a);
}
public int I() {
View a = a(e() - 1, -1, true, false);
if (a == null) {
return -1;
}
return l(a);
}
public int J() {
View a = a(e() - 1, -1, false, true);
if (a == null) {
return -1;
}
return l(a);
}
public int K() {
return this.s;
}
protected boolean L() {
return k() == 1;
}
boolean M() {
return this.u.d() == 0 && this.u.a() == 0;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(AccessibilityEvent accessibilityEvent) {
super.a(accessibilityEvent);
if (e() > 0) {
accessibilityEvent.setFromIndex(H());
accessibilityEvent.setToIndex(J());
}
}
void a(RecyclerView.Recycler recycler, RecyclerView.State state, AnchorInfo anchorInfo, int i) {
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void b(RecyclerView recyclerView, RecyclerView.Recycler recycler) {
super.b(recyclerView, recycler);
if (this.C) {
b(recycler);
recycler.a();
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public RecyclerView.LayoutParams c() {
return new RecyclerView.LayoutParams(-2, -2);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int d(RecyclerView.State state) {
return i(state);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void e(RecyclerView.Recycler recycler, RecyclerView.State state) {
int i;
int i2;
int i3;
int i4;
int i5;
int a;
int i6;
View c;
int d;
int i7;
int i8 = -1;
if (!(this.D == null && this.A == -1) && state.a() == 0) {
b(recycler);
return;
}
SavedState savedState = this.D;
if (savedState != null && savedState.hasValidAnchor()) {
this.A = this.D.mAnchorPosition;
}
F();
this.t.a = false;
P();
View g = g();
if (!this.E.e || this.A != -1 || this.D != null) {
this.E.b();
AnchorInfo anchorInfo = this.E;
anchorInfo.d = this.x ^ this.y;
b(recycler, state, anchorInfo);
this.E.e = true;
} else if (g != null && (this.u.d(g) >= this.u.b() || this.u.a(g) <= this.u.f())) {
this.E.b(g, l(g));
}
int h = h(state);
if (this.t.j >= 0) {
i = h;
h = 0;
} else {
i = 0;
}
int f = h + this.u.f();
int c2 = i + this.u.c();
if (state.d() && (i6 = this.A) != -1 && this.B != Integer.MIN_VALUE && (c = c(i6)) != null) {
if (this.x) {
i7 = this.u.b() - this.u.a(c);
d = this.B;
} else {
d = this.u.d(c) - this.u.f();
i7 = this.B;
}
int i9 = i7 - d;
if (i9 > 0) {
f += i9;
} else {
c2 -= i9;
}
}
if (!this.E.d ? !this.x : this.x) {
i8 = 1;
}
a(recycler, state, this.E, i8);
a(recycler);
this.t.l = M();
this.t.i = state.d();
AnchorInfo anchorInfo2 = this.E;
if (anchorInfo2.d) {
b(anchorInfo2);
LayoutState layoutState = this.t;
layoutState.h = f;
a(recycler, layoutState, state, false);
LayoutState layoutState2 = this.t;
i3 = layoutState2.b;
int i10 = layoutState2.d;
int i11 = layoutState2.c;
if (i11 > 0) {
c2 += i11;
}
a(this.E);
LayoutState layoutState3 = this.t;
layoutState3.h = c2;
layoutState3.d += layoutState3.e;
a(recycler, layoutState3, state, false);
LayoutState layoutState4 = this.t;
i2 = layoutState4.b;
int i12 = layoutState4.c;
if (i12 > 0) {
h(i10, i3);
LayoutState layoutState5 = this.t;
layoutState5.h = i12;
a(recycler, layoutState5, state, false);
i3 = this.t.b;
}
} else {
a(anchorInfo2);
LayoutState layoutState6 = this.t;
layoutState6.h = c2;
a(recycler, layoutState6, state, false);
LayoutState layoutState7 = this.t;
i2 = layoutState7.b;
int i13 = layoutState7.d;
int i14 = layoutState7.c;
if (i14 > 0) {
f += i14;
}
b(this.E);
LayoutState layoutState8 = this.t;
layoutState8.h = f;
layoutState8.d += layoutState8.e;
a(recycler, layoutState8, state, false);
LayoutState layoutState9 = this.t;
i3 = layoutState9.b;
int i15 = layoutState9.c;
if (i15 > 0) {
g(i13, i2);
LayoutState layoutState10 = this.t;
layoutState10.h = i15;
a(recycler, layoutState10, state, false);
i2 = this.t.b;
}
}
if (e() > 0) {
if (this.x ^ this.y) {
int a2 = a(i2, recycler, state, true);
i4 = i3 + a2;
i5 = i2 + a2;
a = b(i4, recycler, state, false);
} else {
int b = b(i3, recycler, state, true);
i4 = i3 + b;
i5 = i2 + b;
a = a(i5, recycler, state, false);
}
i3 = i4 + a;
i2 = i5 + a;
}
b(recycler, state, i3, i2);
if (state.d()) {
this.E.b();
} else {
this.u.i();
}
this.v = this.y;
}
public void f(int i, int i2) {
this.A = i;
this.B = i2;
SavedState savedState = this.D;
if (savedState != null) {
savedState.invalidateAnchor();
}
z();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void g(RecyclerView.State state) {
super.g(state);
this.D = null;
this.A = -1;
this.B = Integer.MIN_VALUE;
this.E.b();
}
protected int h(RecyclerView.State state) {
if (state.c()) {
return this.u.g();
}
return 0;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void i(int i) {
this.A = i;
this.B = Integer.MIN_VALUE;
SavedState savedState = this.D;
if (savedState != null) {
savedState.invalidateAnchor();
}
z();
}
public void k(int i) {
if (i != 0 && i != 1) {
throw new IllegalArgumentException("invalid orientation:" + i);
}
a((String) null);
if (i != this.s || this.u == null) {
this.u = OrientationHelper.a(this, i);
this.E.a = this.u;
this.s = i;
z();
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean v() {
return true;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public Parcelable y() {
SavedState savedState = this.D;
if (savedState != null) {
return new SavedState(savedState);
}
SavedState savedState2 = new SavedState();
if (e() > 0) {
F();
boolean z = this.v ^ this.x;
savedState2.mAnchorLayoutFromEnd = z;
if (z) {
View N = N();
savedState2.mAnchorOffset = this.u.b() - this.u.a(N);
savedState2.mAnchorPosition = l(N);
} else {
View O = O();
savedState2.mAnchorPosition = l(O);
savedState2.mAnchorOffset = this.u.d(O) - this.u.f();
}
} else {
savedState2.invalidateAnchor();
}
return savedState2;
}
public LinearLayoutManager(Context context, int i, boolean z) {
this.s = 1;
this.w = false;
this.x = false;
this.y = false;
this.z = true;
this.A = -1;
this.B = Integer.MIN_VALUE;
this.D = null;
this.E = new AnchorInfo();
this.F = new LayoutChunkResult();
this.G = 2;
k(i);
a(z);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public View c(int i) {
int e = e();
if (e == 0) {
return null;
}
int l = i - l(d(0));
if (l >= 0 && l < e) {
View d = d(l);
if (l(d) == i) {
return d;
}
}
return super.c(i);
}
static class AnchorInfo {
OrientationHelper a;
int b;
int c;
boolean d;
boolean e;
AnchorInfo() {
b();
}
void a() {
this.c = this.d ? this.a.b() : this.a.f();
}
void b() {
this.b = -1;
this.c = Integer.MIN_VALUE;
this.d = false;
this.e = false;
}
public String toString() {
return "AnchorInfo{mPosition=" + this.b + ", mCoordinate=" + this.c + ", mLayoutFromEnd=" + this.d + ", mValid=" + this.e + '}';
}
boolean a(View view, RecyclerView.State state) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return !layoutParams.c() && layoutParams.a() >= 0 && layoutParams.a() < state.a();
}
public void b(View view, int i) {
int h = this.a.h();
if (h >= 0) {
a(view, i);
return;
}
this.b = i;
if (this.d) {
int b = (this.a.b() - h) - this.a.a(view);
this.c = this.a.b() - b;
if (b > 0) {
int b2 = this.c - this.a.b(view);
int f = this.a.f();
int min = b2 - (f + Math.min(this.a.d(view) - f, 0));
if (min < 0) {
this.c += Math.min(b, -min);
return;
}
return;
}
return;
}
int d = this.a.d(view);
int f2 = d - this.a.f();
this.c = d;
if (f2 > 0) {
int b3 = (this.a.b() - Math.min(0, (this.a.b() - h) - this.a.a(view))) - (d + this.a.b(view));
if (b3 < 0) {
this.c -= Math.min(f2, -b3);
}
}
}
public void a(View view, int i) {
if (this.d) {
this.c = this.a.a(view) + this.a.h();
} else {
this.c = this.a.d(view);
}
this.b = i;
}
}
private void h(int i, int i2) {
this.t.c = i2 - this.u.f();
LayoutState layoutState = this.t;
layoutState.d = i;
layoutState.e = this.x ? 1 : -1;
LayoutState layoutState2 = this.t;
layoutState2.f = -1;
layoutState2.b = i2;
layoutState2.g = Integer.MIN_VALUE;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(Parcelable parcelable) {
if (parcelable instanceof SavedState) {
this.D = (SavedState) parcelable;
z();
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean b() {
return this.s == 1;
}
private void g(int i, int i2) {
this.t.c = this.u.b() - i2;
this.t.e = this.x ? -1 : 1;
LayoutState layoutState = this.t;
layoutState.d = i;
layoutState.f = 1;
layoutState.b = i2;
layoutState.g = Integer.MIN_VALUE;
}
private int i(RecyclerView.State state) {
if (e() == 0) {
return 0;
}
F();
return ScrollbarHelper.a(state, this.u, b(!this.z, true), a(!this.z, true), this, this.z);
}
public void b(boolean z) {
a((String) null);
if (this.y == z) {
return;
}
this.y = z;
z();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int f(RecyclerView.State state) {
return k(state);
}
private View f(RecyclerView.Recycler recycler, RecyclerView.State state) {
return e(0, e());
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int c(RecyclerView.State state) {
return k(state);
}
int j(int i) {
return i != 1 ? i != 2 ? i != 17 ? i != 33 ? i != 66 ? (i == 130 && this.s == 1) ? 1 : Integer.MIN_VALUE : this.s == 0 ? 1 : Integer.MIN_VALUE : this.s == 1 ? -1 : Integer.MIN_VALUE : this.s == 0 ? -1 : Integer.MIN_VALUE : (this.s != 1 && L()) ? -1 : 1 : (this.s != 1 && L()) ? 1 : -1;
}
private int k(RecyclerView.State state) {
if (e() == 0) {
return 0;
}
F();
return ScrollbarHelper.b(state, this.u, b(!this.z, true), a(!this.z, true), this, this.z);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean a() {
return this.s == 0;
}
int c(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (e() == 0 || i == 0) {
return 0;
}
this.t.a = true;
F();
int i2 = i > 0 ? 1 : -1;
int abs = Math.abs(i);
a(i2, abs, true, state);
LayoutState layoutState = this.t;
int a = layoutState.g + a(recycler, layoutState, state, false);
if (a < 0) {
return 0;
}
if (abs > a) {
i = i2 * a;
}
this.u.a(-i);
this.t.j = i;
return i;
}
private View h(RecyclerView.Recycler recycler, RecyclerView.State state) {
return e(e() - 1, -1);
}
public void a(boolean z) {
a((String) null);
if (z == this.w) {
return;
}
this.w = z;
z();
}
private void b(RecyclerView.Recycler recycler, RecyclerView.State state, int i, int i2) {
if (!state.e() || e() == 0 || state.d() || !D()) {
return;
}
List<RecyclerView.ViewHolder> f = recycler.f();
int size = f.size();
int l = l(d(0));
int i3 = 0;
int i4 = 0;
for (int i5 = 0; i5 < size; i5++) {
RecyclerView.ViewHolder viewHolder = f.get(i5);
if (!viewHolder.isRemoved()) {
if (((viewHolder.getLayoutPosition() < l) != this.x ? (char) 65535 : (char) 1) == 65535) {
i3 += this.u.b(viewHolder.itemView);
} else {
i4 += this.u.b(viewHolder.itemView);
}
}
}
this.t.k = f;
if (i3 > 0) {
h(l(O()), i);
LayoutState layoutState = this.t;
layoutState.h = i3;
layoutState.c = 0;
layoutState.a();
a(recycler, this.t, state, false);
}
if (i4 > 0) {
g(l(N()), i2);
LayoutState layoutState2 = this.t;
layoutState2.h = i4;
layoutState2.c = 0;
layoutState2.a();
a(recycler, this.t, state, false);
}
this.t.k = null;
}
private View g(RecyclerView.Recycler recycler, RecyclerView.State state) {
return a(recycler, state, 0, e(), state.a());
}
private View i(RecyclerView.Recycler recycler, RecyclerView.State state) {
return a(recycler, state, e() - 1, -1, state.a());
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(RecyclerView recyclerView, RecyclerView.State state, int i) {
LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext());
linearSmoothScroller.c(i);
b(linearSmoothScroller);
}
private View k(RecyclerView.Recycler recycler, RecyclerView.State state) {
return this.x ? h(recycler, state) : f(recycler, state);
}
private View j(RecyclerView.Recycler recycler, RecyclerView.State state) {
return this.x ? f(recycler, state) : h(recycler, state);
}
public LinearLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
this.s = 1;
this.w = false;
this.x = false;
this.y = false;
this.z = true;
this.A = -1;
this.B = Integer.MIN_VALUE;
this.D = null;
this.E = new AnchorInfo();
this.F = new LayoutChunkResult();
this.G = 2;
RecyclerView.LayoutManager.Properties a = RecyclerView.LayoutManager.a(context, attributeSet, i, i2);
k(a.orientation);
a(a.reverseLayout);
b(a.stackFromEnd);
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller.ScrollVectorProvider
public PointF a(int i) {
if (e() == 0) {
return null;
}
int i2 = (i < l(d(0))) != this.x ? -1 : 1;
if (this.s == 0) {
return new PointF(i2, 0.0f);
}
return new PointF(0.0f, i2);
}
private boolean a(RecyclerView.Recycler recycler, RecyclerView.State state, AnchorInfo anchorInfo) {
View m;
int f;
if (e() == 0) {
return false;
}
View g = g();
if (g != null && anchorInfo.a(g, state)) {
anchorInfo.b(g, l(g));
return true;
}
if (this.v != this.y) {
return false;
}
if (anchorInfo.d) {
m = l(recycler, state);
} else {
m = m(recycler, state);
}
if (m == null) {
return false;
}
anchorInfo.a(m, l(m));
if (!state.d() && D()) {
if (this.u.d(m) >= this.u.b() || this.u.a(m) < this.u.f()) {
if (anchorInfo.d) {
f = this.u.b();
} else {
f = this.u.f();
}
anchorInfo.c = f;
}
}
return true;
}
private void b(RecyclerView.Recycler recycler, RecyclerView.State state, AnchorInfo anchorInfo) {
if (a(state, anchorInfo) || a(recycler, state, anchorInfo)) {
return;
}
anchorInfo.a();
anchorInfo.b = this.y ? state.a() - 1 : 0;
}
private int b(int i, RecyclerView.Recycler recycler, RecyclerView.State state, boolean z) {
int f;
int f2 = i - this.u.f();
if (f2 <= 0) {
return 0;
}
int i2 = -c(f2, recycler, state);
int i3 = i + i2;
if (!z || (f = i3 - this.u.f()) <= 0) {
return i2;
}
this.u.a(-f);
return i2 - f;
}
private boolean a(RecyclerView.State state, AnchorInfo anchorInfo) {
int i;
int d;
if (!state.d() && (i = this.A) != -1) {
if (i >= 0 && i < state.a()) {
anchorInfo.b = this.A;
SavedState savedState = this.D;
if (savedState != null && savedState.hasValidAnchor()) {
anchorInfo.d = this.D.mAnchorLayoutFromEnd;
if (anchorInfo.d) {
anchorInfo.c = this.u.b() - this.D.mAnchorOffset;
} else {
anchorInfo.c = this.u.f() + this.D.mAnchorOffset;
}
return true;
}
if (this.B == Integer.MIN_VALUE) {
View c = c(this.A);
if (c != null) {
if (this.u.b(c) > this.u.g()) {
anchorInfo.a();
return true;
}
if (this.u.d(c) - this.u.f() < 0) {
anchorInfo.c = this.u.f();
anchorInfo.d = false;
return true;
}
if (this.u.b() - this.u.a(c) < 0) {
anchorInfo.c = this.u.b();
anchorInfo.d = true;
return true;
}
if (anchorInfo.d) {
d = this.u.a(c) + this.u.h();
} else {
d = this.u.d(c);
}
anchorInfo.c = d;
} else {
if (e() > 0) {
anchorInfo.d = (this.A < l(d(0))) == this.x;
}
anchorInfo.a();
}
return true;
}
boolean z = this.x;
anchorInfo.d = z;
if (z) {
anchorInfo.c = this.u.b() - this.B;
} else {
anchorInfo.c = this.u.f() + this.B;
}
return true;
}
this.A = -1;
this.B = Integer.MIN_VALUE;
}
return false;
}
private void b(AnchorInfo anchorInfo) {
h(anchorInfo.b, anchorInfo.c);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int b(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (this.s == 0) {
return 0;
}
return c(i, recycler, state);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int b(RecyclerView.State state) {
return j(state);
}
private void b(RecyclerView.Recycler recycler, int i) {
if (i < 0) {
return;
}
int e = e();
if (!this.x) {
for (int i2 = 0; i2 < e; i2++) {
View d = d(i2);
if (this.u.a(d) > i || this.u.e(d) > i) {
a(recycler, 0, i2);
return;
}
}
return;
}
int i3 = e - 1;
for (int i4 = i3; i4 >= 0; i4--) {
View d2 = d(i4);
if (this.u.a(d2) > i || this.u.e(d2) > i) {
a(recycler, i3, i4);
return;
}
}
}
private View b(boolean z, boolean z2) {
if (this.x) {
return a(e() - 1, -1, z, z2);
}
return a(0, e(), z, z2);
}
private int a(int i, RecyclerView.Recycler recycler, RecyclerView.State state, boolean z) {
int b;
int b2 = this.u.b() - i;
if (b2 <= 0) {
return 0;
}
int i2 = -c(-b2, recycler, state);
int i3 = i + i2;
if (!z || (b = this.u.b() - i3) <= 0) {
return i2;
}
this.u.a(b);
return b + i2;
}
private void a(AnchorInfo anchorInfo) {
g(anchorInfo.b, anchorInfo.c);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int a(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (this.s == 1) {
return 0;
}
return c(i, recycler, state);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int a(RecyclerView.State state) {
return i(state);
}
private void a(int i, int i2, boolean z, RecyclerView.State state) {
int f;
this.t.l = M();
this.t.h = h(state);
LayoutState layoutState = this.t;
layoutState.f = i;
if (i == 1) {
layoutState.h += this.u.c();
View N = N();
this.t.e = this.x ? -1 : 1;
LayoutState layoutState2 = this.t;
int l = l(N);
LayoutState layoutState3 = this.t;
layoutState2.d = l + layoutState3.e;
layoutState3.b = this.u.a(N);
f = this.u.a(N) - this.u.b();
} else {
View O = O();
this.t.h += this.u.f();
this.t.e = this.x ? 1 : -1;
LayoutState layoutState4 = this.t;
int l2 = l(O);
LayoutState layoutState5 = this.t;
layoutState4.d = l2 + layoutState5.e;
layoutState5.b = this.u.d(O);
f = (-this.u.d(O)) + this.u.f();
}
LayoutState layoutState6 = this.t;
layoutState6.c = i2;
if (z) {
layoutState6.c -= f;
}
this.t.g = f;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int e(RecyclerView.State state) {
return j(state);
}
View e(int i, int i2) {
int i3;
int i4;
F();
if ((i2 > i ? (char) 1 : i2 < i ? (char) 65535 : (char) 0) == 0) {
return d(i);
}
if (this.u.d(d(i)) < this.u.f()) {
i3 = 16644;
i4 = 16388;
} else {
i3 = 4161;
i4 = 4097;
}
if (this.s == 0) {
return this.e.a(i, i2, i3, i4);
}
return this.f.a(i, i2, i3, i4);
}
void a(RecyclerView.State state, LayoutState layoutState, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) {
int i = layoutState.d;
if (i < 0 || i >= state.a()) {
return;
}
layoutPrefetchRegistry.a(i, Math.max(0, layoutState.g));
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(int i, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) {
boolean z;
int i2;
SavedState savedState = this.D;
if (savedState != null && savedState.hasValidAnchor()) {
SavedState savedState2 = this.D;
z = savedState2.mAnchorLayoutFromEnd;
i2 = savedState2.mAnchorPosition;
} else {
P();
z = this.x;
i2 = this.A;
if (i2 == -1) {
i2 = z ? i - 1 : 0;
}
}
int i3 = z ? -1 : 1;
int i4 = i2;
for (int i5 = 0; i5 < this.G && i4 >= 0 && i4 < i; i5++) {
layoutPrefetchRegistry.a(i4, 0);
i4 += i3;
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(int i, int i2, RecyclerView.State state, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) {
if (this.s != 0) {
i = i2;
}
if (e() == 0 || i == 0) {
return;
}
F();
a(i > 0 ? 1 : -1, Math.abs(i), true, state);
a(state, this.t, layoutPrefetchRegistry);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void a(String str) {
if (this.D == null) {
super.a(str);
}
}
private void a(RecyclerView.Recycler recycler, int i, int i2) {
if (i == i2) {
return;
}
if (i2 <= i) {
while (i > i2) {
a(i, recycler);
i--;
}
} else {
for (int i3 = i2 - 1; i3 >= i; i3--) {
a(i3, recycler);
}
}
}
private void a(RecyclerView.Recycler recycler, int i) {
int e = e();
if (i < 0) {
return;
}
int a = this.u.a() - i;
if (this.x) {
for (int i2 = 0; i2 < e; i2++) {
View d = d(i2);
if (this.u.d(d) < a || this.u.f(d) < a) {
a(recycler, 0, i2);
return;
}
}
return;
}
int i3 = e - 1;
for (int i4 = i3; i4 >= 0; i4--) {
View d2 = d(i4);
if (this.u.d(d2) < a || this.u.f(d2) < a) {
a(recycler, i3, i4);
return;
}
}
}
private void a(RecyclerView.Recycler recycler, LayoutState layoutState) {
if (!layoutState.a || layoutState.l) {
return;
}
if (layoutState.f == -1) {
a(recycler, layoutState.g);
} else {
b(recycler, layoutState.g);
}
}
int a(RecyclerView.Recycler recycler, LayoutState layoutState, RecyclerView.State state, boolean z) {
int i = layoutState.c;
int i2 = layoutState.g;
if (i2 != Integer.MIN_VALUE) {
if (i < 0) {
layoutState.g = i2 + i;
}
a(recycler, layoutState);
}
int i3 = layoutState.c + layoutState.h;
LayoutChunkResult layoutChunkResult = this.F;
while (true) {
if ((!layoutState.l && i3 <= 0) || !layoutState.a(state)) {
break;
}
layoutChunkResult.a();
a(recycler, state, layoutState, layoutChunkResult);
if (!layoutChunkResult.b) {
layoutState.b += layoutChunkResult.a * layoutState.f;
if (!layoutChunkResult.c || this.t.k != null || !state.d()) {
int i4 = layoutState.c;
int i5 = layoutChunkResult.a;
layoutState.c = i4 - i5;
i3 -= i5;
}
int i6 = layoutState.g;
if (i6 != Integer.MIN_VALUE) {
layoutState.g = i6 + layoutChunkResult.a;
int i7 = layoutState.c;
if (i7 < 0) {
layoutState.g += i7;
}
a(recycler, layoutState);
}
if (z && layoutChunkResult.d) {
break;
}
} else {
break;
}
}
return i - layoutState.c;
}
void a(RecyclerView.Recycler recycler, RecyclerView.State state, LayoutState layoutState, LayoutChunkResult layoutChunkResult) {
int i;
int i2;
int i3;
int i4;
int c;
View a = layoutState.a(recycler);
if (a == null) {
layoutChunkResult.b = true;
return;
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) a.getLayoutParams();
if (layoutState.k == null) {
if (this.x == (layoutState.f == -1)) {
b(a);
} else {
b(a, 0);
}
} else {
if (this.x == (layoutState.f == -1)) {
a(a);
} else {
a(a, 0);
}
}
a(a, 0, 0);
layoutChunkResult.a = this.u.b(a);
if (this.s == 1) {
if (L()) {
c = r() - p();
i4 = c - this.u.c(a);
} else {
i4 = o();
c = this.u.c(a) + i4;
}
if (layoutState.f == -1) {
int i5 = layoutState.b;
i3 = i5;
i2 = c;
i = i5 - layoutChunkResult.a;
} else {
int i6 = layoutState.b;
i = i6;
i2 = c;
i3 = layoutChunkResult.a + i6;
}
} else {
int q = q();
int c2 = this.u.c(a) + q;
if (layoutState.f == -1) {
int i7 = layoutState.b;
i2 = i7;
i = q;
i3 = c2;
i4 = i7 - layoutChunkResult.a;
} else {
int i8 = layoutState.b;
i = q;
i2 = layoutChunkResult.a + i8;
i3 = c2;
i4 = i8;
}
}
b(a, i4, i, i2, i3);
if (layoutParams.c() || layoutParams.b()) {
layoutChunkResult.c = true;
}
layoutChunkResult.d = a.hasFocusable();
}
private View a(boolean z, boolean z2) {
if (this.x) {
return a(0, e(), z, z2);
}
return a(e() - 1, -1, z, z2);
}
View a(RecyclerView.Recycler recycler, RecyclerView.State state, int i, int i2, int i3) {
F();
int f = this.u.f();
int b = this.u.b();
int i4 = i2 > i ? 1 : -1;
View view = null;
View view2 = null;
while (i != i2) {
View d = d(i);
int l = l(d);
if (l >= 0 && l < i3) {
if (((RecyclerView.LayoutParams) d.getLayoutParams()).c()) {
if (view2 == null) {
view2 = d;
}
} else {
if (this.u.d(d) < b && this.u.a(d) >= f) {
return d;
}
if (view == null) {
view = d;
}
}
}
i += i4;
}
return view != null ? view : view2;
}
View a(int i, int i2, boolean z, boolean z2) {
F();
int i3 = z ? 24579 : 320;
int i4 = z2 ? 320 : 0;
if (this.s == 0) {
return this.e.a(i, i2, i3, i4);
}
return this.f.a(i, i2, i3, i4);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public View a(View view, int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
int j;
View j2;
View N;
P();
if (e() == 0 || (j = j(i)) == Integer.MIN_VALUE) {
return null;
}
F();
F();
a(j, (int) (this.u.g() * 0.33333334f), false, state);
LayoutState layoutState = this.t;
layoutState.g = Integer.MIN_VALUE;
layoutState.a = false;
a(recycler, layoutState, state, true);
if (j == -1) {
j2 = k(recycler, state);
} else {
j2 = j(recycler, state);
}
if (j == -1) {
N = O();
} else {
N = N();
}
if (!N.hasFocusable()) {
return j2;
}
if (j2 == null) {
return null;
}
return N;
}
@Override // androidx.recyclerview.widget.ItemTouchHelper.ViewDropHandler
public void a(View view, View view2, int i, int i2) {
a("Cannot drop a view during a scroll or layout calculation");
F();
P();
int l = l(view);
int l2 = l(view2);
char c = l < l2 ? (char) 1 : (char) 65535;
if (this.x) {
if (c == 1) {
f(l2, this.u.b() - (this.u.d(view2) + this.u.b(view)));
return;
} else {
f(l2, this.u.b() - this.u.a(view2));
return;
}
}
if (c == 65535) {
f(l2, this.u.d(view2));
} else {
f(l2, this.u.a(view2) - this.u.b(view));
}
}
}