256 lines
8.4 KiB
Java
256 lines
8.4 KiB
Java
package j0.l.a;
|
|
|
|
import j0.l.e.d;
|
|
import j0.l.e.j;
|
|
import j0.l.e.n.n;
|
|
import j0.l.e.n.y;
|
|
import j0.o.l;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import rx.Observable;
|
|
import rx.Producer;
|
|
import rx.Subscriber;
|
|
import rx.exceptions.MissingBackpressureException;
|
|
import rx.observers.SerializedSubscriber;
|
|
import rx.subscriptions.SerialSubscription;
|
|
/* compiled from: OnSubscribeConcatMap */
|
|
public final class h<T, R> implements Observable.a<R> {
|
|
public final Observable<? extends T> i;
|
|
public final j0.k.b<? super T, ? extends Observable<? extends R>> j;
|
|
|
|
/* compiled from: OnSubscribeConcatMap */
|
|
public static final class a<T, R> implements Producer {
|
|
public final R i;
|
|
public final c<T, R> j;
|
|
public boolean k;
|
|
|
|
public a(R r, c<T, R> cVar) {
|
|
this.i = r;
|
|
this.j = cVar;
|
|
}
|
|
|
|
@Override // rx.Producer
|
|
public void j(long j) {
|
|
if (!this.k && j > 0) {
|
|
this.k = true;
|
|
c<T, R> cVar = this.j;
|
|
cVar.i.onNext(this.i);
|
|
cVar.l.b(1);
|
|
cVar.r = false;
|
|
cVar.a();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: OnSubscribeConcatMap */
|
|
public static final class b<T, R> extends Subscriber<R> {
|
|
public final c<T, R> i;
|
|
public long j;
|
|
|
|
public b(c<T, R> cVar) {
|
|
this.i = cVar;
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
c<T, R> cVar = this.i;
|
|
long j = this.j;
|
|
if (j != 0) {
|
|
cVar.l.b(j);
|
|
}
|
|
cVar.r = false;
|
|
cVar.a();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
c<T, R> cVar = this.i;
|
|
long j = this.j;
|
|
if (!d.f(cVar.o, th)) {
|
|
l.b(th);
|
|
} else if (cVar.k == 0) {
|
|
Throwable h = d.h(cVar.o);
|
|
if (!d.g(h)) {
|
|
cVar.i.onError(h);
|
|
}
|
|
cVar.unsubscribe();
|
|
} else {
|
|
if (j != 0) {
|
|
cVar.l.b(j);
|
|
}
|
|
cVar.r = false;
|
|
cVar.a();
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(R r) {
|
|
this.j++;
|
|
this.i.i.onNext(r);
|
|
}
|
|
|
|
@Override // rx.Subscriber
|
|
public void setProducer(Producer producer) {
|
|
this.i.l.c(producer);
|
|
}
|
|
}
|
|
|
|
/* compiled from: OnSubscribeConcatMap */
|
|
public static final class c<T, R> extends Subscriber<T> {
|
|
public final Subscriber<? super R> i;
|
|
public final j0.k.b<? super T, ? extends Observable<? extends R>> j;
|
|
public final int k;
|
|
public final j0.l.b.a l = new j0.l.b.a();
|
|
public final Queue<Object> m;
|
|
public final AtomicInteger n = new AtomicInteger();
|
|
public final AtomicReference<Throwable> o = new AtomicReference<>();
|
|
public final SerialSubscription p;
|
|
public volatile boolean q;
|
|
public volatile boolean r;
|
|
|
|
public c(Subscriber<? super R> subscriber, j0.k.b<? super T, ? extends Observable<? extends R>> bVar, int i, int i2) {
|
|
this.i = subscriber;
|
|
this.j = bVar;
|
|
this.k = i2;
|
|
this.m = y.b() ? new n<>(i) : new j0.l.e.m.c<>(i);
|
|
this.p = new SerialSubscription();
|
|
request((long) i);
|
|
}
|
|
|
|
public void a() {
|
|
if (this.n.getAndIncrement() == 0) {
|
|
int i = this.k;
|
|
while (!this.i.isUnsubscribed()) {
|
|
if (!this.r) {
|
|
if (i != 1 || this.o.get() == null) {
|
|
boolean z2 = this.q;
|
|
Object poll = this.m.poll();
|
|
boolean z3 = poll == null;
|
|
if (z2 && z3) {
|
|
Throwable h = d.h(this.o);
|
|
if (h == null) {
|
|
this.i.onCompleted();
|
|
return;
|
|
} else if (!d.g(h)) {
|
|
this.i.onError(h);
|
|
return;
|
|
} else {
|
|
return;
|
|
}
|
|
} else if (!z3) {
|
|
try {
|
|
Observable<Object> observable = (Observable) this.j.call((Object) e.b(poll));
|
|
if (observable == null) {
|
|
b(new NullPointerException("The source returned by the mapper was null"));
|
|
return;
|
|
} else if (observable != c.j) {
|
|
if (observable instanceof j) {
|
|
this.r = true;
|
|
this.l.c(new a(((j) observable).k, this));
|
|
} else {
|
|
b bVar = new b(this);
|
|
this.p.a(bVar);
|
|
if (!bVar.isUnsubscribed()) {
|
|
this.r = true;
|
|
observable.i0(bVar);
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
request(1);
|
|
} else {
|
|
request(1);
|
|
}
|
|
} catch (Throwable th) {
|
|
c.q.a.k.a.a0(th);
|
|
b(th);
|
|
return;
|
|
}
|
|
}
|
|
} else {
|
|
Throwable h2 = d.h(this.o);
|
|
if (!d.g(h2)) {
|
|
this.i.onError(h2);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (this.n.decrementAndGet() == 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void b(Throwable th) {
|
|
unsubscribe();
|
|
if (d.f(this.o, th)) {
|
|
Throwable h = d.h(this.o);
|
|
if (!d.g(h)) {
|
|
this.i.onError(h);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
l.b(th);
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
this.q = true;
|
|
a();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
if (d.f(this.o, th)) {
|
|
this.q = true;
|
|
if (this.k == 0) {
|
|
Throwable h = d.h(this.o);
|
|
if (!d.g(h)) {
|
|
this.i.onError(h);
|
|
}
|
|
this.p.i.unsubscribe();
|
|
return;
|
|
}
|
|
a();
|
|
return;
|
|
}
|
|
l.b(th);
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
Queue<Object> queue = this.m;
|
|
if (t == null) {
|
|
t = (T) e.b;
|
|
}
|
|
if (!queue.offer(t)) {
|
|
unsubscribe();
|
|
onError(new MissingBackpressureException());
|
|
return;
|
|
}
|
|
a();
|
|
}
|
|
}
|
|
|
|
public h(Observable<? extends T> observable, j0.k.b<? super T, ? extends Observable<? extends R>> bVar, int i, int i2) {
|
|
this.i = observable;
|
|
this.j = bVar;
|
|
}
|
|
|
|
@Override // rx.functions.Action1
|
|
public void call(Object obj) {
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
c cVar = new c(new SerializedSubscriber(subscriber), this.j, 2, 0);
|
|
subscriber.add(cVar);
|
|
subscriber.add(cVar.p);
|
|
subscriber.setProducer(new g(this, cVar));
|
|
if (!subscriber.isUnsubscribed()) {
|
|
this.i.i0(cVar);
|
|
}
|
|
}
|
|
}
|