package androidx.recyclerview.widget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.view.View; import android.view.ViewPropertyAnimator; import androidx.core.view.n0; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /* loaded from: classes.dex */ public class c extends n { /* renamed from: s, reason: collision with root package name */ private static TimeInterpolator f2389s; /* renamed from: h, reason: collision with root package name */ private ArrayList f2390h = new ArrayList(); /* renamed from: i, reason: collision with root package name */ private ArrayList f2391i = new ArrayList(); /* renamed from: j, reason: collision with root package name */ private ArrayList f2392j = new ArrayList(); /* renamed from: k, reason: collision with root package name */ private ArrayList f2393k = new ArrayList(); /* renamed from: l, reason: collision with root package name */ ArrayList f2394l = new ArrayList(); /* renamed from: m, reason: collision with root package name */ ArrayList f2395m = new ArrayList(); /* renamed from: n, reason: collision with root package name */ ArrayList f2396n = new ArrayList(); /* renamed from: o, reason: collision with root package name */ ArrayList f2397o = new ArrayList(); /* renamed from: p, reason: collision with root package name */ ArrayList f2398p = new ArrayList(); /* renamed from: q, reason: collision with root package name */ ArrayList f2399q = new ArrayList(); /* renamed from: r, reason: collision with root package name */ ArrayList f2400r = new ArrayList(); class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ArrayList f2401a; a(ArrayList arrayList) { this.f2401a = arrayList; } @Override // java.lang.Runnable public void run() { Iterator it = this.f2401a.iterator(); while (it.hasNext()) { j jVar = (j) it.next(); c.this.S(jVar.f2435a, jVar.f2436b, jVar.f2437c, jVar.f2438d, jVar.f2439e); } this.f2401a.clear(); c.this.f2395m.remove(this.f2401a); } } class b implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ArrayList f2403a; b(ArrayList arrayList) { this.f2403a = arrayList; } @Override // java.lang.Runnable public void run() { Iterator it = this.f2403a.iterator(); while (it.hasNext()) { c.this.R((i) it.next()); } this.f2403a.clear(); c.this.f2396n.remove(this.f2403a); } } /* renamed from: androidx.recyclerview.widget.c$c, reason: collision with other inner class name */ class RunnableC0035c implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ArrayList f2405a; RunnableC0035c(ArrayList arrayList) { this.f2405a = arrayList; } @Override // java.lang.Runnable public void run() { Iterator it = this.f2405a.iterator(); while (it.hasNext()) { c.this.Q((RecyclerView.d0) it.next()); } this.f2405a.clear(); c.this.f2394l.remove(this.f2405a); } } class d extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ RecyclerView.d0 f2407a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ ViewPropertyAnimator f2408b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ View f2409c; d(RecyclerView.d0 d0Var, ViewPropertyAnimator viewPropertyAnimator, View view) { this.f2407a = d0Var; this.f2408b = viewPropertyAnimator; this.f2409c = view; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f2408b.setListener(null); this.f2409c.setAlpha(1.0f); c.this.G(this.f2407a); c.this.f2399q.remove(this.f2407a); c.this.V(); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { c.this.H(this.f2407a); } } class e extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ RecyclerView.d0 f2411a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ View f2412b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ ViewPropertyAnimator f2413c; e(RecyclerView.d0 d0Var, View view, ViewPropertyAnimator viewPropertyAnimator) { this.f2411a = d0Var; this.f2412b = view; this.f2413c = viewPropertyAnimator; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationCancel(Animator animator) { this.f2412b.setAlpha(1.0f); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f2413c.setListener(null); c.this.A(this.f2411a); c.this.f2397o.remove(this.f2411a); c.this.V(); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { c.this.B(this.f2411a); } } class f extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ RecyclerView.d0 f2415a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ int f2416b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ View f2417c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ int f2418d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ ViewPropertyAnimator f2419e; f(RecyclerView.d0 d0Var, int i10, View view, int i11, ViewPropertyAnimator viewPropertyAnimator) { this.f2415a = d0Var; this.f2416b = i10; this.f2417c = view; this.f2418d = i11; this.f2419e = viewPropertyAnimator; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationCancel(Animator animator) { if (this.f2416b != 0) { this.f2417c.setTranslationX(0.0f); } if (this.f2418d != 0) { this.f2417c.setTranslationY(0.0f); } } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f2419e.setListener(null); c.this.E(this.f2415a); c.this.f2398p.remove(this.f2415a); c.this.V(); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { c.this.F(this.f2415a); } } class g extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ i f2421a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ ViewPropertyAnimator f2422b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ View f2423c; g(i iVar, ViewPropertyAnimator viewPropertyAnimator, View view) { this.f2421a = iVar; this.f2422b = viewPropertyAnimator; this.f2423c = view; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f2422b.setListener(null); this.f2423c.setAlpha(1.0f); this.f2423c.setTranslationX(0.0f); this.f2423c.setTranslationY(0.0f); c.this.C(this.f2421a.f2429a, true); c.this.f2400r.remove(this.f2421a.f2429a); c.this.V(); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { c.this.D(this.f2421a.f2429a, true); } } class h extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ i f2425a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ ViewPropertyAnimator f2426b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ View f2427c; h(i iVar, ViewPropertyAnimator viewPropertyAnimator, View view) { this.f2425a = iVar; this.f2426b = viewPropertyAnimator; this.f2427c = view; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f2426b.setListener(null); this.f2427c.setAlpha(1.0f); this.f2427c.setTranslationX(0.0f); this.f2427c.setTranslationY(0.0f); c.this.C(this.f2425a.f2430b, false); c.this.f2400r.remove(this.f2425a.f2430b); c.this.V(); } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { c.this.D(this.f2425a.f2430b, false); } } private static class j { /* renamed from: a, reason: collision with root package name */ public RecyclerView.d0 f2435a; /* renamed from: b, reason: collision with root package name */ public int f2436b; /* renamed from: c, reason: collision with root package name */ public int f2437c; /* renamed from: d, reason: collision with root package name */ public int f2438d; /* renamed from: e, reason: collision with root package name */ public int f2439e; j(RecyclerView.d0 d0Var, int i10, int i11, int i12, int i13) { this.f2435a = d0Var; this.f2436b = i10; this.f2437c = i11; this.f2438d = i12; this.f2439e = i13; } } private void T(RecyclerView.d0 d0Var) { View view = d0Var.f2240a; ViewPropertyAnimator animate = view.animate(); this.f2399q.add(d0Var); animate.setDuration(o()).alpha(0.0f).setListener(new d(d0Var, animate, view)).start(); } private void W(List list, RecyclerView.d0 d0Var) { for (int size = list.size() - 1; size >= 0; size--) { i iVar = (i) list.get(size); if (Y(iVar, d0Var) && iVar.f2429a == null && iVar.f2430b == null) { list.remove(iVar); } } } private void X(i iVar) { RecyclerView.d0 d0Var = iVar.f2429a; if (d0Var != null) { Y(iVar, d0Var); } RecyclerView.d0 d0Var2 = iVar.f2430b; if (d0Var2 != null) { Y(iVar, d0Var2); } } private boolean Y(i iVar, RecyclerView.d0 d0Var) { boolean z10 = false; if (iVar.f2430b == d0Var) { iVar.f2430b = null; } else { if (iVar.f2429a != d0Var) { return false; } iVar.f2429a = null; z10 = true; } d0Var.f2240a.setAlpha(1.0f); d0Var.f2240a.setTranslationX(0.0f); d0Var.f2240a.setTranslationY(0.0f); C(d0Var, z10); return true; } private void Z(RecyclerView.d0 d0Var) { if (f2389s == null) { f2389s = new ValueAnimator().getInterpolator(); } d0Var.f2240a.animate().setInterpolator(f2389s); j(d0Var); } void Q(RecyclerView.d0 d0Var) { View view = d0Var.f2240a; ViewPropertyAnimator animate = view.animate(); this.f2397o.add(d0Var); animate.alpha(1.0f).setDuration(l()).setListener(new e(d0Var, view, animate)).start(); } void R(i iVar) { RecyclerView.d0 d0Var = iVar.f2429a; View view = d0Var == null ? null : d0Var.f2240a; RecyclerView.d0 d0Var2 = iVar.f2430b; View view2 = d0Var2 != null ? d0Var2.f2240a : null; if (view != null) { ViewPropertyAnimator duration = view.animate().setDuration(m()); this.f2400r.add(iVar.f2429a); duration.translationX(iVar.f2433e - iVar.f2431c); duration.translationY(iVar.f2434f - iVar.f2432d); duration.alpha(0.0f).setListener(new g(iVar, duration, view)).start(); } if (view2 != null) { ViewPropertyAnimator animate = view2.animate(); this.f2400r.add(iVar.f2430b); animate.translationX(0.0f).translationY(0.0f).setDuration(m()).alpha(1.0f).setListener(new h(iVar, animate, view2)).start(); } } void S(RecyclerView.d0 d0Var, int i10, int i11, int i12, int i13) { View view = d0Var.f2240a; int i14 = i12 - i10; int i15 = i13 - i11; if (i14 != 0) { view.animate().translationX(0.0f); } if (i15 != 0) { view.animate().translationY(0.0f); } ViewPropertyAnimator animate = view.animate(); this.f2398p.add(d0Var); animate.setDuration(n()).setListener(new f(d0Var, i14, view, i15, animate)).start(); } void U(List list) { for (int size = list.size() - 1; size >= 0; size--) { ((RecyclerView.d0) list.get(size)).f2240a.animate().cancel(); } } void V() { if (p()) { return; } i(); } @Override // androidx.recyclerview.widget.RecyclerView.l public boolean g(RecyclerView.d0 d0Var, List list) { return !list.isEmpty() || super.g(d0Var, list); } @Override // androidx.recyclerview.widget.RecyclerView.l public void j(RecyclerView.d0 d0Var) { View view = d0Var.f2240a; view.animate().cancel(); int size = this.f2392j.size(); while (true) { size--; if (size < 0) { break; } if (((j) this.f2392j.get(size)).f2435a == d0Var) { view.setTranslationY(0.0f); view.setTranslationX(0.0f); E(d0Var); this.f2392j.remove(size); } } W(this.f2393k, d0Var); if (this.f2390h.remove(d0Var)) { view.setAlpha(1.0f); G(d0Var); } if (this.f2391i.remove(d0Var)) { view.setAlpha(1.0f); A(d0Var); } for (int size2 = this.f2396n.size() - 1; size2 >= 0; size2--) { ArrayList arrayList = (ArrayList) this.f2396n.get(size2); W(arrayList, d0Var); if (arrayList.isEmpty()) { this.f2396n.remove(size2); } } for (int size3 = this.f2395m.size() - 1; size3 >= 0; size3--) { ArrayList arrayList2 = (ArrayList) this.f2395m.get(size3); int size4 = arrayList2.size() - 1; while (true) { if (size4 < 0) { break; } if (((j) arrayList2.get(size4)).f2435a == d0Var) { view.setTranslationY(0.0f); view.setTranslationX(0.0f); E(d0Var); arrayList2.remove(size4); if (arrayList2.isEmpty()) { this.f2395m.remove(size3); } } else { size4--; } } } for (int size5 = this.f2394l.size() - 1; size5 >= 0; size5--) { ArrayList arrayList3 = (ArrayList) this.f2394l.get(size5); if (arrayList3.remove(d0Var)) { view.setAlpha(1.0f); A(d0Var); if (arrayList3.isEmpty()) { this.f2394l.remove(size5); } } } this.f2399q.remove(d0Var); this.f2397o.remove(d0Var); this.f2400r.remove(d0Var); this.f2398p.remove(d0Var); V(); } @Override // androidx.recyclerview.widget.RecyclerView.l public void k() { int size = this.f2392j.size(); while (true) { size--; if (size < 0) { break; } j jVar = (j) this.f2392j.get(size); View view = jVar.f2435a.f2240a; view.setTranslationY(0.0f); view.setTranslationX(0.0f); E(jVar.f2435a); this.f2392j.remove(size); } for (int size2 = this.f2390h.size() - 1; size2 >= 0; size2--) { G((RecyclerView.d0) this.f2390h.get(size2)); this.f2390h.remove(size2); } int size3 = this.f2391i.size(); while (true) { size3--; if (size3 < 0) { break; } RecyclerView.d0 d0Var = (RecyclerView.d0) this.f2391i.get(size3); d0Var.f2240a.setAlpha(1.0f); A(d0Var); this.f2391i.remove(size3); } for (int size4 = this.f2393k.size() - 1; size4 >= 0; size4--) { X((i) this.f2393k.get(size4)); } this.f2393k.clear(); if (p()) { for (int size5 = this.f2395m.size() - 1; size5 >= 0; size5--) { ArrayList arrayList = (ArrayList) this.f2395m.get(size5); for (int size6 = arrayList.size() - 1; size6 >= 0; size6--) { j jVar2 = (j) arrayList.get(size6); View view2 = jVar2.f2435a.f2240a; view2.setTranslationY(0.0f); view2.setTranslationX(0.0f); E(jVar2.f2435a); arrayList.remove(size6); if (arrayList.isEmpty()) { this.f2395m.remove(arrayList); } } } for (int size7 = this.f2394l.size() - 1; size7 >= 0; size7--) { ArrayList arrayList2 = (ArrayList) this.f2394l.get(size7); for (int size8 = arrayList2.size() - 1; size8 >= 0; size8--) { RecyclerView.d0 d0Var2 = (RecyclerView.d0) arrayList2.get(size8); d0Var2.f2240a.setAlpha(1.0f); A(d0Var2); arrayList2.remove(size8); if (arrayList2.isEmpty()) { this.f2394l.remove(arrayList2); } } } for (int size9 = this.f2396n.size() - 1; size9 >= 0; size9--) { ArrayList arrayList3 = (ArrayList) this.f2396n.get(size9); for (int size10 = arrayList3.size() - 1; size10 >= 0; size10--) { X((i) arrayList3.get(size10)); if (arrayList3.isEmpty()) { this.f2396n.remove(arrayList3); } } } U(this.f2399q); U(this.f2398p); U(this.f2397o); U(this.f2400r); i(); } } @Override // androidx.recyclerview.widget.RecyclerView.l public boolean p() { return (this.f2391i.isEmpty() && this.f2393k.isEmpty() && this.f2392j.isEmpty() && this.f2390h.isEmpty() && this.f2398p.isEmpty() && this.f2399q.isEmpty() && this.f2397o.isEmpty() && this.f2400r.isEmpty() && this.f2395m.isEmpty() && this.f2394l.isEmpty() && this.f2396n.isEmpty()) ? false : true; } @Override // androidx.recyclerview.widget.RecyclerView.l public void u() { boolean z10 = !this.f2390h.isEmpty(); boolean z11 = !this.f2392j.isEmpty(); boolean z12 = !this.f2393k.isEmpty(); boolean z13 = !this.f2391i.isEmpty(); if (z10 || z11 || z13 || z12) { Iterator it = this.f2390h.iterator(); while (it.hasNext()) { T((RecyclerView.d0) it.next()); } this.f2390h.clear(); if (z11) { ArrayList arrayList = new ArrayList(); arrayList.addAll(this.f2392j); this.f2395m.add(arrayList); this.f2392j.clear(); a aVar = new a(arrayList); if (z10) { n0.g0(((j) arrayList.get(0)).f2435a.f2240a, aVar, o()); } else { aVar.run(); } } if (z12) { ArrayList arrayList2 = new ArrayList(); arrayList2.addAll(this.f2393k); this.f2396n.add(arrayList2); this.f2393k.clear(); b bVar = new b(arrayList2); if (z10) { n0.g0(((i) arrayList2.get(0)).f2429a.f2240a, bVar, o()); } else { bVar.run(); } } if (z13) { ArrayList arrayList3 = new ArrayList(); arrayList3.addAll(this.f2391i); this.f2394l.add(arrayList3); this.f2391i.clear(); RunnableC0035c runnableC0035c = new RunnableC0035c(arrayList3); if (z10 || z11 || z12) { n0.g0(((RecyclerView.d0) arrayList3.get(0)).f2240a, runnableC0035c, (z10 ? o() : 0L) + Math.max(z11 ? n() : 0L, z12 ? m() : 0L)); } else { runnableC0035c.run(); } } } } @Override // androidx.recyclerview.widget.n public boolean w(RecyclerView.d0 d0Var) { Z(d0Var); d0Var.f2240a.setAlpha(0.0f); this.f2391i.add(d0Var); return true; } @Override // androidx.recyclerview.widget.n public boolean x(RecyclerView.d0 d0Var, RecyclerView.d0 d0Var2, int i10, int i11, int i12, int i13) { if (d0Var == d0Var2) { return y(d0Var, i10, i11, i12, i13); } float translationX = d0Var.f2240a.getTranslationX(); float translationY = d0Var.f2240a.getTranslationY(); float alpha = d0Var.f2240a.getAlpha(); Z(d0Var); int i14 = (int) ((i12 - i10) - translationX); int i15 = (int) ((i13 - i11) - translationY); d0Var.f2240a.setTranslationX(translationX); d0Var.f2240a.setTranslationY(translationY); d0Var.f2240a.setAlpha(alpha); if (d0Var2 != null) { Z(d0Var2); d0Var2.f2240a.setTranslationX(-i14); d0Var2.f2240a.setTranslationY(-i15); d0Var2.f2240a.setAlpha(0.0f); } this.f2393k.add(new i(d0Var, d0Var2, i10, i11, i12, i13)); return true; } @Override // androidx.recyclerview.widget.n public boolean y(RecyclerView.d0 d0Var, int i10, int i11, int i12, int i13) { View view = d0Var.f2240a; int translationX = i10 + ((int) view.getTranslationX()); int translationY = i11 + ((int) d0Var.f2240a.getTranslationY()); Z(d0Var); int i14 = i12 - translationX; int i15 = i13 - translationY; if (i14 == 0 && i15 == 0) { E(d0Var); return false; } if (i14 != 0) { view.setTranslationX(-i14); } if (i15 != 0) { view.setTranslationY(-i15); } this.f2392j.add(new j(d0Var, translationX, translationY, i12, i13)); return true; } @Override // androidx.recyclerview.widget.n public boolean z(RecyclerView.d0 d0Var) { Z(d0Var); this.f2390h.add(d0Var); return true; } private static class i { /* renamed from: a, reason: collision with root package name */ public RecyclerView.d0 f2429a; /* renamed from: b, reason: collision with root package name */ public RecyclerView.d0 f2430b; /* renamed from: c, reason: collision with root package name */ public int f2431c; /* renamed from: d, reason: collision with root package name */ public int f2432d; /* renamed from: e, reason: collision with root package name */ public int f2433e; /* renamed from: f, reason: collision with root package name */ public int f2434f; private i(RecyclerView.d0 d0Var, RecyclerView.d0 d0Var2) { this.f2429a = d0Var; this.f2430b = d0Var2; } public String toString() { return "ChangeInfo{oldHolder=" + this.f2429a + ", newHolder=" + this.f2430b + ", fromX=" + this.f2431c + ", fromY=" + this.f2432d + ", toX=" + this.f2433e + ", toY=" + this.f2434f + '}'; } i(RecyclerView.d0 d0Var, RecyclerView.d0 d0Var2, int i10, int i11, int i12, int i13) { this(d0Var, d0Var2); this.f2431c = i10; this.f2432d = i11; this.f2433e = i12; this.f2434f = i13; } } }