708 lines
26 KiB
Java
708 lines
26 KiB
Java
package j0.l.a;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import b.i.a.f.e.o.f;
|
|
import j0.l.e.i;
|
|
import j0.l.e.k;
|
|
import j0.l.e.n.g;
|
|
import j0.l.e.o.n;
|
|
import j0.l.e.o.y;
|
|
import java.util.ArrayList;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import rx.Observable;
|
|
import rx.Producer;
|
|
import rx.Subscriber;
|
|
import rx.exceptions.CompositeException;
|
|
import rx.exceptions.MissingBackpressureException;
|
|
import rx.exceptions.OnErrorThrowable;
|
|
import rx.subscriptions.CompositeSubscription;
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public final class x0<T> implements Observable.b<T, Observable<? extends T>> {
|
|
public final boolean j;
|
|
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public static final class a {
|
|
public static final x0<Object> a = new x0<>(true, Integer.MAX_VALUE);
|
|
}
|
|
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public static final class b {
|
|
public static final x0<Object> a = new x0<>(false, Integer.MAX_VALUE);
|
|
}
|
|
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public static final class c<T> extends Subscriber<T> {
|
|
public static final int j = i.j / 4;
|
|
public final e<T> k;
|
|
public final long l;
|
|
public volatile boolean m;
|
|
public volatile i n;
|
|
public int o;
|
|
|
|
public c(e<T> eVar, long j2) {
|
|
this.k = eVar;
|
|
this.l = j2;
|
|
}
|
|
|
|
public void a(long j2) {
|
|
int i = this.o - ((int) j2);
|
|
if (i > j) {
|
|
this.o = i;
|
|
return;
|
|
}
|
|
int i2 = i.j;
|
|
this.o = i2;
|
|
int i3 = i2 - i;
|
|
if (i3 > 0) {
|
|
request(i3);
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
this.m = true;
|
|
this.k.b();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
this.k.d().offer(th);
|
|
this.m = true;
|
|
this.k.b();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
boolean z2;
|
|
e<T> eVar = this.k;
|
|
long j2 = eVar.n.get();
|
|
if (j2 != 0) {
|
|
synchronized (eVar) {
|
|
j2 = eVar.n.get();
|
|
if (eVar.f3761s || j2 == 0) {
|
|
z2 = false;
|
|
} else {
|
|
eVar.f3761s = true;
|
|
z2 = true;
|
|
}
|
|
}
|
|
} else {
|
|
z2 = false;
|
|
}
|
|
if (z2) {
|
|
i iVar = this.n;
|
|
if (iVar != null) {
|
|
Queue<Object> queue = iVar.k;
|
|
if (!(queue == null || queue.isEmpty())) {
|
|
eVar.f(this, t);
|
|
eVar.c();
|
|
return;
|
|
}
|
|
}
|
|
try {
|
|
eVar.k.onNext(t);
|
|
if (j2 != RecyclerView.FOREVER_NS) {
|
|
eVar.n.a(1);
|
|
}
|
|
a(1L);
|
|
synchronized (eVar) {
|
|
try {
|
|
if (!eVar.t) {
|
|
eVar.f3761s = false;
|
|
} else {
|
|
eVar.t = false;
|
|
eVar.c();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
eVar.f(this, t);
|
|
eVar.b();
|
|
}
|
|
}
|
|
|
|
@Override // rx.Subscriber
|
|
public void onStart() {
|
|
int i = i.j;
|
|
this.o = i;
|
|
request(i);
|
|
}
|
|
}
|
|
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public static final class d<T> extends AtomicLong implements Producer {
|
|
private static final long serialVersionUID = -1214379189873595503L;
|
|
public final e<T> subscriber;
|
|
|
|
public d(e<T> eVar) {
|
|
this.subscriber = eVar;
|
|
}
|
|
|
|
public long a(int i) {
|
|
return addAndGet(-i);
|
|
}
|
|
|
|
@Override // rx.Producer
|
|
public void j(long j) {
|
|
int i = (j > 0L ? 1 : (j == 0L ? 0 : -1));
|
|
if (i > 0) {
|
|
if (get() != RecyclerView.FOREVER_NS) {
|
|
f.c0(this, j);
|
|
this.subscriber.b();
|
|
}
|
|
} else if (i < 0) {
|
|
throw new IllegalArgumentException("n >= 0 required");
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: OperatorMerge.java */
|
|
/* loaded from: classes3.dex */
|
|
public static final class e<T> extends Subscriber<Observable<? extends T>> {
|
|
public static final c<?>[] j = new c[0];
|
|
public int A;
|
|
public final Subscriber<? super T> k;
|
|
public final boolean l;
|
|
public final int m;
|
|
public d<T> n;
|
|
public volatile Queue<Object> o;
|
|
public volatile CompositeSubscription p;
|
|
public volatile ConcurrentLinkedQueue<Throwable> q;
|
|
public volatile boolean r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public boolean f3761s;
|
|
public boolean t;
|
|
public final Object u = new Object();
|
|
public volatile c<?>[] v = j;
|
|
public long w;
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public long f3762x;
|
|
|
|
/* renamed from: y reason: collision with root package name */
|
|
public int f3763y;
|
|
|
|
/* renamed from: z reason: collision with root package name */
|
|
public final int f3764z;
|
|
|
|
public e(Subscriber<? super T> subscriber, boolean z2, int i) {
|
|
this.k = subscriber;
|
|
this.l = z2;
|
|
this.m = i;
|
|
if (i == Integer.MAX_VALUE) {
|
|
this.f3764z = Integer.MAX_VALUE;
|
|
request(RecyclerView.FOREVER_NS);
|
|
return;
|
|
}
|
|
this.f3764z = Math.max(1, i >> 1);
|
|
request(i);
|
|
}
|
|
|
|
public boolean a() {
|
|
if (this.k.isUnsubscribed()) {
|
|
return true;
|
|
}
|
|
ConcurrentLinkedQueue<Throwable> concurrentLinkedQueue = this.q;
|
|
if (this.l || concurrentLinkedQueue == null || concurrentLinkedQueue.isEmpty()) {
|
|
return false;
|
|
}
|
|
try {
|
|
h();
|
|
return true;
|
|
} finally {
|
|
unsubscribe();
|
|
}
|
|
}
|
|
|
|
public void b() {
|
|
synchronized (this) {
|
|
if (this.f3761s) {
|
|
this.t = true;
|
|
return;
|
|
}
|
|
this.f3761s = true;
|
|
c();
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:100:0x0151, code lost:
|
|
r4 = r9.m;
|
|
r13 = r9.n;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:101:0x0155, code lost:
|
|
if (r4 == false) goto L_0x0176;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:102:0x0157, code lost:
|
|
if (r13 == null) goto L_0x0169;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:103:0x0159, code lost:
|
|
r4 = r13.k;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:104:0x015b, code lost:
|
|
if (r4 == null) goto L_0x0166;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:106:0x0161, code lost:
|
|
if (r4.isEmpty() == false) goto L_0x0164;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:108:0x0164, code lost:
|
|
r4 = false;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:109:0x0166, code lost:
|
|
r4 = true;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:110:0x0167, code lost:
|
|
if (r4 == false) goto L_0x0176;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:111:0x0169, code lost:
|
|
g(r9);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:112:0x0170, code lost:
|
|
if (a() == false) goto L_0x0173;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:113:0x0172, code lost:
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:114:0x0173, code lost:
|
|
r6 = r6 + 1;
|
|
r8 = true;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:115:0x0176, code lost:
|
|
if (r3 != 0) goto L_0x0179;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:117:0x0179, code lost:
|
|
r0 = r0 + 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:118:0x017b, code lost:
|
|
if (r0 != r7) goto L_0x017e;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:119:0x017d, code lost:
|
|
r0 = 0;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:122:0x0186, code lost:
|
|
r23.f3763y = r0;
|
|
r23.f3762x = r5[r0].l;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
public void c() {
|
|
boolean z2;
|
|
Throwable th;
|
|
int i;
|
|
boolean z3;
|
|
Throwable th2;
|
|
try {
|
|
Subscriber<? super T> subscriber = this.k;
|
|
while (!a()) {
|
|
Queue<Object> queue = this.o;
|
|
long j2 = this.n.get();
|
|
boolean z4 = j2 == RecyclerView.FOREVER_NS;
|
|
if (queue != null) {
|
|
i = 0;
|
|
while (true) {
|
|
int i2 = 0;
|
|
Object obj = null;
|
|
while (true) {
|
|
if (j2 <= 0) {
|
|
break;
|
|
}
|
|
Object poll = queue.poll();
|
|
if (!a()) {
|
|
if (poll == null) {
|
|
obj = poll;
|
|
break;
|
|
}
|
|
subscriber.onNext((Object) e.b(poll));
|
|
i++;
|
|
i2++;
|
|
j2--;
|
|
obj = poll;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (i2 > 0) {
|
|
j2 = z4 ? Long.MAX_VALUE : this.n.a(i2);
|
|
}
|
|
if (j2 == 0 || obj == null) {
|
|
break;
|
|
}
|
|
i = i;
|
|
j2 = j2;
|
|
}
|
|
} else {
|
|
j2 = j2;
|
|
i = 0;
|
|
}
|
|
boolean z5 = this.r;
|
|
Queue<Object> queue2 = this.o;
|
|
c<?>[] cVarArr = this.v;
|
|
int length = cVarArr.length;
|
|
if (!z5 || ((queue2 != null && !queue2.isEmpty()) || length != 0)) {
|
|
if (length > 0) {
|
|
long j3 = this.f3762x;
|
|
int i3 = this.f3763y;
|
|
if (length <= i3 || cVarArr[i3].l != j3) {
|
|
if (length <= i3) {
|
|
i3 = 0;
|
|
}
|
|
for (int i4 = 0; i4 < length && cVarArr[i3].l != j3; i4++) {
|
|
i3++;
|
|
if (i3 == length) {
|
|
i3 = 0;
|
|
}
|
|
}
|
|
this.f3763y = i3;
|
|
this.f3762x = cVarArr[i3].l;
|
|
}
|
|
int i5 = 0;
|
|
z3 = false;
|
|
while (true) {
|
|
if (i5 >= length) {
|
|
subscriber = subscriber;
|
|
break;
|
|
} else if (!a()) {
|
|
c<?> cVar = cVarArr[i3];
|
|
Object obj2 = null;
|
|
while (true) {
|
|
int i6 = 0;
|
|
while (j2 > 0) {
|
|
if (!a()) {
|
|
i iVar = cVar.n;
|
|
if (iVar != null && (obj2 = iVar.c()) != null) {
|
|
try {
|
|
subscriber.onNext((Object) e.b(obj2));
|
|
j2--;
|
|
i6++;
|
|
}
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (i6 > 0) {
|
|
if (!z4) {
|
|
j2 = this.n.a(i6);
|
|
subscriber = subscriber;
|
|
} else {
|
|
subscriber = subscriber;
|
|
j2 = RecyclerView.FOREVER_NS;
|
|
}
|
|
cVar.a(i6);
|
|
} else {
|
|
subscriber = subscriber;
|
|
}
|
|
int i7 = (j2 > 0L ? 1 : (j2 == 0L ? 0 : -1));
|
|
if (i7 == 0 || obj2 == null) {
|
|
break;
|
|
}
|
|
subscriber = subscriber;
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
i5++;
|
|
subscriber = subscriber;
|
|
}
|
|
} else {
|
|
subscriber = subscriber;
|
|
z3 = false;
|
|
}
|
|
if (i > 0) {
|
|
request(i);
|
|
}
|
|
if (!z3) {
|
|
synchronized (this) {
|
|
try {
|
|
if (!this.t) {
|
|
try {
|
|
this.f3761s = false;
|
|
return;
|
|
} catch (Throwable th3) {
|
|
th2 = th3;
|
|
z2 = true;
|
|
while (true) {
|
|
try {
|
|
break;
|
|
} catch (Throwable th4) {
|
|
th2 = th4;
|
|
}
|
|
}
|
|
throw th2;
|
|
}
|
|
} else {
|
|
this.t = false;
|
|
}
|
|
} catch (Throwable th5) {
|
|
th2 = th5;
|
|
z2 = false;
|
|
}
|
|
}
|
|
try {
|
|
break;
|
|
throw th2;
|
|
} catch (Throwable th6) {
|
|
th = th6;
|
|
if (!z2) {
|
|
synchronized (this) {
|
|
this.f3761s = false;
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
} else {
|
|
ConcurrentLinkedQueue<Throwable> concurrentLinkedQueue = this.q;
|
|
if (concurrentLinkedQueue != null && !concurrentLinkedQueue.isEmpty()) {
|
|
h();
|
|
return;
|
|
}
|
|
subscriber.onCompleted();
|
|
return;
|
|
}
|
|
}
|
|
} catch (Throwable th7) {
|
|
th = th7;
|
|
z2 = false;
|
|
}
|
|
}
|
|
|
|
public Queue<Throwable> d() {
|
|
ConcurrentLinkedQueue<Throwable> concurrentLinkedQueue = this.q;
|
|
if (concurrentLinkedQueue == null) {
|
|
synchronized (this) {
|
|
concurrentLinkedQueue = this.q;
|
|
if (concurrentLinkedQueue == null) {
|
|
concurrentLinkedQueue = new ConcurrentLinkedQueue<>();
|
|
this.q = concurrentLinkedQueue;
|
|
}
|
|
}
|
|
}
|
|
return concurrentLinkedQueue;
|
|
}
|
|
|
|
public void e(T t) {
|
|
Queue<Object> queue = this.o;
|
|
if (queue == null) {
|
|
int i = this.m;
|
|
if (i == Integer.MAX_VALUE) {
|
|
queue = new g<>(i.j);
|
|
} else {
|
|
queue = ((i + (-1)) & i) == 0 ? y.b() ? new n<>(i) : new j0.l.e.n.c<>(i) : new j0.l.e.n.d<>(i);
|
|
}
|
|
this.o = queue;
|
|
}
|
|
if (!queue.offer(t == null ? e.f3753b : t)) {
|
|
unsubscribe();
|
|
d().offer(OnErrorThrowable.a(new MissingBackpressureException(), t));
|
|
this.r = true;
|
|
b();
|
|
}
|
|
}
|
|
|
|
public void f(c<T> cVar, T t) {
|
|
i iVar = cVar.n;
|
|
if (iVar == null) {
|
|
iVar = y.b() ? new i(false, i.j) : new i();
|
|
cVar.add(iVar);
|
|
cVar.n = iVar;
|
|
}
|
|
if (t == null) {
|
|
try {
|
|
t = (T) e.f3753b;
|
|
} catch (IllegalStateException e) {
|
|
if (!cVar.isUnsubscribed()) {
|
|
cVar.unsubscribe();
|
|
cVar.onError(e);
|
|
return;
|
|
}
|
|
return;
|
|
} catch (MissingBackpressureException e2) {
|
|
cVar.unsubscribe();
|
|
cVar.onError(e2);
|
|
return;
|
|
}
|
|
}
|
|
iVar.a(t);
|
|
}
|
|
|
|
public void g(c<T> cVar) {
|
|
i iVar = cVar.n;
|
|
if (iVar != null) {
|
|
synchronized (iVar) {
|
|
}
|
|
}
|
|
this.p.c(cVar);
|
|
synchronized (this.u) {
|
|
c<?>[] cVarArr = this.v;
|
|
int length = cVarArr.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
i = -1;
|
|
break;
|
|
} else if (cVar.equals(cVarArr[i])) {
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
if (i >= 0) {
|
|
if (length == 1) {
|
|
this.v = j;
|
|
return;
|
|
}
|
|
c<?>[] cVarArr2 = new c[length - 1];
|
|
System.arraycopy(cVarArr, 0, cVarArr2, 0, i);
|
|
System.arraycopy(cVarArr, i + 1, cVarArr2, i, (length - i) - 1);
|
|
this.v = cVarArr2;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void h() {
|
|
ArrayList arrayList = new ArrayList(this.q);
|
|
if (arrayList.size() == 1) {
|
|
this.k.onError((Throwable) arrayList.get(0));
|
|
} else {
|
|
this.k.onError(new CompositeException(arrayList));
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
this.r = true;
|
|
b();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
d().offer(th);
|
|
this.r = true;
|
|
b();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(Object obj) {
|
|
boolean z2;
|
|
Observable<Object> observable = (Observable) obj;
|
|
if (observable != null) {
|
|
boolean z3 = true;
|
|
if (observable == c.k) {
|
|
int i = this.A + 1;
|
|
if (i == this.f3764z) {
|
|
this.A = 0;
|
|
request(i);
|
|
return;
|
|
}
|
|
this.A = i;
|
|
} else if (observable instanceof k) {
|
|
T t = ((k) observable).l;
|
|
long j2 = this.n.get();
|
|
if (j2 != 0) {
|
|
synchronized (this) {
|
|
j2 = this.n.get();
|
|
if (this.f3761s || j2 == 0) {
|
|
z2 = false;
|
|
} else {
|
|
this.f3761s = true;
|
|
z2 = true;
|
|
}
|
|
}
|
|
} else {
|
|
z2 = false;
|
|
}
|
|
if (z2) {
|
|
Queue<Object> queue = this.o;
|
|
if (queue == null || queue.isEmpty()) {
|
|
try {
|
|
this.k.onNext(t);
|
|
if (j2 != RecyclerView.FOREVER_NS) {
|
|
try {
|
|
this.n.a(1);
|
|
}
|
|
}
|
|
int i2 = this.A + 1;
|
|
if (i2 == this.f3764z) {
|
|
this.A = 0;
|
|
request(i2);
|
|
} else {
|
|
this.A = i2;
|
|
}
|
|
synchronized (this) {
|
|
if (!this.t) {
|
|
this.f3761s = false;
|
|
} else {
|
|
this.t = false;
|
|
c();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
e(t);
|
|
c();
|
|
}
|
|
} else {
|
|
e(t);
|
|
b();
|
|
}
|
|
} else {
|
|
long j3 = this.w;
|
|
this.w = 1 + j3;
|
|
c<?> cVar = new c<>(this, j3);
|
|
CompositeSubscription compositeSubscription = this.p;
|
|
if (compositeSubscription == null) {
|
|
synchronized (this) {
|
|
compositeSubscription = this.p;
|
|
if (compositeSubscription == null) {
|
|
compositeSubscription = new CompositeSubscription();
|
|
this.p = compositeSubscription;
|
|
} else {
|
|
z3 = false;
|
|
}
|
|
}
|
|
if (z3) {
|
|
add(compositeSubscription);
|
|
}
|
|
}
|
|
compositeSubscription.a(cVar);
|
|
synchronized (this.u) {
|
|
c<?>[] cVarArr = this.v;
|
|
int length = cVarArr.length;
|
|
c<?>[] cVarArr2 = new c[length + 1];
|
|
System.arraycopy(cVarArr, 0, cVarArr2, 0, length);
|
|
cVarArr2[length] = cVar;
|
|
this.v = cVarArr2;
|
|
}
|
|
observable.i0(cVar);
|
|
b();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public x0(boolean z2, int i) {
|
|
this.j = z2;
|
|
}
|
|
|
|
@Override // j0.k.b
|
|
public Object call(Object obj) {
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
e eVar = new e(subscriber, this.j, Integer.MAX_VALUE);
|
|
d<T> dVar = new d<>(eVar);
|
|
eVar.n = dVar;
|
|
subscriber.add(eVar);
|
|
subscriber.setProducer(dVar);
|
|
return eVar;
|
|
}
|
|
}
|