package o; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.analytics.ecommerce.ProductAction; import java.util.ArrayList; import java.util.List; import o.RDy; import o.TkJ; /* loaded from: classes.dex */ public final class UtV implements TkJ.Sts { final LWm a; final TkJ b; final boolean c; public final ArrayList d; public int e; private Runnable f; public final ArrayList g; private RDy.Sts i; /* loaded from: classes.dex */ public interface LWm { void a(int i, int i2); void a(Sts sts); RecyclerView.zJl b(int i); void b(int i, int i2); void c(Sts sts); void d(int i, int i2); void d(int i, int i2, Object obj); void e(int i, int i2); } public UtV(LWm lWm) { this(lWm, (byte) 0); } private UtV(LWm lWm, byte b) { this.i = new RDy.RVV(30); this.d = new ArrayList<>(); this.g = new ArrayList<>(); this.e = 0; this.a = lWm; this.c = false; this.b = new TkJ(this); } public final void b() { int size = this.g.size(); for (int i = 0; i < size; i++) { this.a.c(this.g.get(i)); } a(this.g); this.e = 0; } private void b(Sts sts) { int i; if (sts.c == 1 || sts.c == 8) { throw new IllegalArgumentException("should not dispatch add or move for pre layout"); } int b = b(sts.a, sts.c); int i2 = sts.a; int i3 = sts.c; if (i3 == 2) { i = 0; } else { if (i3 != 4) { throw new IllegalArgumentException("op should be remove or update.".concat(String.valueOf(sts))); } i = 1; } int i4 = 1; for (int i5 = 1; i5 < sts.b; i5++) { int b2 = b(sts.a + (i * i5), sts.c); int i6 = sts.c; if (i6 == 2 ? b2 != b : !(i6 == 4 && b2 == b + 1)) { Sts a = a(sts.c, b, i4, sts.d); b(a, i2); if (!this.c) { a.d = null; this.i.d(a); } if (sts.c == 4) { i2 += i4; } i4 = 1; b = b2; } else { i4++; } } Object obj = sts.d; if (!this.c) { sts.d = null; this.i.d(sts); } if (i4 > 0) { Sts a2 = a(sts.c, b, i4, obj); b(a2, i2); if (this.c) { return; } a2.d = null; this.i.d(a2); } } private void b(Sts sts, int i) { this.a.a(sts); int i2 = sts.c; if (i2 == 2) { this.a.e(i, sts.b); } else { if (i2 == 4) { this.a.d(i, sts.b, sts.d); return; } throw new IllegalArgumentException("only remove and update ops can be dispatched in first pass"); } } private int b(int i, int i2) { int i3; int i4; for (int size = this.g.size() - 1; size >= 0; size--) { Sts sts = this.g.get(size); if (sts.c == 8) { if (sts.a < sts.b) { i3 = sts.a; i4 = sts.b; } else { i3 = sts.b; i4 = sts.a; } if (i >= i3 && i <= i4) { if (i3 == sts.a) { if (i2 == 1) { sts.b++; } else if (i2 == 2) { sts.b--; } i++; } else { if (i2 == 1) { sts.a++; } else if (i2 == 2) { sts.a--; } i--; } } else if (i < sts.a) { if (i2 == 1) { sts.a++; sts.b++; } else if (i2 == 2) { sts.a--; sts.b--; } } } else if (sts.a <= i) { if (sts.c == 1) { i -= sts.b; } else if (sts.c == 2) { i += sts.b; } } else if (i2 == 1) { sts.a++; } else if (i2 == 2) { sts.a--; } } for (int size2 = this.g.size() - 1; size2 >= 0; size2--) { Sts sts2 = this.g.get(size2); if (sts2.c == 8) { if (sts2.b == sts2.a || sts2.b < 0) { this.g.remove(size2); if (!this.c) { sts2.d = null; this.i.d(sts2); } } } else if (sts2.b <= 0) { this.g.remove(size2); if (!this.c) { sts2.d = null; this.i.d(sts2); } } } return i; } private boolean d(int i) { int size = this.g.size(); for (int i2 = 0; i2 < size; i2++) { Sts sts = this.g.get(i2); if (sts.c == 8) { if (d(sts.b, i2 + 1) == i) { return true; } } else if (sts.c == 1) { int i3 = sts.a; int i4 = sts.b; for (int i5 = sts.a; i5 < i3 + i4; i5++) { if (d(i5, i2 + 1) == i) { return true; } } } else { continue; } } return false; } private void a(Sts sts) { this.g.add(sts); int i = sts.c; if (i == 1) { this.a.d(sts.a, sts.b); return; } if (i == 2) { this.a.a(sts.a, sts.b); } else if (i == 4) { this.a.d(sts.a, sts.b, sts.d); } else { if (i == 8) { this.a.b(sts.a, sts.b); return; } throw new IllegalArgumentException("Unknown update op type for ".concat(String.valueOf(sts))); } } public final int d(int i, int i2) { int size = this.g.size(); while (i2 < size) { Sts sts = this.g.get(i2); if (sts.c == 8) { if (sts.a == i) { i = sts.b; } else { if (sts.a < i) { i--; } if (sts.b <= i) { i++; } } } else if (sts.a > i) { continue; } else if (sts.c == 2) { if (i < sts.a + sts.b) { return -1; } i -= sts.b; } else if (sts.c == 1) { i += sts.b; } i2++; } return i; } public final void e() { b(); int size = this.d.size(); for (int i = 0; i < size; i++) { Sts sts = this.d.get(i); int i2 = sts.c; if (i2 == 1) { this.a.c(sts); this.a.d(sts.a, sts.b); } else if (i2 == 2) { this.a.c(sts); this.a.e(sts.a, sts.b); } else if (i2 == 4) { this.a.c(sts); this.a.d(sts.a, sts.b, sts.d); } else if (i2 == 8) { this.a.c(sts); this.a.b(sts.a, sts.b); } } a(this.d); this.e = 0; } public final int a(int i) { int size = this.d.size(); for (int i2 = 0; i2 < size; i2++) { Sts sts = this.d.get(i2); int i3 = sts.c; if (i3 != 1) { if (i3 != 2) { if (i3 == 8) { if (sts.a == i) { i = sts.b; } else { if (sts.a < i) { i--; } if (sts.b <= i) { i++; } } } } else if (sts.a > i) { continue; } else { if (sts.a + sts.b > i) { return -1; } i -= sts.b; } } else if (sts.a <= i) { i += sts.b; } } return i; } /* loaded from: classes.dex */ public static final class Sts { public int a; public int b; public int c; public Object d; Sts(int i, int i2, int i3, Object obj) { this.c = i; this.a = i2; this.b = i3; this.d = obj; } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append("["); int i = this.c; sb.append(i != 1 ? i != 2 ? i != 4 ? i != 8 ? "??" : "mv" : "up" : "rm" : ProductAction.ACTION_ADD); sb.append(",s:"); sb.append(this.a); sb.append("c:"); sb.append(this.b); sb.append(",p:"); sb.append(this.d); sb.append("]"); return sb.toString(); } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Sts)) { return false; } Sts sts = (Sts) obj; int i = this.c; if (i != sts.c) { return false; } if (i == 8 && Math.abs(this.b - this.a) == 1 && this.b == sts.a && this.a == sts.b) { return true; } if (this.b != sts.b || this.a != sts.a) { return false; } Object obj2 = this.d; if (obj2 != null) { if (!obj2.equals(sts.d)) { return false; } } else if (sts.d != null) { return false; } return true; } public final int hashCode() { return (((this.c * 31) + this.a) * 31) + this.b; } } @Override // o.TkJ.Sts public final Sts a(int i, int i2, int i3, Object obj) { Sts d = this.i.d(); if (d == null) { return new Sts(i, i2, i3, obj); } d.c = i; d.a = i2; d.b = i3; d.d = obj; return d; } @Override // o.TkJ.Sts public final void d(Sts sts) { if (this.c) { return; } sts.d = null; this.i.d(sts); } public final void a(List list) { int size = list.size(); for (int i = 0; i < size; i++) { Sts sts = list.get(i); if (!this.c) { sts.d = null; this.i.d(sts); } } list.clear(); } /* JADX WARN: Code restructure failed: missing block: B:145:0x0221, code lost: if (r9 == 8) goto L180; */ /* JADX WARN: Removed duplicated region for block: B:118:0x006b */ /* JADX WARN: Removed duplicated region for block: B:121:0x0099 */ /* JADX WARN: Removed duplicated region for block: B:123:0x00a7 */ /* JADX WARN: Removed duplicated region for block: B:125:0x00ac A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:128:0x0006 A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:129:0x009d */ /* JADX WARN: Removed duplicated region for block: B:130:0x0071 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void d() { /* Method dump skipped, instructions count: 758 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.UtV.d():void"); } }