what-the-bank/sources/retrofit2/adapter/rxjava3/CallEnqueueObservable.java

100 lines
3.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package retrofit2.adapter.rxjava3;
import io.reactivex.rxjava3.exceptions.CompositeException;
import o.AbstractC13163fSk;
import o.C13147fSI;
import o.C13418fZu;
import o.InterfaceC13174fSv;
import o.fSJ;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/* loaded from: classes.dex */
final class CallEnqueueObservable<T> extends AbstractC13163fSk<Response<T>> {
private final Call<T> originalCall;
/* JADX INFO: Access modifiers changed from: package-private */
public CallEnqueueObservable(Call<T> call) {
this.originalCall = call;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super Response<T>> interfaceC13174fSv) {
Call<T> clone = this.originalCall.clone();
CallCallback callCallback = new CallCallback(clone, interfaceC13174fSv);
interfaceC13174fSv.onSubscribe(callCallback);
if (callCallback.isDisposed()) {
return;
}
clone.enqueue(callCallback);
}
/* loaded from: classes6.dex */
static final class CallCallback<T> implements fSJ, Callback<T> {
private final Call<?> call;
private volatile boolean disposed;
private final InterfaceC13174fSv<? super Response<T>> observer;
boolean terminated = false;
CallCallback(Call<?> call, InterfaceC13174fSv<? super Response<T>> interfaceC13174fSv) {
this.call = call;
this.observer = interfaceC13174fSv;
}
@Override // retrofit2.Callback
public final void onResponse(Call<T> call, Response<T> response) {
if (this.disposed) {
return;
}
try {
this.observer.onNext(response);
if (this.disposed) {
return;
}
this.terminated = true;
this.observer.onComplete();
} catch (Throwable th) {
C13147fSI.c(th);
if (this.terminated) {
C13418fZu.c(th);
return;
}
if (this.disposed) {
return;
}
try {
this.observer.onError(th);
} catch (Throwable th2) {
C13147fSI.c(th2);
C13418fZu.c(new CompositeException(th, th2));
}
}
}
@Override // retrofit2.Callback
public final void onFailure(Call<T> call, Throwable th) {
if (call.isCanceled()) {
return;
}
try {
this.observer.onError(th);
} catch (Throwable th2) {
C13147fSI.c(th2);
C13418fZu.c(new CompositeException(th, th2));
}
}
@Override // o.fSJ
public final void dispose() {
this.disposed = true;
this.call.cancel();
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.disposed;
}
}
}