package androidx.recyclerview.widget;

import android.view.View;
import android.view.ViewPropertyAnimator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;

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

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

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

    public /* synthetic */ a1(RecyclerView recyclerView, int i10) {
        this.f3661a = i10;
        this.f3662b = recyclerView;
    }

    @Override // java.lang.Runnable
    public final void run() {
        int i10 = this.f3661a;
        RecyclerView recyclerView = this.f3662b;
        switch (i10) {
            case 0:
                if (recyclerView.mFirstLayoutComplete && !recyclerView.isLayoutRequested()) {
                    if (!recyclerView.mIsAttached) {
                        recyclerView.requestLayout();
                    } else if (!recyclerView.mLayoutSuppressed) {
                        recyclerView.consumePendingUpdateOperations();
                    } else {
                        recyclerView.mLayoutWasDefered = true;
                    }
                    break;
                }
                break;
            default:
                l1 l1Var = recyclerView.mItemAnimator;
                if (l1Var != null) {
                    p pVar = (p) l1Var;
                    ArrayList arrayList = pVar.f3835h;
                    boolean z10 = !arrayList.isEmpty();
                    ArrayList arrayList2 = pVar.f3837j;
                    boolean z11 = !arrayList2.isEmpty();
                    ArrayList arrayList3 = pVar.f3838k;
                    boolean z12 = !arrayList3.isEmpty();
                    ArrayList arrayList4 = pVar.f3836i;
                    boolean zIsEmpty = true ^ arrayList4.isEmpty();
                    if (z10 || z11 || zIsEmpty || z12) {
                        Iterator it = arrayList.iterator();
                        while (true) {
                            boolean zHasNext = it.hasNext();
                            long j10 = pVar.f3774d;
                            if (zHasNext) {
                                j2 j2Var = (j2) it.next();
                                View view = j2Var.itemView;
                                ViewPropertyAnimator viewPropertyAnimatorAnimate = view.animate();
                                pVar.f3844q.add(j2Var);
                                viewPropertyAnimatorAnimate.setDuration(j10).alpha(0.0f).setListener(new i(view, viewPropertyAnimatorAnimate, pVar, j2Var)).start();
                                it = it;
                            } else {
                                arrayList.clear();
                                if (z11) {
                                    ArrayList arrayList5 = new ArrayList();
                                    arrayList5.addAll(arrayList2);
                                    pVar.f3840m.add(arrayList5);
                                    arrayList2.clear();
                                    g gVar = new g(pVar, arrayList5);
                                    if (z10) {
                                        View view2 = ((o) arrayList5.get(0)).f3820a.itemView;
                                        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
                                        view2.postOnAnimationDelayed(gVar, j10);
                                    } else {
                                        gVar.run();
                                    }
                                }
                                if (z12) {
                                    ArrayList arrayList6 = new ArrayList();
                                    arrayList6.addAll(arrayList3);
                                    pVar.f3841n.add(arrayList6);
                                    arrayList3.clear();
                                    l.l lVar = new l.l(pVar, arrayList6, 7);
                                    if (z10) {
                                        View view3 = ((n) arrayList6.get(0)).f3784a.itemView;
                                        WeakHashMap weakHashMap2 = androidx.core.view.s1.f1815a;
                                        view3.postOnAnimationDelayed(lVar, j10);
                                    } else {
                                        lVar.run();
                                    }
                                }
                                if (zIsEmpty) {
                                    ArrayList arrayList7 = new ArrayList();
                                    arrayList7.addAll(arrayList4);
                                    pVar.f3839l.add(arrayList7);
                                    arrayList4.clear();
                                    h hVar = new h(pVar, arrayList7);
                                    if (z10 || z11 || z12) {
                                        if (!z10) {
                                            j10 = 0;
                                        }
                                        long jMax = Math.max(z11 ? pVar.f3775e : 0L, z12 ? pVar.f3776f : 0L) + j10;
                                        View view4 = ((j2) arrayList7.get(0)).itemView;
                                        WeakHashMap weakHashMap3 = androidx.core.view.s1.f1815a;
                                        view4.postOnAnimationDelayed(hVar, jMax);
                                    } else {
                                        hVar.run();
                                    }
                                }
                            }
                        }
                    }
                }
                recyclerView.mPostedAnimatorRunner = false;
                break;
        }
    }
}
