package androidx.recyclerview.widget;

import F1.C0186o;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import java.util.ArrayList;

/* JADX INFO: renamed from: androidx.recyclerview.widget.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1159i extends G {

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static TimeInterpolator f13092s;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f13093g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public ArrayList f13094h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public ArrayList f13095i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public ArrayList f13096j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public ArrayList f13097k;
    public ArrayList l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public ArrayList f13098m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public ArrayList f13099n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ArrayList f13100o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public ArrayList f13101p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public ArrayList f13102q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public ArrayList f13103r;

    public static void h(ArrayList arrayList) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            ((Z) arrayList.get(size)).itemView.animate().cancel();
        }
    }

    @Override // androidx.recyclerview.widget.G
    public final boolean a(Z z6, Z z7, C0186o c0186o, C0186o c0186o2) {
        int i6;
        int i7;
        int i8 = c0186o.f1462a;
        int i9 = c0186o.f1463b;
        if (z7.shouldIgnore()) {
            int i10 = c0186o.f1462a;
            i7 = c0186o.f1463b;
            i6 = i10;
        } else {
            i6 = c0186o2.f1462a;
            i7 = c0186o2.f1463b;
        }
        if (z6 == z7) {
            return g(z6, i8, i9, i6, i7);
        }
        float translationX = z6.itemView.getTranslationX();
        float translationY = z6.itemView.getTranslationY();
        float alpha = z6.itemView.getAlpha();
        l(z6);
        z6.itemView.setTranslationX(translationX);
        z6.itemView.setTranslationY(translationY);
        z6.itemView.setAlpha(alpha);
        l(z7);
        z7.itemView.setTranslationX(-((int) ((i6 - i8) - translationX)));
        z7.itemView.setTranslationY(-((int) ((i7 - i9) - translationY)));
        z7.itemView.setAlpha(0.0f);
        ArrayList arrayList = this.f13097k;
        C1157g c1157g = new C1157g();
        c1157g.f13070a = z6;
        c1157g.f13071b = z7;
        c1157g.f13072c = i8;
        c1157g.f13073d = i9;
        c1157g.f13074e = i6;
        c1157g.f13075f = i7;
        arrayList.add(c1157g);
        return true;
    }

    @Override // androidx.recyclerview.widget.G
    public final void d(Z z6) {
        View view = z6.itemView;
        view.animate().cancel();
        ArrayList arrayList = this.f13096j;
        int size = arrayList.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            if (((C1158h) arrayList.get(size)).f13082a == z6) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                c(z6);
                arrayList.remove(size);
            }
        }
        j(this.f13097k, z6);
        if (this.f13094h.remove(z6)) {
            view.setAlpha(1.0f);
            c(z6);
        }
        if (this.f13095i.remove(z6)) {
            view.setAlpha(1.0f);
            c(z6);
        }
        ArrayList arrayList2 = this.f13099n;
        for (int size2 = arrayList2.size() - 1; size2 >= 0; size2--) {
            ArrayList arrayList3 = (ArrayList) arrayList2.get(size2);
            j(arrayList3, z6);
            if (arrayList3.isEmpty()) {
                arrayList2.remove(size2);
            }
        }
        ArrayList arrayList4 = this.f13098m;
        for (int size3 = arrayList4.size() - 1; size3 >= 0; size3--) {
            ArrayList arrayList5 = (ArrayList) arrayList4.get(size3);
            int size4 = arrayList5.size() - 1;
            while (true) {
                if (size4 < 0) {
                    break;
                }
                if (((C1158h) arrayList5.get(size4)).f13082a == z6) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    c(z6);
                    arrayList5.remove(size4);
                    if (arrayList5.isEmpty()) {
                        arrayList4.remove(size3);
                    }
                } else {
                    size4--;
                }
            }
        }
        ArrayList arrayList6 = this.l;
        for (int size5 = arrayList6.size() - 1; size5 >= 0; size5--) {
            ArrayList arrayList7 = (ArrayList) arrayList6.get(size5);
            if (arrayList7.remove(z6)) {
                view.setAlpha(1.0f);
                c(z6);
                if (arrayList7.isEmpty()) {
                    arrayList6.remove(size5);
                }
            }
        }
        this.f13102q.remove(z6);
        this.f13100o.remove(z6);
        this.f13103r.remove(z6);
        this.f13101p.remove(z6);
        i();
    }

    @Override // androidx.recyclerview.widget.G
    public final void e() {
        ArrayList arrayList = this.f13096j;
        int size = arrayList.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            C1158h c1158h = (C1158h) arrayList.get(size);
            View view = c1158h.f13082a.itemView;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            c(c1158h.f13082a);
            arrayList.remove(size);
        }
        ArrayList arrayList2 = this.f13094h;
        for (int size2 = arrayList2.size() - 1; size2 >= 0; size2--) {
            c((Z) arrayList2.get(size2));
            arrayList2.remove(size2);
        }
        ArrayList arrayList3 = this.f13095i;
        int size3 = arrayList3.size();
        while (true) {
            size3--;
            if (size3 < 0) {
                break;
            }
            Z z6 = (Z) arrayList3.get(size3);
            z6.itemView.setAlpha(1.0f);
            c(z6);
            arrayList3.remove(size3);
        }
        ArrayList arrayList4 = this.f13097k;
        for (int size4 = arrayList4.size() - 1; size4 >= 0; size4--) {
            C1157g c1157g = (C1157g) arrayList4.get(size4);
            Z z7 = c1157g.f13070a;
            if (z7 != null) {
                k(c1157g, z7);
            }
            Z z8 = c1157g.f13071b;
            if (z8 != null) {
                k(c1157g, z8);
            }
        }
        arrayList4.clear();
        if (f()) {
            ArrayList arrayList5 = this.f13098m;
            for (int size5 = arrayList5.size() - 1; size5 >= 0; size5--) {
                ArrayList arrayList6 = (ArrayList) arrayList5.get(size5);
                for (int size6 = arrayList6.size() - 1; size6 >= 0; size6--) {
                    C1158h c1158h2 = (C1158h) arrayList6.get(size6);
                    View view2 = c1158h2.f13082a.itemView;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    c(c1158h2.f13082a);
                    arrayList6.remove(size6);
                    if (arrayList6.isEmpty()) {
                        arrayList5.remove(arrayList6);
                    }
                }
            }
            ArrayList arrayList7 = this.l;
            for (int size7 = arrayList7.size() - 1; size7 >= 0; size7--) {
                ArrayList arrayList8 = (ArrayList) arrayList7.get(size7);
                for (int size8 = arrayList8.size() - 1; size8 >= 0; size8--) {
                    Z z9 = (Z) arrayList8.get(size8);
                    z9.itemView.setAlpha(1.0f);
                    c(z9);
                    arrayList8.remove(size8);
                    if (arrayList8.isEmpty()) {
                        arrayList7.remove(arrayList8);
                    }
                }
            }
            ArrayList arrayList9 = this.f13099n;
            for (int size9 = arrayList9.size() - 1; size9 >= 0; size9--) {
                ArrayList arrayList10 = (ArrayList) arrayList9.get(size9);
                for (int size10 = arrayList10.size() - 1; size10 >= 0; size10--) {
                    C1157g c1157g2 = (C1157g) arrayList10.get(size10);
                    Z z10 = c1157g2.f13070a;
                    if (z10 != null) {
                        k(c1157g2, z10);
                    }
                    Z z11 = c1157g2.f13071b;
                    if (z11 != null) {
                        k(c1157g2, z11);
                    }
                    if (arrayList10.isEmpty()) {
                        arrayList9.remove(arrayList10);
                    }
                }
            }
            h(this.f13102q);
            h(this.f13101p);
            h(this.f13100o);
            h(this.f13103r);
            ArrayList arrayList11 = this.f12823b;
            if (arrayList11.size() > 0) {
                arrayList11.get(0).getClass();
                throw new ClassCastException();
            }
            arrayList11.clear();
        }
    }

    @Override // androidx.recyclerview.widget.G
    public final boolean f() {
        return (this.f13095i.isEmpty() && this.f13097k.isEmpty() && this.f13096j.isEmpty() && this.f13094h.isEmpty() && this.f13101p.isEmpty() && this.f13102q.isEmpty() && this.f13100o.isEmpty() && this.f13103r.isEmpty() && this.f13098m.isEmpty() && this.l.isEmpty() && this.f13099n.isEmpty()) ? false : true;
    }

    public final boolean g(Z z6, int i6, int i7, int i8, int i9) {
        View view = z6.itemView;
        int translationX = i6 + ((int) view.getTranslationX());
        int translationY = i7 + ((int) z6.itemView.getTranslationY());
        l(z6);
        int i10 = i8 - translationX;
        int i11 = i9 - translationY;
        if (i10 == 0 && i11 == 0) {
            c(z6);
            return false;
        }
        if (i10 != 0) {
            view.setTranslationX(-i10);
        }
        if (i11 != 0) {
            view.setTranslationY(-i11);
        }
        ArrayList arrayList = this.f13096j;
        C1158h c1158h = new C1158h();
        c1158h.f13082a = z6;
        c1158h.f13083b = translationX;
        c1158h.f13084c = translationY;
        c1158h.f13085d = i8;
        c1158h.f13086e = i9;
        arrayList.add(c1158h);
        return true;
    }

    public final void i() {
        if (f()) {
            return;
        }
        ArrayList arrayList = this.f12823b;
        if (arrayList.size() <= 0) {
            arrayList.clear();
        } else {
            arrayList.get(0).getClass();
            throw new ClassCastException();
        }
    }

    public final void j(ArrayList arrayList, Z z6) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            C1157g c1157g = (C1157g) arrayList.get(size);
            if (k(c1157g, z6) && c1157g.f13070a == null && c1157g.f13071b == null) {
                arrayList.remove(c1157g);
            }
        }
    }

    public final boolean k(C1157g c1157g, Z z6) {
        if (c1157g.f13071b == z6) {
            c1157g.f13071b = null;
        } else {
            if (c1157g.f13070a != z6) {
                return false;
            }
            c1157g.f13070a = null;
        }
        z6.itemView.setAlpha(1.0f);
        z6.itemView.setTranslationX(0.0f);
        z6.itemView.setTranslationY(0.0f);
        c(z6);
        return true;
    }

    public final void l(Z z6) {
        if (f13092s == null) {
            f13092s = new ValueAnimator().getInterpolator();
        }
        z6.itemView.animate().setInterpolator(f13092s);
        d(z6);
    }
}
