package android.support.v7.widget;

import android.support.v7.widget.RecyclerView.o;
import android.support.v7.widget.RecyclerView.v;
import java.util.ArrayList;
import java.util.Comparator;

final class af implements Runnable {
    static final ThreadLocal<af> aiU = new ThreadLocal();
    static Comparator<b> aiZ = new 1();
    ArrayList<RecyclerView> aiV = new ArrayList();
    long aiW;
    long aiX;
    private ArrayList<b> aiY = new ArrayList();

    af() {
    }

    /* Access modifiers changed, original: final */
    public final void b(RecyclerView recyclerView, int i, int i2) {
        if (recyclerView.isAttachedToWindow() && this.aiW == 0) {
            this.aiW = recyclerView.getNanoTime();
            recyclerView.post(this);
        }
        a aVar = recyclerView.anX;
        aVar.aja = i;
        aVar.ajb = i2;
    }

    private static v a(RecyclerView recyclerView, int i, long j) {
        boolean z;
        int hU = recyclerView.anf.hU();
        for (int i2 = 0; i2 < hU; i2++) {
            v bn = RecyclerView.bn(recyclerView.anf.bI(i2));
            if (bn.mPosition == i && !bn.kq()) {
                z = true;
                break;
            }
        }
        z = false;
        if (z) {
            return null;
        }
        o oVar = recyclerView.anc;
        try {
            recyclerView.jw();
            v e = oVar.e(i, j);
            if (e != null) {
                if (!e.isBound() || e.kq()) {
                    oVar.a(e, false);
                } else {
                    oVar.bI(e.apJ);
                }
            }
            recyclerView.al(false);
            return e;
        } catch (Throwable th) {
            recyclerView.al(false);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:42:0x0100 A:{Catch:{ all -> 0x019a, all -> 0x019f }} */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x01a8 A:{SYNTHETIC} */
    public final void run() {
        /*
        r14 = this;
        r2 = "RV Prefetch";
        android.support.v4.os.f.beginSection(r2);	 Catch:{ all -> 0x019f }
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r2 = r2.isEmpty();	 Catch:{ all -> 0x019f }
        if (r2 == 0) goto L_0x0016;
    L_0x000e:
        r2 = 0;
        r14.aiW = r2;
        android.support.v4.os.f.endSection();
    L_0x0015:
        return;
    L_0x0016:
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r7 = r2.size();	 Catch:{ all -> 0x019f }
        r4 = 0;
        r2 = 0;
        r6 = r2;
    L_0x0020:
        if (r6 >= r7) goto L_0x003c;
    L_0x0022:
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r2 = r2.get(r6);	 Catch:{ all -> 0x019f }
        r2 = (android.support.v7.widget.RecyclerView) r2;	 Catch:{ all -> 0x019f }
        r3 = r2.getWindowVisibility();	 Catch:{ all -> 0x019f }
        if (r3 != 0) goto L_0x01b7;
    L_0x0030:
        r2 = r2.getDrawingTime();	 Catch:{ all -> 0x019f }
        r2 = java.lang.Math.max(r2, r4);	 Catch:{ all -> 0x019f }
    L_0x0038:
        r6 = r6 + 1;
        r4 = r2;
        goto L_0x0020;
    L_0x003c:
        r2 = 0;
        r2 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1));
        if (r2 != 0) goto L_0x004a;
    L_0x0042:
        r2 = 0;
        r14.aiW = r2;
        android.support.v4.os.f.endSection();
        goto L_0x0015;
    L_0x004a:
        r2 = java.util.concurrent.TimeUnit.MILLISECONDS;	 Catch:{ all -> 0x019f }
        r2 = r2.toNanos(r4);	 Catch:{ all -> 0x019f }
        r4 = r14.aiX;	 Catch:{ all -> 0x019f }
        r6 = r2 + r4;
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r10 = r2.size();	 Catch:{ all -> 0x019f }
        r3 = 0;
        r2 = 0;
        r4 = r2;
    L_0x005d:
        if (r4 >= r10) goto L_0x007c;
    L_0x005f:
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r2 = r2.get(r4);	 Catch:{ all -> 0x019f }
        r2 = (android.support.v7.widget.RecyclerView) r2;	 Catch:{ all -> 0x019f }
        r5 = r2.getWindowVisibility();	 Catch:{ all -> 0x019f }
        if (r5 != 0) goto L_0x01b4;
    L_0x006d:
        r5 = r2.anX;	 Catch:{ all -> 0x019f }
        r8 = 0;
        r5.a(r2, r8);	 Catch:{ all -> 0x019f }
        r2 = r2.anX;	 Catch:{ all -> 0x019f }
        r2 = r2.mCount;	 Catch:{ all -> 0x019f }
        r2 = r2 + r3;
    L_0x0078:
        r4 = r4 + 1;
        r3 = r2;
        goto L_0x005d;
    L_0x007c:
        r2 = r14.aiY;	 Catch:{ all -> 0x019f }
        r2.ensureCapacity(r3);	 Catch:{ all -> 0x019f }
        r3 = 0;
        r2 = 0;
        r9 = r2;
    L_0x0084:
        if (r9 >= r10) goto L_0x00ef;
    L_0x0086:
        r2 = r14.aiV;	 Catch:{ all -> 0x019f }
        r2 = r2.get(r9);	 Catch:{ all -> 0x019f }
        r2 = (android.support.v7.widget.RecyclerView) r2;	 Catch:{ all -> 0x019f }
        r4 = r2.getWindowVisibility();	 Catch:{ all -> 0x019f }
        if (r4 != 0) goto L_0x01b1;
    L_0x0094:
        r11 = r2.anX;	 Catch:{ all -> 0x019f }
        r4 = r11.aja;	 Catch:{ all -> 0x019f }
        r4 = java.lang.Math.abs(r4);	 Catch:{ all -> 0x019f }
        r5 = r11.ajb;	 Catch:{ all -> 0x019f }
        r5 = java.lang.Math.abs(r5);	 Catch:{ all -> 0x019f }
        r12 = r4 + r5;
        r5 = 0;
        r8 = r5;
        r4 = r3;
    L_0x00a7:
        r3 = r11.mCount;	 Catch:{ all -> 0x019f }
        r3 = r3 * 2;
        if (r8 >= r3) goto L_0x00e9;
    L_0x00ad:
        r3 = r14.aiY;	 Catch:{ all -> 0x019f }
        r3 = r3.size();	 Catch:{ all -> 0x019f }
        if (r4 < r3) goto L_0x00dd;
    L_0x00b5:
        r3 = new android.support.v7.widget.af$b;	 Catch:{ all -> 0x019f }
        r3.<init>();	 Catch:{ all -> 0x019f }
        r5 = r14.aiY;	 Catch:{ all -> 0x019f }
        r5.add(r3);	 Catch:{ all -> 0x019f }
        r5 = r3;
    L_0x00c0:
        r3 = r11.ajc;	 Catch:{ all -> 0x019f }
        r13 = r8 + 1;
        r13 = r3[r13];	 Catch:{ all -> 0x019f }
        if (r13 > r12) goto L_0x00e7;
    L_0x00c8:
        r3 = 1;
    L_0x00c9:
        r5.ajd = r3;	 Catch:{ all -> 0x019f }
        r5.aje = r12;	 Catch:{ all -> 0x019f }
        r5.ajf = r13;	 Catch:{ all -> 0x019f }
        r5.ajg = r2;	 Catch:{ all -> 0x019f }
        r3 = r11.ajc;	 Catch:{ all -> 0x019f }
        r3 = r3[r8];	 Catch:{ all -> 0x019f }
        r5.position = r3;	 Catch:{ all -> 0x019f }
        r4 = r4 + 1;
        r3 = r8 + 2;
        r8 = r3;
        goto L_0x00a7;
    L_0x00dd:
        r3 = r14.aiY;	 Catch:{ all -> 0x019f }
        r3 = r3.get(r4);	 Catch:{ all -> 0x019f }
        r3 = (android.support.v7.widget.af.b) r3;	 Catch:{ all -> 0x019f }
        r5 = r3;
        goto L_0x00c0;
    L_0x00e7:
        r3 = 0;
        goto L_0x00c9;
    L_0x00e9:
        r2 = r4;
    L_0x00ea:
        r4 = r9 + 1;
        r3 = r2;
        r9 = r4;
        goto L_0x0084;
    L_0x00ef:
        r2 = r14.aiY;	 Catch:{ all -> 0x019f }
        r3 = aiZ;	 Catch:{ all -> 0x019f }
        java.util.Collections.sort(r2, r3);	 Catch:{ all -> 0x019f }
        r2 = 0;
        r8 = r2;
    L_0x00f8:
        r2 = r14.aiY;	 Catch:{ all -> 0x019f }
        r2 = r2.size();	 Catch:{ all -> 0x019f }
        if (r8 >= r2) goto L_0x01a8;
    L_0x0100:
        r2 = r14.aiY;	 Catch:{ all -> 0x019f }
        r2 = r2.get(r8);	 Catch:{ all -> 0x019f }
        r0 = r2;
        r0 = (android.support.v7.widget.af.b) r0;	 Catch:{ all -> 0x019f }
        r3 = r0;
        r2 = r3.ajg;	 Catch:{ all -> 0x019f }
        if (r2 == 0) goto L_0x01a8;
    L_0x010e:
        r2 = r3.ajd;	 Catch:{ all -> 0x019f }
        if (r2 == 0) goto L_0x0181;
    L_0x0112:
        r4 = 9223372036854775807; // 0x7fffffffffffffff float:NaN double:NaN;
    L_0x0117:
        r2 = r3.ajg;	 Catch:{ all -> 0x019f }
        r9 = r3.position;	 Catch:{ all -> 0x019f }
        r2 = a(r2, r9, r4);	 Catch:{ all -> 0x019f }
        if (r2 == 0) goto L_0x0186;
    L_0x0121:
        r4 = r2.apK;	 Catch:{ all -> 0x019f }
        if (r4 == 0) goto L_0x0186;
    L_0x0125:
        r4 = r2.isBound();	 Catch:{ all -> 0x019f }
        if (r4 == 0) goto L_0x0186;
    L_0x012b:
        r4 = r2.kq();	 Catch:{ all -> 0x019f }
        if (r4 != 0) goto L_0x0186;
    L_0x0131:
        r2 = r2.apK;	 Catch:{ all -> 0x019f }
        r2 = r2.get();	 Catch:{ all -> 0x019f }
        r2 = (android.support.v7.widget.RecyclerView) r2;	 Catch:{ all -> 0x019f }
        if (r2 == 0) goto L_0x0186;
    L_0x013b:
        r4 = r2.anA;	 Catch:{ all -> 0x019f }
        if (r4 == 0) goto L_0x014a;
    L_0x013f:
        r4 = r2.anf;	 Catch:{ all -> 0x019f }
        r4 = r4.hU();	 Catch:{ all -> 0x019f }
        if (r4 == 0) goto L_0x014a;
    L_0x0147:
        r2.jj();	 Catch:{ all -> 0x019f }
    L_0x014a:
        r5 = r2.anX;	 Catch:{ all -> 0x019f }
        r4 = 1;
        r5.a(r2, r4);	 Catch:{ all -> 0x019f }
        r4 = r5.mCount;	 Catch:{ all -> 0x019f }
        if (r4 == 0) goto L_0x0186;
    L_0x0154:
        r4 = "RV Nested Prefetch";
        android.support.v4.os.f.beginSection(r4);	 Catch:{ all -> 0x019a }
        r4 = r2.anY;	 Catch:{ all -> 0x019a }
        r9 = r2.Yq;	 Catch:{ all -> 0x019a }
        r10 = 1;
        r4.aps = r10;	 Catch:{ all -> 0x019a }
        r9 = r9.getItemCount();	 Catch:{ all -> 0x019a }
        r4.apt = r9;	 Catch:{ all -> 0x019a }
        r9 = 0;
        r4.apv = r9;	 Catch:{ all -> 0x019a }
        r9 = 0;
        r4.apw = r9;	 Catch:{ all -> 0x019a }
        r9 = 0;
        r4.apx = r9;	 Catch:{ all -> 0x019a }
        r4 = 0;
    L_0x0171:
        r9 = r5.mCount;	 Catch:{ all -> 0x019a }
        r9 = r9 * 2;
        if (r4 >= r9) goto L_0x0183;
    L_0x0177:
        r9 = r5.ajc;	 Catch:{ all -> 0x019a }
        r9 = r9[r4];	 Catch:{ all -> 0x019a }
        a(r2, r9, r6);	 Catch:{ all -> 0x019a }
        r4 = r4 + 2;
        goto L_0x0171;
    L_0x0181:
        r4 = r6;
        goto L_0x0117;
    L_0x0183:
        android.support.v4.os.f.endSection();	 Catch:{ all -> 0x019f }
    L_0x0186:
        r2 = 0;
        r3.ajd = r2;	 Catch:{ all -> 0x019f }
        r2 = 0;
        r3.aje = r2;	 Catch:{ all -> 0x019f }
        r2 = 0;
        r3.ajf = r2;	 Catch:{ all -> 0x019f }
        r2 = 0;
        r3.ajg = r2;	 Catch:{ all -> 0x019f }
        r2 = 0;
        r3.position = r2;	 Catch:{ all -> 0x019f }
        r2 = r8 + 1;
        r8 = r2;
        goto L_0x00f8;
    L_0x019a:
        r2 = move-exception;
        android.support.v4.os.f.endSection();	 Catch:{ all -> 0x019f }
        throw r2;	 Catch:{ all -> 0x019f }
    L_0x019f:
        r2 = move-exception;
        r4 = 0;
        r14.aiW = r4;
        android.support.v4.os.f.endSection();
        throw r2;
    L_0x01a8:
        r2 = 0;
        r14.aiW = r2;
        android.support.v4.os.f.endSection();
        goto L_0x0015;
    L_0x01b1:
        r2 = r3;
        goto L_0x00ea;
    L_0x01b4:
        r2 = r3;
        goto L_0x0078;
    L_0x01b7:
        r2 = r4;
        goto L_0x0038;
        */
        throw new UnsupportedOperationException("Method not decompiled: android.support.v7.widget.af.run():void");
    }
}
