mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-16 02:47:17 +01:00
110 lines
3.3 KiB
Java
110 lines
3.3 KiB
Java
package io.reactivex.rxjava3.internal.observers;
|
|
|
|
import io.reactivex.rxjava3.core.Observer;
|
|
import io.reactivex.rxjava3.disposables.Disposable;
|
|
import io.reactivex.rxjava3.exceptions.Exceptions;
|
|
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
|
|
import io.reactivex.rxjava3.operators.QueueDisposable;
|
|
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public abstract class BasicFuseableObserver<T, R> implements Observer<T>, QueueDisposable<R> {
|
|
protected boolean done;
|
|
protected final Observer<? super R> downstream;
|
|
protected QueueDisposable<T> qd;
|
|
protected int sourceMode;
|
|
protected Disposable upstream;
|
|
|
|
public BasicFuseableObserver(Observer<? super R> observer) {
|
|
this.downstream = observer;
|
|
}
|
|
|
|
public boolean beforeDownstream() {
|
|
return true;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public void clear() {
|
|
this.qd.clear();
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.disposables.Disposable
|
|
public void dispose() {
|
|
this.upstream.dispose();
|
|
}
|
|
|
|
public final void fail(Throwable th) {
|
|
Exceptions.throwIfFatal(th);
|
|
this.upstream.dispose();
|
|
onError(th);
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.disposables.Disposable
|
|
public boolean isDisposed() {
|
|
return this.upstream.isDisposed();
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public boolean isEmpty() {
|
|
return this.qd.isEmpty();
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public final boolean offer(R r) {
|
|
throw new UnsupportedOperationException("Should not be called!");
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.Observer
|
|
public void onComplete() {
|
|
if (this.done) {
|
|
return;
|
|
}
|
|
this.done = true;
|
|
this.downstream.onComplete();
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.Observer
|
|
public void onError(Throwable th) {
|
|
if (this.done) {
|
|
RxJavaPlugins.onError(th);
|
|
} else {
|
|
this.done = true;
|
|
this.downstream.onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.Observer
|
|
public final void onSubscribe(Disposable disposable) {
|
|
if (DisposableHelper.validate(this.upstream, disposable)) {
|
|
this.upstream = disposable;
|
|
if (disposable instanceof QueueDisposable) {
|
|
this.qd = (QueueDisposable) disposable;
|
|
}
|
|
if (beforeDownstream()) {
|
|
this.downstream.onSubscribe(this);
|
|
afterDownstream();
|
|
}
|
|
}
|
|
}
|
|
|
|
public final int transitiveBoundaryFusion(int i) {
|
|
QueueDisposable<T> queueDisposable = this.qd;
|
|
if (queueDisposable == null || (i & 4) != 0) {
|
|
return 0;
|
|
}
|
|
int requestFusion = queueDisposable.requestFusion(i);
|
|
if (requestFusion != 0) {
|
|
this.sourceMode = requestFusion;
|
|
}
|
|
return requestFusion;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public final boolean offer(R r, R r2) {
|
|
throw new UnsupportedOperationException("Should not be called!");
|
|
}
|
|
|
|
public void afterDownstream() {
|
|
}
|
|
}
|