package d.p.b;

import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;

/* JADX INFO: loaded from: classes.dex */
public class k extends y {

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3268i = new ArrayList<>();

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3269j = new ArrayList<>();

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public ArrayList<b> f3270k = new ArrayList<>();

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public ArrayList<a> f3271l = new ArrayList<>();

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public ArrayList<ArrayList<RecyclerView.z>> f3272m = new ArrayList<>();

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public ArrayList<ArrayList<b>> f3273n = new ArrayList<>();

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ArrayList<ArrayList<a>> f3274o = new ArrayList<>();

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3275p = new ArrayList<>();

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3276q = new ArrayList<>();

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3277r = new ArrayList<>();

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public ArrayList<RecyclerView.z> f3278s = new ArrayList<>();

    public static class a {
        public RecyclerView.z a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public RecyclerView.z f3279b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f3280c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public int f3281d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public int f3282e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public int f3283f;

        public a(RecyclerView.z zVar, RecyclerView.z zVar2, int i2, int i3, int i4, int i5) {
            this.a = zVar;
            this.f3279b = zVar2;
            this.f3280c = i2;
            this.f3281d = i3;
            this.f3282e = i4;
            this.f3283f = i5;
        }

        public String toString() {
            StringBuilder sbF = g.a.a.a.a.F("ChangeInfo{oldHolder=");
            sbF.append(this.a);
            sbF.append(", newHolder=");
            sbF.append(this.f3279b);
            sbF.append(", fromX=");
            sbF.append(this.f3280c);
            sbF.append(", fromY=");
            sbF.append(this.f3281d);
            sbF.append(", toX=");
            sbF.append(this.f3282e);
            sbF.append(", toY=");
            return g.a.a.a.a.w(sbF, this.f3283f, AbstractJsonLexerKt.END_OBJ);
        }
    }

    public static class b {
        public RecyclerView.z a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f3284b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f3285c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public int f3286d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public int f3287e;

        public b(RecyclerView.z zVar, int i2, int i3, int i4, int i5) {
            this.a = zVar;
            this.f3284b = i2;
            this.f3285c = i3;
            this.f3286d = i4;
            this.f3287e = i5;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.i
    public void e(RecyclerView.z zVar) {
        View view = zVar.f833b;
        view.animate().cancel();
        int size = this.f3270k.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            if (this.f3270k.get(size).a == zVar) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                c(zVar);
                this.f3270k.remove(size);
            }
        }
        l(this.f3271l, zVar);
        if (this.f3268i.remove(zVar)) {
            view.setAlpha(1.0f);
            c(zVar);
        }
        if (this.f3269j.remove(zVar)) {
            view.setAlpha(1.0f);
            c(zVar);
        }
        int size2 = this.f3274o.size();
        while (true) {
            size2--;
            if (size2 < 0) {
                break;
            }
            ArrayList<a> arrayList = this.f3274o.get(size2);
            l(arrayList, zVar);
            if (arrayList.isEmpty()) {
                this.f3274o.remove(size2);
            }
        }
        int size3 = this.f3273n.size();
        while (true) {
            size3--;
            if (size3 < 0) {
                break;
            }
            ArrayList<b> arrayList2 = this.f3273n.get(size3);
            int size4 = arrayList2.size();
            while (true) {
                size4--;
                if (size4 < 0) {
                    break;
                }
                if (arrayList2.get(size4).a == zVar) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    c(zVar);
                    arrayList2.remove(size4);
                    if (arrayList2.isEmpty()) {
                        this.f3273n.remove(size3);
                    }
                }
            }
        }
        int size5 = this.f3272m.size();
        while (true) {
            size5--;
            if (size5 < 0) {
                this.f3277r.remove(zVar);
                this.f3275p.remove(zVar);
                this.f3278s.remove(zVar);
                this.f3276q.remove(zVar);
                k();
                return;
            }
            ArrayList<RecyclerView.z> arrayList3 = this.f3272m.get(size5);
            if (arrayList3.remove(zVar)) {
                view.setAlpha(1.0f);
                c(zVar);
                if (arrayList3.isEmpty()) {
                    this.f3272m.remove(size5);
                }
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.i
    public void f() {
        int size = this.f3270k.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            b bVar = this.f3270k.get(size);
            View view = bVar.a.f833b;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            c(bVar.a);
            this.f3270k.remove(size);
        }
        int size2 = this.f3268i.size();
        while (true) {
            size2--;
            if (size2 < 0) {
                break;
            }
            c(this.f3268i.get(size2));
            this.f3268i.remove(size2);
        }
        int size3 = this.f3269j.size();
        while (true) {
            size3--;
            if (size3 < 0) {
                break;
            }
            RecyclerView.z zVar = this.f3269j.get(size3);
            zVar.f833b.setAlpha(1.0f);
            c(zVar);
            this.f3269j.remove(size3);
        }
        int size4 = this.f3271l.size();
        while (true) {
            size4--;
            if (size4 < 0) {
                break;
            }
            a aVar = this.f3271l.get(size4);
            RecyclerView.z zVar2 = aVar.a;
            if (zVar2 != null) {
                m(aVar, zVar2);
            }
            RecyclerView.z zVar3 = aVar.f3279b;
            if (zVar3 != null) {
                m(aVar, zVar3);
            }
        }
        this.f3271l.clear();
        if (!g()) {
            return;
        }
        int size5 = this.f3273n.size();
        while (true) {
            size5--;
            if (size5 < 0) {
                break;
            }
            ArrayList<b> arrayList = this.f3273n.get(size5);
            int size6 = arrayList.size();
            while (true) {
                size6--;
                if (size6 >= 0) {
                    b bVar2 = arrayList.get(size6);
                    View view2 = bVar2.a.f833b;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    c(bVar2.a);
                    arrayList.remove(size6);
                    if (arrayList.isEmpty()) {
                        this.f3273n.remove(arrayList);
                    }
                }
            }
        }
        int size7 = this.f3272m.size();
        while (true) {
            size7--;
            if (size7 < 0) {
                break;
            }
            ArrayList<RecyclerView.z> arrayList2 = this.f3272m.get(size7);
            int size8 = arrayList2.size();
            while (true) {
                size8--;
                if (size8 >= 0) {
                    RecyclerView.z zVar4 = arrayList2.get(size8);
                    zVar4.f833b.setAlpha(1.0f);
                    c(zVar4);
                    arrayList2.remove(size8);
                    if (arrayList2.isEmpty()) {
                        this.f3272m.remove(arrayList2);
                    }
                }
            }
        }
        int size9 = this.f3274o.size();
        while (true) {
            size9--;
            if (size9 < 0) {
                j(this.f3277r);
                j(this.f3276q);
                j(this.f3275p);
                j(this.f3278s);
                d();
                return;
            }
            ArrayList<a> arrayList3 = this.f3274o.get(size9);
            int size10 = arrayList3.size();
            while (true) {
                size10--;
                if (size10 >= 0) {
                    a aVar2 = arrayList3.get(size10);
                    RecyclerView.z zVar5 = aVar2.a;
                    if (zVar5 != null) {
                        m(aVar2, zVar5);
                    }
                    RecyclerView.z zVar6 = aVar2.f3279b;
                    if (zVar6 != null) {
                        m(aVar2, zVar6);
                    }
                    if (arrayList3.isEmpty()) {
                        this.f3274o.remove(arrayList3);
                    }
                }
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.i
    public boolean g() {
        return (this.f3269j.isEmpty() && this.f3271l.isEmpty() && this.f3270k.isEmpty() && this.f3268i.isEmpty() && this.f3276q.isEmpty() && this.f3277r.isEmpty() && this.f3275p.isEmpty() && this.f3278s.isEmpty() && this.f3273n.isEmpty() && this.f3272m.isEmpty() && this.f3274o.isEmpty()) ? false : true;
    }

    @Override // d.p.b.y
    public boolean i(RecyclerView.z zVar, int i2, int i3, int i4, int i5) {
        View view = zVar.f833b;
        int translationX = i2 + ((int) view.getTranslationX());
        int translationY = i3 + ((int) zVar.f833b.getTranslationY());
        n(zVar);
        int i6 = i4 - translationX;
        int i7 = i5 - translationY;
        if (i6 == 0 && i7 == 0) {
            c(zVar);
            return false;
        }
        if (i6 != 0) {
            view.setTranslationX(-i6);
        }
        if (i7 != 0) {
            view.setTranslationY(-i7);
        }
        this.f3270k.add(new b(zVar, translationX, translationY, i4, i5));
        return true;
    }

    public void j(List<RecyclerView.z> list) {
        int size = list.size();
        while (true) {
            size--;
            if (size < 0) {
                return;
            } else {
                list.get(size).f833b.animate().cancel();
            }
        }
    }

    public void k() {
        if (g()) {
            return;
        }
        d();
    }

    public final void l(List<a> list, RecyclerView.z zVar) {
        int size = list.size();
        while (true) {
            size--;
            if (size < 0) {
                return;
            }
            a aVar = list.get(size);
            if (m(aVar, zVar) && aVar.a == null && aVar.f3279b == null) {
                list.remove(aVar);
            }
        }
    }

    public final boolean m(a aVar, RecyclerView.z zVar) {
        if (aVar.f3279b == zVar) {
            aVar.f3279b = null;
        } else {
            if (aVar.a != zVar) {
                return false;
            }
            aVar.a = null;
        }
        zVar.f833b.setAlpha(1.0f);
        zVar.f833b.setTranslationX(0.0f);
        zVar.f833b.setTranslationY(0.0f);
        c(zVar);
        return true;
    }

    public final void n(RecyclerView.z zVar) {
        if (f3267h == null) {
            f3267h = new ValueAnimator().getInterpolator();
        }
        zVar.f833b.animate().setInterpolator(f3267h);
        e(zVar);
    }
}
