what-the-bank/sources/o/fWA.java

201 lines
6.2 KiB
Java

package o;
import android.R;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes6.dex */
public final class fWA<T> extends fUX<T, T> {
private fSD<? extends T> b;
public fWA(AbstractC13163fSk<T> abstractC13163fSk, fSD<? extends T> fsd) {
super(abstractC13163fSk);
this.b = fsd;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
RVV rvv = new RVV(interfaceC13174fSv);
interfaceC13174fSv.onSubscribe(rvv);
this.c.subscribe(rvv);
this.b.c(rvv.b);
}
/* loaded from: classes6.dex */
static final class RVV<T> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
final InterfaceC13174fSv<? super T> a;
volatile int d;
T f;
private volatile boolean g;
private volatile InterfaceC13408fZk<T> h;
private volatile boolean j;
final AtomicReference<fSJ> c = new AtomicReference<>();
final HBt<T> b = new HBt<>(this);
final C13355fYI e = new C13355fYI();
RVV(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
this.a = interfaceC13174fSv;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this.c, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
if (compareAndSet(0, 1)) {
this.a.onNext(t);
if (decrementAndGet() == 0) {
return;
}
} else {
C13416fZs c13416fZs = this.h;
if (c13416fZs == null) {
c13416fZs = new C13416fZs(AbstractC13163fSk.bufferSize());
this.h = c13416fZs;
}
c13416fZs.b(t);
if (getAndIncrement() != 0) {
return;
}
}
b();
}
@Override // o.fSJ
public final boolean isDisposed() {
return EnumC13192fTf.c(this.c.get());
}
@Override // o.fSJ
public final void dispose() {
this.g = true;
EnumC13192fTf.e(this.c);
EnumC13192fTf.e(this.b);
Throwable b = fYR.b(this.e);
if (b != null && b != fYR.b) {
C13418fZu.c(b);
}
if (getAndIncrement() == 0) {
this.h = null;
this.f = null;
}
}
final void b() {
InterfaceC13174fSv<? super T> interfaceC13174fSv = this.a;
int i = 1;
while (!this.g) {
if (this.e.get() == null) {
int i2 = this.d;
if (i2 == 1) {
T t = this.f;
this.f = null;
this.d = 2;
interfaceC13174fSv.onNext(t);
i2 = 2;
}
boolean z = this.j;
InterfaceC13408fZk<T> interfaceC13408fZk = this.h;
R.color b = interfaceC13408fZk != null ? interfaceC13408fZk.b() : null;
boolean z2 = b == null;
if (z && z2 && i2 == 2) {
this.h = null;
interfaceC13174fSv.onComplete();
return;
} else if (!z2) {
interfaceC13174fSv.onNext(b);
} else {
i = addAndGet(-i);
if (i == 0) {
return;
}
}
} else {
this.f = null;
this.h = null;
Throwable b2 = fYR.b(this.e);
if (b2 == null) {
interfaceC13174fSv.onComplete();
return;
} else {
if (b2 != fYR.b) {
interfaceC13174fSv.onError(b2);
return;
}
return;
}
}
}
this.f = null;
this.h = null;
}
/* loaded from: classes6.dex */
static final class HBt<T> extends AtomicReference<fSJ> implements InterfaceC13176fSx<T> {
private RVV<T> d;
HBt(RVV<T> rvv) {
this.d = rvv;
}
@Override // o.InterfaceC13176fSx
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this, fsj);
}
@Override // o.InterfaceC13176fSx
public final void onError(Throwable th) {
RVV<T> rvv = this.d;
if (fYR.c(rvv.e, th)) {
EnumC13192fTf.e(rvv.c);
if (rvv.getAndIncrement() == 0) {
rvv.b();
return;
}
return;
}
C13418fZu.c(th);
}
@Override // o.InterfaceC13176fSx
public final void e(T t) {
RVV<T> rvv = this.d;
if (rvv.compareAndSet(0, 1)) {
rvv.a.onNext(t);
rvv.d = 2;
} else {
rvv.f = t;
rvv.d = 1;
if (rvv.getAndIncrement() != 0) {
return;
}
}
rvv.b();
}
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
this.j = true;
if (getAndIncrement() == 0) {
b();
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (fYR.c(this.e, th)) {
EnumC13192fTf.e(this.b);
if (getAndIncrement() == 0) {
b();
return;
}
return;
}
C13418fZu.c(th);
}
}
}