268 lines
9.5 KiB
Java
268 lines
9.5 KiB
Java
package o;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class qtT implements Runnable {
|
|
public long b;
|
|
private long c;
|
|
public ArrayList<RecyclerView> d = new ArrayList<>();
|
|
private ArrayList<Sts> h = new ArrayList<>();
|
|
public static final ThreadLocal<qtT> e = new ThreadLocal<>();
|
|
private static Comparator<Sts> a = new Comparator<Sts>() { // from class: o.qtT.3
|
|
@Override // java.util.Comparator
|
|
public final /* bridge */ /* synthetic */ int compare(Sts sts, Sts sts2) {
|
|
Sts sts3 = sts;
|
|
Sts sts4 = sts2;
|
|
if ((sts3.b == null) != (sts4.b == null)) {
|
|
return sts3.b == null ? 1 : -1;
|
|
}
|
|
if (sts3.e != sts4.e) {
|
|
return sts3.e ? -1 : 1;
|
|
}
|
|
int i = sts4.c - sts3.c;
|
|
if (i != 0) {
|
|
return i;
|
|
}
|
|
int i2 = sts3.d - sts4.d;
|
|
if (i2 != 0) {
|
|
return i2;
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
/* loaded from: classes.dex */
|
|
static class Sts {
|
|
public int a;
|
|
public RecyclerView b;
|
|
public int c;
|
|
public int d;
|
|
public boolean e;
|
|
|
|
Sts() {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class LWm implements RecyclerView.tOB.Sts {
|
|
int a;
|
|
int b;
|
|
public int[] c;
|
|
public int e;
|
|
|
|
final void d(RecyclerView recyclerView, boolean z) {
|
|
this.e = 0;
|
|
int[] iArr = this.c;
|
|
if (iArr != null) {
|
|
Arrays.fill(iArr, -1);
|
|
}
|
|
RecyclerView.tOB tob = recyclerView.x;
|
|
if (recyclerView.g == null || tob == null || !tob.q) {
|
|
return;
|
|
}
|
|
if (!z) {
|
|
if (!recyclerView.d()) {
|
|
tob.b(this.a, this.b, recyclerView.R, this);
|
|
}
|
|
} else if (recyclerView.j.d.size() <= 0) {
|
|
tob.d(recyclerView.g.getItemCount(), this);
|
|
}
|
|
if (this.e > tob.p) {
|
|
tob.p = this.e;
|
|
tob.r = z;
|
|
recyclerView.M.b();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.tOB.Sts
|
|
public final void c(int i, int i2) {
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException("Layout positions must be non-negative");
|
|
}
|
|
if (i2 < 0) {
|
|
throw new IllegalArgumentException("Pixel distance must be non-negative");
|
|
}
|
|
int i3 = this.e;
|
|
int i4 = i3 << 1;
|
|
int[] iArr = this.c;
|
|
if (iArr == null) {
|
|
int[] iArr2 = new int[4];
|
|
this.c = iArr2;
|
|
Arrays.fill(iArr2, -1);
|
|
} else if (i4 >= iArr.length) {
|
|
int[] iArr3 = new int[i3 << 2];
|
|
this.c = iArr3;
|
|
System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
|
|
}
|
|
int[] iArr4 = this.c;
|
|
iArr4[i4] = i;
|
|
iArr4[i4 + 1] = i2;
|
|
this.e++;
|
|
}
|
|
|
|
public final boolean b(int i) {
|
|
if (this.c != null) {
|
|
int i2 = this.e;
|
|
for (int i3 = 0; i3 < (i2 << 1); i3 += 2) {
|
|
if (this.c[i3] == i) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public final void a(RecyclerView recyclerView, int i, int i2) {
|
|
if (recyclerView.isAttachedToWindow() && this.c == 0) {
|
|
this.c = RecyclerView.b();
|
|
recyclerView.post(this);
|
|
}
|
|
LWm lWm = recyclerView.J;
|
|
lWm.a = i;
|
|
lWm.b = i2;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
RecyclerView recyclerView;
|
|
Sts sts;
|
|
long j = 0;
|
|
try {
|
|
Lfp.b("RV Prefetch");
|
|
if (!this.d.isEmpty()) {
|
|
int size = this.d.size();
|
|
long j2 = 0;
|
|
for (int i = 0; i < size; i++) {
|
|
try {
|
|
RecyclerView recyclerView2 = this.d.get(i);
|
|
if (recyclerView2.getWindowVisibility() == 0) {
|
|
j2 = Math.max(recyclerView2.getDrawingTime(), j2);
|
|
}
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
this.c = j;
|
|
throw th;
|
|
}
|
|
}
|
|
if (j2 != 0) {
|
|
long nanos = TimeUnit.MILLISECONDS.toNanos(j2) + this.b;
|
|
int size2 = this.d.size();
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size2; i3++) {
|
|
RecyclerView recyclerView3 = this.d.get(i3);
|
|
if (recyclerView3.getWindowVisibility() == 0) {
|
|
recyclerView3.J.d(recyclerView3, false);
|
|
i2 += recyclerView3.J.e;
|
|
}
|
|
}
|
|
this.h.ensureCapacity(i2);
|
|
int i4 = 0;
|
|
int i5 = 0;
|
|
while (i4 < size2) {
|
|
RecyclerView recyclerView4 = this.d.get(i4);
|
|
if (recyclerView4.getWindowVisibility() == 0) {
|
|
LWm lWm = recyclerView4.J;
|
|
int abs = Math.abs(lWm.a) + Math.abs(lWm.b);
|
|
int i6 = 0;
|
|
while (i6 < (lWm.e << 1)) {
|
|
if (i5 >= this.h.size()) {
|
|
sts = new Sts();
|
|
this.h.add(sts);
|
|
} else {
|
|
sts = this.h.get(i5);
|
|
}
|
|
int i7 = lWm.c[i6 + 1];
|
|
sts.e = i7 <= abs;
|
|
sts.c = abs;
|
|
sts.d = i7;
|
|
sts.b = recyclerView4;
|
|
sts.a = lWm.c[i6];
|
|
i5++;
|
|
i6 += 2;
|
|
j = 0;
|
|
}
|
|
}
|
|
i4++;
|
|
j = 0;
|
|
}
|
|
Collections.sort(this.h, a);
|
|
for (int i8 = 0; i8 < this.h.size(); i8++) {
|
|
Sts sts2 = this.h.get(i8);
|
|
if (sts2.b == null) {
|
|
break;
|
|
}
|
|
RecyclerView.zJl d = d(sts2.b, sts2.a, sts2.e ? Long.MAX_VALUE : nanos);
|
|
if (d != null && d.mNestedRecyclerView != null && d.isBound() && !d.isInvalid() && (recyclerView = d.mNestedRecyclerView.get()) != null) {
|
|
if (recyclerView.k && recyclerView.n.d.c() != 0) {
|
|
recyclerView.i();
|
|
}
|
|
LWm lWm2 = recyclerView.J;
|
|
lWm2.d(recyclerView, true);
|
|
if (lWm2.e != 0) {
|
|
try {
|
|
Lfp.b("RV Nested Prefetch");
|
|
RecyclerView.AcL acL = recyclerView.R;
|
|
RecyclerView.Sts sts3 = recyclerView.g;
|
|
acL.j = 1;
|
|
acL.h = sts3.getItemCount();
|
|
acL.c = false;
|
|
acL.t = false;
|
|
acL.f = false;
|
|
for (int i9 = 0; i9 < (lWm2.e << 1); i9 += 2) {
|
|
d(recyclerView, lWm2.c[i9], nanos);
|
|
}
|
|
Lfp.c();
|
|
} finally {
|
|
Lfp.c();
|
|
}
|
|
}
|
|
}
|
|
sts2.e = false;
|
|
sts2.c = 0;
|
|
sts2.d = 0;
|
|
sts2.b = null;
|
|
sts2.a = 0;
|
|
}
|
|
this.c = 0L;
|
|
}
|
|
}
|
|
this.c = 0L;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
j = 0;
|
|
}
|
|
}
|
|
|
|
private static RecyclerView.zJl d(RecyclerView recyclerView, int i, long j) {
|
|
int c = recyclerView.n.d.c();
|
|
for (int i2 = 0; i2 < c; i2++) {
|
|
RecyclerView.zJl c2 = RecyclerView.c(recyclerView.n.d.e(i2));
|
|
if (c2.mPosition == i && !c2.isInvalid()) {
|
|
return null;
|
|
}
|
|
}
|
|
RecyclerView.huo huoVar = recyclerView.M;
|
|
try {
|
|
recyclerView.B++;
|
|
RecyclerView.zJl a2 = huoVar.a(i, j);
|
|
if (a2 != null) {
|
|
if (a2.isBound() && !a2.isInvalid()) {
|
|
huoVar.c(a2.itemView);
|
|
} else {
|
|
huoVar.c(a2, false);
|
|
}
|
|
}
|
|
return a2;
|
|
} finally {
|
|
recyclerView.d(false);
|
|
}
|
|
}
|
|
}
|