package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.mq, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1899mq extends AbstractC0775b10 {
    public static TimeInterpolator s;
    public boolean g;
    public ArrayList h;
    public ArrayList i;
    public ArrayList j;
    public ArrayList k;
    public ArrayList l;
    public ArrayList m;
    public ArrayList n;

    /* renamed from: o, reason: collision with root package name */
    public ArrayList f640o;
    public ArrayList p;
    public ArrayList q;
    public ArrayList r;

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

    @Override // o.AbstractC0775b10
    public final boolean a(AbstractC2488t10 abstractC2488t10, AbstractC2488t10 abstractC2488t102, KZ kz, KZ kz2) {
        int i;
        int i2;
        int i3 = kz.b;
        int i4 = kz.c;
        if (abstractC2488t102.o()) {
            int i5 = kz.b;
            i2 = kz.c;
            i = i5;
        } else {
            i = kz2.b;
            i2 = kz2.c;
        }
        if (abstractC2488t10 == abstractC2488t102) {
            return g(abstractC2488t10, i3, i4, i, i2);
        }
        View view = abstractC2488t10.a;
        float translationX = view.getTranslationX();
        float translationY = view.getTranslationY();
        float alpha = view.getAlpha();
        l(abstractC2488t10);
        view.setTranslationX(translationX);
        view.setTranslationY(translationY);
        view.setAlpha(alpha);
        View view2 = abstractC2488t102.a;
        l(abstractC2488t102);
        view2.setTranslationX(-((int) ((i - i3) - translationX)));
        view2.setTranslationY(-((int) ((i2 - i4) - translationY)));
        view2.setAlpha(0.0f);
        ArrayList arrayList = this.k;
        C1709kq c1709kq = new C1709kq();
        c1709kq.a = abstractC2488t10;
        c1709kq.b = abstractC2488t102;
        c1709kq.c = i3;
        c1709kq.d = i4;
        c1709kq.e = i;
        c1709kq.f = i2;
        arrayList.add(c1709kq);
        return true;
    }

    @Override // o.AbstractC0775b10
    public final void d(AbstractC2488t10 abstractC2488t10) {
        ArrayList arrayList = this.l;
        ArrayList arrayList2 = this.m;
        ArrayList arrayList3 = this.n;
        View view = abstractC2488t10.a;
        view.animate().cancel();
        ArrayList arrayList4 = this.j;
        int size = arrayList4.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            if (((C1804lq) arrayList4.get(size)).a == abstractC2488t10) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                c(abstractC2488t10);
                arrayList4.remove(size);
            }
        }
        j(this.k, abstractC2488t10);
        if (this.h.remove(abstractC2488t10)) {
            view.setAlpha(1.0f);
            c(abstractC2488t10);
        }
        if (this.i.remove(abstractC2488t10)) {
            view.setAlpha(1.0f);
            c(abstractC2488t10);
        }
        for (int size2 = arrayList3.size() - 1; size2 >= 0; size2--) {
            ArrayList arrayList5 = (ArrayList) arrayList3.get(size2);
            j(arrayList5, abstractC2488t10);
            if (arrayList5.isEmpty()) {
                arrayList3.remove(size2);
            }
        }
        for (int size3 = arrayList2.size() - 1; size3 >= 0; size3--) {
            ArrayList arrayList6 = (ArrayList) arrayList2.get(size3);
            int size4 = arrayList6.size() - 1;
            while (true) {
                if (size4 < 0) {
                    break;
                }
                if (((C1804lq) arrayList6.get(size4)).a == abstractC2488t10) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    c(abstractC2488t10);
                    arrayList6.remove(size4);
                    if (arrayList6.isEmpty()) {
                        arrayList2.remove(size3);
                    }
                } else {
                    size4--;
                }
            }
        }
        for (int size5 = arrayList.size() - 1; size5 >= 0; size5--) {
            ArrayList arrayList7 = (ArrayList) arrayList.get(size5);
            if (arrayList7.remove(abstractC2488t10)) {
                view.setAlpha(1.0f);
                c(abstractC2488t10);
                if (arrayList7.isEmpty()) {
                    arrayList.remove(size5);
                }
            }
        }
        this.q.remove(abstractC2488t10);
        this.f640o.remove(abstractC2488t10);
        this.r.remove(abstractC2488t10);
        this.p.remove(abstractC2488t10);
        i();
    }

    @Override // o.AbstractC0775b10
    public final void e() {
        ArrayList arrayList = this.n;
        ArrayList arrayList2 = this.l;
        ArrayList arrayList3 = this.m;
        ArrayList arrayList4 = this.k;
        ArrayList arrayList5 = this.i;
        ArrayList arrayList6 = this.h;
        ArrayList arrayList7 = this.j;
        int size = arrayList7.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            C1804lq c1804lq = (C1804lq) arrayList7.get(size);
            View view = c1804lq.a.a;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            c(c1804lq.a);
            arrayList7.remove(size);
        }
        for (int size2 = arrayList6.size() - 1; size2 >= 0; size2--) {
            c((AbstractC2488t10) arrayList6.get(size2));
            arrayList6.remove(size2);
        }
        int size3 = arrayList5.size();
        while (true) {
            size3--;
            if (size3 < 0) {
                break;
            }
            AbstractC2488t10 abstractC2488t10 = (AbstractC2488t10) arrayList5.get(size3);
            abstractC2488t10.a.setAlpha(1.0f);
            c(abstractC2488t10);
            arrayList5.remove(size3);
        }
        for (int size4 = arrayList4.size() - 1; size4 >= 0; size4--) {
            C1709kq c1709kq = (C1709kq) arrayList4.get(size4);
            AbstractC2488t10 abstractC2488t102 = c1709kq.a;
            if (abstractC2488t102 != null) {
                k(c1709kq, abstractC2488t102);
            }
            AbstractC2488t10 abstractC2488t103 = c1709kq.b;
            if (abstractC2488t103 != null) {
                k(c1709kq, abstractC2488t103);
            }
        }
        arrayList4.clear();
        if (f()) {
            for (int size5 = arrayList3.size() - 1; size5 >= 0; size5--) {
                ArrayList arrayList8 = (ArrayList) arrayList3.get(size5);
                for (int size6 = arrayList8.size() - 1; size6 >= 0; size6--) {
                    C1804lq c1804lq2 = (C1804lq) arrayList8.get(size6);
                    View view2 = c1804lq2.a.a;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    c(c1804lq2.a);
                    arrayList8.remove(size6);
                    if (arrayList8.isEmpty()) {
                        arrayList3.remove(arrayList8);
                    }
                }
            }
            for (int size7 = arrayList2.size() - 1; size7 >= 0; size7--) {
                ArrayList arrayList9 = (ArrayList) arrayList2.get(size7);
                for (int size8 = arrayList9.size() - 1; size8 >= 0; size8--) {
                    AbstractC2488t10 abstractC2488t104 = (AbstractC2488t10) arrayList9.get(size8);
                    abstractC2488t104.a.setAlpha(1.0f);
                    c(abstractC2488t104);
                    arrayList9.remove(size8);
                    if (arrayList9.isEmpty()) {
                        arrayList2.remove(arrayList9);
                    }
                }
            }
            for (int size9 = arrayList.size() - 1; size9 >= 0; size9--) {
                ArrayList arrayList10 = (ArrayList) arrayList.get(size9);
                for (int size10 = arrayList10.size() - 1; size10 >= 0; size10--) {
                    C1709kq c1709kq2 = (C1709kq) arrayList10.get(size10);
                    AbstractC2488t10 abstractC2488t105 = c1709kq2.a;
                    if (abstractC2488t105 != null) {
                        k(c1709kq2, abstractC2488t105);
                    }
                    AbstractC2488t10 abstractC2488t106 = c1709kq2.b;
                    if (abstractC2488t106 != null) {
                        k(c1709kq2, abstractC2488t106);
                    }
                    if (arrayList10.isEmpty()) {
                        arrayList.remove(arrayList10);
                    }
                }
            }
            h(this.q);
            h(this.p);
            h(this.f640o);
            h(this.r);
            ArrayList arrayList11 = this.b;
            if (arrayList11.size() > 0) {
                arrayList11.get(0).getClass();
                throw new ClassCastException();
            }
            arrayList11.clear();
        }
    }

    @Override // o.AbstractC0775b10
    public final boolean f() {
        return (this.i.isEmpty() && this.k.isEmpty() && this.j.isEmpty() && this.h.isEmpty() && this.p.isEmpty() && this.q.isEmpty() && this.f640o.isEmpty() && this.r.isEmpty() && this.m.isEmpty() && this.l.isEmpty() && this.n.isEmpty()) ? false : true;
    }

    public final boolean g(AbstractC2488t10 abstractC2488t10, int i, int i2, int i3, int i4) {
        View view = abstractC2488t10.a;
        int translationX = i + ((int) view.getTranslationX());
        int translationY = i2 + ((int) abstractC2488t10.a.getTranslationY());
        l(abstractC2488t10);
        int i5 = i3 - translationX;
        int i6 = i4 - translationY;
        if (i5 == 0 && i6 == 0) {
            c(abstractC2488t10);
            return false;
        }
        if (i5 != 0) {
            view.setTranslationX(-i5);
        }
        if (i6 != 0) {
            view.setTranslationY(-i6);
        }
        ArrayList arrayList = this.j;
        C1804lq c1804lq = new C1804lq();
        c1804lq.a = abstractC2488t10;
        c1804lq.b = translationX;
        c1804lq.c = translationY;
        c1804lq.d = i3;
        c1804lq.e = i4;
        arrayList.add(c1804lq);
        return true;
    }

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

    public final void j(ArrayList arrayList, AbstractC2488t10 abstractC2488t10) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            C1709kq c1709kq = (C1709kq) arrayList.get(size);
            if (k(c1709kq, abstractC2488t10) && c1709kq.a == null && c1709kq.b == null) {
                arrayList.remove(c1709kq);
            }
        }
    }

    public final boolean k(C1709kq c1709kq, AbstractC2488t10 abstractC2488t10) {
        if (c1709kq.b == abstractC2488t10) {
            c1709kq.b = null;
        } else {
            if (c1709kq.a != abstractC2488t10) {
                return false;
            }
            c1709kq.a = null;
        }
        View view = abstractC2488t10.a;
        View view2 = abstractC2488t10.a;
        view.setAlpha(1.0f);
        view2.setTranslationX(0.0f);
        view2.setTranslationY(0.0f);
        c(abstractC2488t10);
        return true;
    }

    public final void l(AbstractC2488t10 abstractC2488t10) {
        if (s == null) {
            s = new ValueAnimator().getInterpolator();
        }
        abstractC2488t10.a.animate().setInterpolator(s);
        d(abstractC2488t10);
    }
}
