package N1;

import android.view.View;
import android.view.ViewPropertyAnimator;
import androidx.recyclerview.widget.RecyclerView;
import java.lang.reflect.Field;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class P implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f4486q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ RecyclerView f4487r;

    public /* synthetic */ P(RecyclerView recyclerView, int i) {
        this.f4486q = i;
        this.f4487r = recyclerView;
    }

    @Override // java.lang.Runnable
    public final void run() {
        RecyclerView recyclerView;
        RecyclerView recyclerView2;
        RecyclerView recyclerView3 = this.f4487r;
        int i = 1;
        switch (this.f4486q) {
            case n4.u0.f15495q /* 0 */:
                if (recyclerView3.f9034L && !recyclerView3.isLayoutRequested()) {
                    if (!recyclerView3.f9031J) {
                        recyclerView3.requestLayout();
                    } else if (!recyclerView3.f9040O) {
                        recyclerView3.o();
                    } else {
                        recyclerView3.f9038N = true;
                    }
                    break;
                }
                break;
            default:
                Z z8 = recyclerView3.f9061g0;
                if (z8 != null) {
                    C0214o c0214o = (C0214o) z8;
                    ArrayList arrayList = c0214o.f4603h;
                    boolean zIsEmpty = arrayList.isEmpty();
                    ArrayList arrayList2 = c0214o.f4604j;
                    boolean zIsEmpty2 = arrayList2.isEmpty();
                    ArrayList arrayList3 = c0214o.f4605k;
                    boolean zIsEmpty3 = arrayList3.isEmpty();
                    ArrayList arrayList4 = c0214o.i;
                    boolean zIsEmpty4 = arrayList4.isEmpty();
                    if (zIsEmpty && zIsEmpty2 && zIsEmpty4 && zIsEmpty3) {
                        recyclerView2 = recyclerView3;
                    } else {
                        int size = arrayList.size();
                        recyclerView2 = recyclerView3;
                        int i5 = 0;
                        while (true) {
                            long j8 = c0214o.f4497d;
                            if (i5 < size) {
                                Object obj = arrayList.get(i5);
                                i5 += i;
                                t0 t0Var = (t0) obj;
                                View view = t0Var.f4654a;
                                ViewPropertyAnimator viewPropertyAnimatorAnimate = view.animate();
                                c0214o.f4611q.add(t0Var);
                                viewPropertyAnimatorAnimate.setDuration(j8).alpha(0.0f).setListener(new C0209j(c0214o, t0Var, viewPropertyAnimatorAnimate, view)).start();
                                arrayList = arrayList;
                                i = 1;
                            } else {
                                arrayList.clear();
                                if (!zIsEmpty2) {
                                    ArrayList arrayList5 = new ArrayList();
                                    arrayList5.addAll(arrayList2);
                                    c0214o.f4607m.add(arrayList5);
                                    arrayList2.clear();
                                    RunnableC0208i runnableC0208i = new RunnableC0208i(c0214o, arrayList5, 0);
                                    if (zIsEmpty) {
                                        runnableC0208i.run();
                                    } else {
                                        View view2 = ((C0213n) arrayList5.get(0)).f4589a.f4654a;
                                        Field field = M.J.f4065a;
                                        view2.postOnAnimationDelayed(runnableC0208i, j8);
                                    }
                                }
                                if (!zIsEmpty3) {
                                    ArrayList arrayList6 = new ArrayList();
                                    arrayList6.addAll(arrayList3);
                                    c0214o.f4608n.add(arrayList6);
                                    arrayList3.clear();
                                    RunnableC0208i runnableC0208i2 = new RunnableC0208i(c0214o, arrayList6, 1);
                                    if (zIsEmpty) {
                                        runnableC0208i2.run();
                                    } else {
                                        View view3 = ((C0212m) arrayList6.get(0)).f4582a.f4654a;
                                        Field field2 = M.J.f4065a;
                                        view3.postOnAnimationDelayed(runnableC0208i2, j8);
                                    }
                                }
                                if (!zIsEmpty4) {
                                    ArrayList arrayList7 = new ArrayList();
                                    arrayList7.addAll(arrayList4);
                                    c0214o.f4606l.add(arrayList7);
                                    arrayList4.clear();
                                    RunnableC0208i runnableC0208i3 = new RunnableC0208i(c0214o, arrayList7, 2);
                                    if (zIsEmpty && zIsEmpty2 && zIsEmpty3) {
                                        runnableC0208i3.run();
                                    } else {
                                        if (zIsEmpty) {
                                            j8 = 0;
                                        }
                                        long jMax = Math.max(!zIsEmpty2 ? c0214o.f4498e : 0L, zIsEmpty3 ? 0L : c0214o.f4499f) + j8;
                                        View view4 = ((t0) arrayList7.get(0)).f4654a;
                                        Field field3 = M.J.f4065a;
                                        view4.postOnAnimationDelayed(runnableC0208i3, jMax);
                                    }
                                }
                            }
                        }
                    }
                    recyclerView = recyclerView2;
                } else {
                    recyclerView = recyclerView3;
                }
                recyclerView.f9023E0 = false;
                break;
        }
    }
}
