263 lines
9.0 KiB
Java
263 lines
9.0 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 fVV<T, R> extends fUX<T, R> {
|
|
private fSS<? super T, ? extends fSD<? extends R>> d;
|
|
private boolean e;
|
|
|
|
public fVV(InterfaceC13169fSq<T> interfaceC13169fSq, fSS<? super T, ? extends fSD<? extends R>> fss, boolean z) {
|
|
super(interfaceC13169fSq);
|
|
this.d = fss;
|
|
this.e = z;
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super R> interfaceC13174fSv) {
|
|
this.c.subscribe(new Sts(interfaceC13174fSv, this.d, this.e));
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class Sts<T, R> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
|
|
final boolean a;
|
|
final InterfaceC13174fSv<? super R> e;
|
|
fSJ g;
|
|
private volatile boolean h;
|
|
private fSS<? super T, ? extends fSD<? extends R>> j;
|
|
final fSC i = new fSC();
|
|
final C13355fYI d = new C13355fYI();
|
|
final AtomicInteger b = new AtomicInteger(1);
|
|
final AtomicReference<C13416fZs<R>> c = new AtomicReference<>();
|
|
|
|
Sts(InterfaceC13174fSv<? super R> interfaceC13174fSv, fSS<? super T, ? extends fSD<? 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.g, fsj)) {
|
|
this.g = fsj;
|
|
this.e.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
try {
|
|
fSD fsd = (fSD) Objects.requireNonNull(this.j.a(t), "The mapper returned a null SingleSource");
|
|
this.b.getAndIncrement();
|
|
HBt hBt = new HBt(this);
|
|
if (this.h || !this.i.e(hBt)) {
|
|
return;
|
|
}
|
|
fsd.c(hBt);
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
this.g.dispose();
|
|
onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.b.decrementAndGet();
|
|
if (fYR.c(this.d, th)) {
|
|
if (!this.a) {
|
|
this.i.dispose();
|
|
}
|
|
if (getAndIncrement() == 0) {
|
|
e();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.b.decrementAndGet();
|
|
if (getAndIncrement() == 0) {
|
|
e();
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
this.h = true;
|
|
this.g.dispose();
|
|
this.i.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.b;
|
|
AtomicReference<C13416fZs<R>> atomicReference = this.c;
|
|
int i = 1;
|
|
while (!this.h) {
|
|
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) {
|
|
C13355fYI c13355fYI = this.d;
|
|
InterfaceC13174fSv<? super R> interfaceC13174fSv2 = this.e;
|
|
Throwable b2 = fYR.b(c13355fYI);
|
|
if (b2 == null) {
|
|
interfaceC13174fSv2.onComplete();
|
|
return;
|
|
} else {
|
|
if (b2 != fYR.b) {
|
|
interfaceC13174fSv2.onError(b2);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
interfaceC13174fSv.onNext(b);
|
|
} else {
|
|
i = addAndGet(-i);
|
|
if (i == 0) {
|
|
return;
|
|
}
|
|
}
|
|
} else {
|
|
C13416fZs<R> c13416fZs2 = this.c.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.c.get();
|
|
if (c13416fZs3 != null) {
|
|
c13416fZs3.e();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
final class HBt extends AtomicReference<fSJ> implements InterfaceC13176fSx<R>, fSJ {
|
|
private Sts b;
|
|
|
|
HBt(Sts sts) {
|
|
this.b = sts;
|
|
}
|
|
|
|
@Override // o.InterfaceC13176fSx
|
|
public final void onSubscribe(fSJ fsj) {
|
|
EnumC13192fTf.a(this, fsj);
|
|
}
|
|
|
|
@Override // o.InterfaceC13176fSx
|
|
public final void e(R r) {
|
|
Sts sts = this.b;
|
|
sts.i.b(this);
|
|
if (sts.get() == 0) {
|
|
if (sts.compareAndSet(0, 1)) {
|
|
sts.e.onNext(r);
|
|
boolean z = sts.b.decrementAndGet() == 0;
|
|
C13416fZs<R> c13416fZs = sts.c.get();
|
|
if (z && (c13416fZs == null || c13416fZs.b.get() == c13416fZs.e.get())) {
|
|
C13355fYI c13355fYI = sts.d;
|
|
InterfaceC13174fSv<? super R> interfaceC13174fSv = sts.e;
|
|
Throwable b = fYR.b(c13355fYI);
|
|
if (b == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
} else {
|
|
if (b != fYR.b) {
|
|
interfaceC13174fSv.onError(b);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (sts.decrementAndGet() == 0) {
|
|
return;
|
|
}
|
|
sts.e();
|
|
}
|
|
}
|
|
C13416fZs<R> c13416fZs2 = sts.c.get();
|
|
if (c13416fZs2 == null) {
|
|
c13416fZs2 = new C13416fZs<>(AbstractC13163fSk.bufferSize());
|
|
AtomicReference<C13416fZs<R>> atomicReference = sts.c;
|
|
while (true) {
|
|
if (atomicReference.compareAndSet(null, c13416fZs2)) {
|
|
break;
|
|
} else if (atomicReference.get() != null) {
|
|
c13416fZs2 = sts.c.get();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
synchronized (c13416fZs2) {
|
|
c13416fZs2.b(r);
|
|
}
|
|
sts.b.decrementAndGet();
|
|
if (sts.getAndIncrement() != 0) {
|
|
return;
|
|
}
|
|
sts.e();
|
|
}
|
|
|
|
@Override // o.InterfaceC13176fSx
|
|
public final void onError(Throwable th) {
|
|
Sts sts = this.b;
|
|
sts.i.b(this);
|
|
if (fYR.c(sts.d, th)) {
|
|
if (!sts.a) {
|
|
sts.g.dispose();
|
|
sts.i.dispose();
|
|
}
|
|
sts.b.decrementAndGet();
|
|
if (sts.getAndIncrement() == 0) {
|
|
sts.e();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@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.h;
|
|
}
|
|
}
|
|
}
|