package androidx.recyclerview.widget;

import android.view.View;
import android.view.ViewPropertyAnimator;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;

/* JADX INFO: renamed from: androidx.recyclerview.widget.x, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class RunnableC1173x implements Runnable {

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

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

    public /* synthetic */ RunnableC1173x(RecyclerView recyclerView, int i6) {
        this.f13192a = i6;
        this.f13193b = recyclerView;
    }

    @Override // java.lang.Runnable
    public final void run() {
        RecyclerView recyclerView = this.f13193b;
        switch (this.f13192a) {
            case 0:
                if (recyclerView.f12962y && !recyclerView.isLayoutRequested()) {
                    if (!recyclerView.f12958w) {
                        recyclerView.requestLayout();
                    } else if (!recyclerView.f12899B) {
                        recyclerView.k();
                    } else {
                        recyclerView.f12897A = true;
                    }
                    break;
                }
                break;
            default:
                G g6 = recyclerView.f12914P;
                if (g6 != null) {
                    C1159i c1159i = (C1159i) g6;
                    ArrayList arrayList = c1159i.f13094h;
                    boolean zIsEmpty = arrayList.isEmpty();
                    ArrayList arrayList2 = c1159i.f13096j;
                    boolean zIsEmpty2 = arrayList2.isEmpty();
                    ArrayList arrayList3 = c1159i.f13097k;
                    boolean zIsEmpty3 = arrayList3.isEmpty();
                    ArrayList arrayList4 = c1159i.f13095i;
                    boolean zIsEmpty4 = arrayList4.isEmpty();
                    if (!zIsEmpty || !zIsEmpty2 || !zIsEmpty4 || !zIsEmpty3) {
                        Iterator it = arrayList.iterator();
                        while (true) {
                            boolean zHasNext = it.hasNext();
                            long j4 = c1159i.f12825d;
                            if (zHasNext) {
                                Z z6 = (Z) it.next();
                                View view = z6.itemView;
                                ViewPropertyAnimator viewPropertyAnimatorAnimate = view.animate();
                                c1159i.f13102q.add(z6);
                                viewPropertyAnimatorAnimate.setDuration(j4).alpha(0.0f).setListener(new C1154d(c1159i, z6, viewPropertyAnimatorAnimate, view)).start();
                                arrayList = arrayList;
                            } else {
                                arrayList.clear();
                                if (!zIsEmpty2) {
                                    ArrayList arrayList5 = new ArrayList();
                                    arrayList5.addAll(arrayList2);
                                    c1159i.f13098m.add(arrayList5);
                                    arrayList2.clear();
                                    RunnableC1153c runnableC1153c = new RunnableC1153c(c1159i, arrayList5, 0);
                                    if (zIsEmpty) {
                                        runnableC1153c.run();
                                    } else {
                                        View view2 = ((C1158h) arrayList5.get(0)).f13082a.itemView;
                                        Field field = F1.F.f1367a;
                                        view2.postOnAnimationDelayed(runnableC1153c, j4);
                                    }
                                }
                                if (!zIsEmpty3) {
                                    ArrayList arrayList6 = new ArrayList();
                                    arrayList6.addAll(arrayList3);
                                    c1159i.f13099n.add(arrayList6);
                                    arrayList3.clear();
                                    RunnableC1153c runnableC1153c2 = new RunnableC1153c(c1159i, arrayList6, 1);
                                    if (zIsEmpty) {
                                        runnableC1153c2.run();
                                    } else {
                                        View view3 = ((C1157g) arrayList6.get(0)).f13070a.itemView;
                                        Field field2 = F1.F.f1367a;
                                        view3.postOnAnimationDelayed(runnableC1153c2, j4);
                                    }
                                }
                                if (!zIsEmpty4) {
                                    ArrayList arrayList7 = new ArrayList();
                                    arrayList7.addAll(arrayList4);
                                    c1159i.l.add(arrayList7);
                                    arrayList4.clear();
                                    RunnableC1153c runnableC1153c3 = new RunnableC1153c(c1159i, arrayList7, 2);
                                    if (zIsEmpty && zIsEmpty2 && zIsEmpty3) {
                                        runnableC1153c3.run();
                                    } else {
                                        if (zIsEmpty) {
                                            j4 = 0;
                                        }
                                        long jMax = Math.max(!zIsEmpty2 ? c1159i.f12826e : 0L, zIsEmpty3 ? 0L : c1159i.f12827f) + j4;
                                        View view4 = ((Z) arrayList7.get(0)).itemView;
                                        Field field3 = F1.F.f1367a;
                                        view4.postOnAnimationDelayed(runnableC1153c3, jMax);
                                    }
                                }
                            }
                        }
                    }
                }
                recyclerView.f12945p0 = false;
                break;
        }
    }
}
