297 lines
10 KiB
Java
297 lines
10 KiB
Java
package o;
|
|
|
|
import android.R;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class fVW<T, R> extends fUX<T, R> {
|
|
private fSS<? super T, ? extends InterfaceC13160fSh<? extends R>> a;
|
|
private boolean d;
|
|
|
|
public fVW(InterfaceC13169fSq<T> interfaceC13169fSq, fSS<? super T, ? extends InterfaceC13160fSh<? extends R>> fss, boolean z) {
|
|
super(interfaceC13169fSq);
|
|
this.a = fss;
|
|
this.d = z;
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super R> interfaceC13174fSv) {
|
|
this.c.subscribe(new LWm(interfaceC13174fSv, this.a, this.d));
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class LWm<T, R> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
|
|
final boolean a;
|
|
final InterfaceC13174fSv<? super R> e;
|
|
fSJ h;
|
|
private volatile boolean i;
|
|
private fSS<? super T, ? extends InterfaceC13160fSh<? extends R>> j;
|
|
final fSC g = new fSC();
|
|
final C13355fYI d = new C13355fYI();
|
|
final AtomicInteger c = new AtomicInteger(1);
|
|
final AtomicReference<C13416fZs<R>> b = new AtomicReference<>();
|
|
|
|
LWm(InterfaceC13174fSv<? super R> interfaceC13174fSv, fSS<? super T, ? extends InterfaceC13160fSh<? extends R>> fss, boolean z) {
|
|
this.e = interfaceC13174fSv;
|
|
this.j = fss;
|
|
this.a = z;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (EnumC13192fTf.d(this.h, fsj)) {
|
|
this.h = fsj;
|
|
this.e.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
try {
|
|
InterfaceC13160fSh interfaceC13160fSh = (InterfaceC13160fSh) Objects.requireNonNull(this.j.a(t), "The mapper returned a null MaybeSource");
|
|
this.c.getAndIncrement();
|
|
Sts sts = new Sts(this);
|
|
if (this.i || !this.g.e(sts)) {
|
|
return;
|
|
}
|
|
interfaceC13160fSh.c(sts);
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
this.h.dispose();
|
|
onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.c.decrementAndGet();
|
|
if (fYR.c(this.d, th)) {
|
|
if (!this.a) {
|
|
this.g.dispose();
|
|
}
|
|
if (getAndIncrement() == 0) {
|
|
e();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.c.decrementAndGet();
|
|
if (getAndIncrement() == 0) {
|
|
e();
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
this.i = true;
|
|
this.h.dispose();
|
|
this.g.dispose();
|
|
Throwable b = fYR.b(this.d);
|
|
if (b == null || b == fYR.b) {
|
|
return;
|
|
}
|
|
C13418fZu.c(b);
|
|
}
|
|
|
|
final void e() {
|
|
InterfaceC13174fSv<? super R> interfaceC13174fSv = this.e;
|
|
AtomicInteger atomicInteger = this.c;
|
|
AtomicReference<C13416fZs<R>> atomicReference = this.b;
|
|
int i = 1;
|
|
while (!this.i) {
|
|
if (this.a || this.d.get() == null) {
|
|
boolean z = atomicInteger.get() == 0;
|
|
C13416fZs<R> c13416fZs = atomicReference.get();
|
|
R.color b = c13416fZs != null ? c13416fZs.b() : null;
|
|
boolean z2 = b == null;
|
|
if (z && z2) {
|
|
Throwable b2 = fYR.b(this.d);
|
|
if (b2 == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
} else {
|
|
if (b2 != fYR.b) {
|
|
interfaceC13174fSv.onError(b2);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
interfaceC13174fSv.onNext(b);
|
|
} else {
|
|
i = addAndGet(-i);
|
|
if (i == 0) {
|
|
return;
|
|
}
|
|
}
|
|
} else {
|
|
C13416fZs<R> c13416fZs2 = this.b.get();
|
|
if (c13416fZs2 != null) {
|
|
c13416fZs2.e();
|
|
}
|
|
Throwable b3 = fYR.b(this.d);
|
|
if (b3 == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
} else {
|
|
if (b3 != fYR.b) {
|
|
interfaceC13174fSv.onError(b3);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
C13416fZs<R> c13416fZs3 = this.b.get();
|
|
if (c13416fZs3 != null) {
|
|
c13416fZs3.e();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
final class Sts extends AtomicReference<fSJ> implements InterfaceC13161fSi<R>, fSJ {
|
|
private LWm d;
|
|
|
|
Sts(LWm lWm) {
|
|
this.d = lWm;
|
|
}
|
|
|
|
@Override // o.InterfaceC13161fSi
|
|
public final void onSubscribe(fSJ fsj) {
|
|
EnumC13192fTf.a(this, fsj);
|
|
}
|
|
|
|
@Override // o.InterfaceC13161fSi
|
|
public final void e(R r) {
|
|
LWm lWm = this.d;
|
|
lWm.g.b(this);
|
|
if (lWm.get() == 0) {
|
|
if (lWm.compareAndSet(0, 1)) {
|
|
lWm.e.onNext(r);
|
|
boolean z = lWm.c.decrementAndGet() == 0;
|
|
C13416fZs<R> c13416fZs = lWm.b.get();
|
|
if (z && (c13416fZs == null || c13416fZs.b.get() == c13416fZs.e.get())) {
|
|
C13355fYI c13355fYI = lWm.d;
|
|
InterfaceC13174fSv<? super R> interfaceC13174fSv = lWm.e;
|
|
Throwable b = fYR.b(c13355fYI);
|
|
if (b == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
} else {
|
|
if (b != fYR.b) {
|
|
interfaceC13174fSv.onError(b);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (lWm.decrementAndGet() == 0) {
|
|
return;
|
|
}
|
|
lWm.e();
|
|
}
|
|
}
|
|
C13416fZs<R> c13416fZs2 = lWm.b.get();
|
|
if (c13416fZs2 == null) {
|
|
c13416fZs2 = new C13416fZs<>(AbstractC13163fSk.bufferSize());
|
|
AtomicReference<C13416fZs<R>> atomicReference = lWm.b;
|
|
while (true) {
|
|
if (atomicReference.compareAndSet(null, c13416fZs2)) {
|
|
break;
|
|
} else if (atomicReference.get() != null) {
|
|
c13416fZs2 = lWm.b.get();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
synchronized (c13416fZs2) {
|
|
c13416fZs2.b(r);
|
|
}
|
|
lWm.c.decrementAndGet();
|
|
if (lWm.getAndIncrement() != 0) {
|
|
return;
|
|
}
|
|
lWm.e();
|
|
}
|
|
|
|
@Override // o.InterfaceC13161fSi
|
|
public final void onError(Throwable th) {
|
|
LWm lWm = this.d;
|
|
lWm.g.b(this);
|
|
if (fYR.c(lWm.d, th)) {
|
|
if (!lWm.a) {
|
|
lWm.h.dispose();
|
|
lWm.g.dispose();
|
|
}
|
|
lWm.c.decrementAndGet();
|
|
if (lWm.getAndIncrement() == 0) {
|
|
lWm.e();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13161fSi
|
|
public final void onComplete() {
|
|
LWm lWm = this.d;
|
|
lWm.g.b(this);
|
|
if (lWm.get() == 0) {
|
|
if (lWm.compareAndSet(0, 1)) {
|
|
boolean z = lWm.c.decrementAndGet() == 0;
|
|
C13416fZs<R> c13416fZs = lWm.b.get();
|
|
if (z && (c13416fZs == null || c13416fZs.b.get() == c13416fZs.e.get())) {
|
|
C13355fYI c13355fYI = lWm.d;
|
|
InterfaceC13174fSv<? super R> interfaceC13174fSv = lWm.e;
|
|
Throwable b = fYR.b(c13355fYI);
|
|
if (b == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
} else {
|
|
if (b != fYR.b) {
|
|
interfaceC13174fSv.onError(b);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (lWm.decrementAndGet() != 0) {
|
|
lWm.e();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
lWm.c.decrementAndGet();
|
|
if (lWm.getAndIncrement() == 0) {
|
|
lWm.e();
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return EnumC13192fTf.c(get());
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
EnumC13192fTf.e(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.i;
|
|
}
|
|
}
|
|
}
|