package androidx.recyclerview.widget; import androidx.recyclerview.widget.AdapterHelper; import java.util.List; /* loaded from: classes.dex */ class OpReorderer { final Callback a; interface Callback { AdapterHelper.UpdateOp a(int i, int i2, int i3, Object obj); void a(AdapterHelper.UpdateOp updateOp); } OpReorderer(Callback callback) { this.a = callback; } private void c(List list, int i, AdapterHelper.UpdateOp updateOp, int i2, AdapterHelper.UpdateOp updateOp2) { int i3 = updateOp.d < updateOp2.b ? -1 : 0; if (updateOp.b < updateOp2.b) { i3++; } int i4 = updateOp2.b; int i5 = updateOp.b; if (i4 <= i5) { updateOp.b = i5 + updateOp2.d; } int i6 = updateOp2.b; int i7 = updateOp.d; if (i6 <= i7) { updateOp.d = i7 + updateOp2.d; } updateOp2.b += i3; list.set(i, updateOp2); list.set(i2, updateOp); } void a(List list) { while (true) { int b = b(list); if (b == -1) { return; } else { a(list, b, b + 1); } } } /* JADX WARN: Removed duplicated region for block: B:10:0x0048 */ /* JADX WARN: Removed duplicated region for block: B:12:0x0056 */ /* JADX WARN: Removed duplicated region for block: B:14:0x005b */ /* JADX WARN: Removed duplicated region for block: B:17:? A[RETURN, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:18:0x004c */ /* JADX WARN: Removed duplicated region for block: B:19:0x002b */ /* JADX WARN: Removed duplicated region for block: B:7:0x0027 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ void b(java.util.List r9, int r10, androidx.recyclerview.widget.AdapterHelper.UpdateOp r11, int r12, androidx.recyclerview.widget.AdapterHelper.UpdateOp r13) { /* r8 = this; int r0 = r11.d int r1 = r13.b r2 = 4 r3 = 0 r4 = 1 if (r0 >= r1) goto Ld int r1 = r1 - r4 r13.b = r1 goto L20 Ld: int r5 = r13.d int r1 = r1 + r5 if (r0 >= r1) goto L20 int r5 = r5 - r4 r13.d = r5 androidx.recyclerview.widget.OpReorderer$Callback r0 = r8.a int r1 = r11.b java.lang.Object r5 = r13.c androidx.recyclerview.widget.AdapterHelper$UpdateOp r0 = r0.a(r2, r1, r4, r5) goto L21 L20: r0 = r3 L21: int r1 = r11.b int r5 = r13.b if (r1 > r5) goto L2b int r5 = r5 + r4 r13.b = r5 goto L41 L2b: int r6 = r13.d int r7 = r5 + r6 if (r1 >= r7) goto L41 int r5 = r5 + r6 int r5 = r5 - r1 androidx.recyclerview.widget.OpReorderer$Callback r3 = r8.a int r1 = r1 + r4 java.lang.Object r4 = r13.c androidx.recyclerview.widget.AdapterHelper$UpdateOp r3 = r3.a(r2, r1, r5, r4) int r1 = r13.d int r1 = r1 - r5 r13.d = r1 L41: r9.set(r12, r11) int r11 = r13.d if (r11 <= 0) goto L4c r9.set(r10, r13) goto L54 L4c: r9.remove(r10) androidx.recyclerview.widget.OpReorderer$Callback r11 = r8.a r11.a(r13) L54: if (r0 == 0) goto L59 r9.add(r10, r0) L59: if (r3 == 0) goto L5e r9.add(r10, r3) L5e: return */ throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.OpReorderer.b(java.util.List, int, androidx.recyclerview.widget.AdapterHelper$UpdateOp, int, androidx.recyclerview.widget.AdapterHelper$UpdateOp):void"); } private void a(List list, int i, int i2) { AdapterHelper.UpdateOp updateOp = list.get(i); AdapterHelper.UpdateOp updateOp2 = list.get(i2); int i3 = updateOp2.a; if (i3 == 1) { c(list, i, updateOp, i2, updateOp2); } else if (i3 == 2) { a(list, i, updateOp, i2, updateOp2); } else { if (i3 != 4) { return; } b(list, i, updateOp, i2, updateOp2); } } void a(List list, int i, AdapterHelper.UpdateOp updateOp, int i2, AdapterHelper.UpdateOp updateOp2) { boolean z; int i3 = updateOp.b; int i4 = updateOp.d; boolean z2 = false; if (i3 < i4) { if (updateOp2.b == i3 && updateOp2.d == i4 - i3) { z = false; z2 = true; } else { z = false; } } else if (updateOp2.b == i4 + 1 && updateOp2.d == i3 - i4) { z = true; z2 = true; } else { z = true; } int i5 = updateOp.d; int i6 = updateOp2.b; if (i5 < i6) { updateOp2.b = i6 - 1; } else { int i7 = updateOp2.d; if (i5 < i6 + i7) { updateOp2.d = i7 - 1; updateOp.a = 2; updateOp.d = 1; if (updateOp2.d == 0) { list.remove(i2); this.a.a(updateOp2); return; } return; } } int i8 = updateOp.b; int i9 = updateOp2.b; AdapterHelper.UpdateOp updateOp3 = null; if (i8 <= i9) { updateOp2.b = i9 + 1; } else { int i10 = updateOp2.d; if (i8 < i9 + i10) { updateOp3 = this.a.a(2, i8 + 1, (i9 + i10) - i8, null); updateOp2.d = updateOp.b - updateOp2.b; } } if (z2) { list.set(i, updateOp2); list.remove(i2); this.a.a(updateOp); return; } if (z) { if (updateOp3 != null) { int i11 = updateOp.b; if (i11 > updateOp3.b) { updateOp.b = i11 - updateOp3.d; } int i12 = updateOp.d; if (i12 > updateOp3.b) { updateOp.d = i12 - updateOp3.d; } } int i13 = updateOp.b; if (i13 > updateOp2.b) { updateOp.b = i13 - updateOp2.d; } int i14 = updateOp.d; if (i14 > updateOp2.b) { updateOp.d = i14 - updateOp2.d; } } else { if (updateOp3 != null) { int i15 = updateOp.b; if (i15 >= updateOp3.b) { updateOp.b = i15 - updateOp3.d; } int i16 = updateOp.d; if (i16 >= updateOp3.b) { updateOp.d = i16 - updateOp3.d; } } int i17 = updateOp.b; if (i17 >= updateOp2.b) { updateOp.b = i17 - updateOp2.d; } int i18 = updateOp.d; if (i18 >= updateOp2.b) { updateOp.d = i18 - updateOp2.d; } } list.set(i, updateOp2); if (updateOp.b != updateOp.d) { list.set(i2, updateOp); } else { list.remove(i2); } if (updateOp3 != null) { list.add(i, updateOp3); } } private int b(List list) { boolean z = false; for (int size = list.size() - 1; size >= 0; size--) { if (list.get(size).a != 8) { z = true; } else if (z) { return size; } } return -1; } }