99 lines
2.9 KiB
Java
99 lines
2.9 KiB
Java
package io.reactivex.internal.observers;
|
|
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.exceptions.CompositeException;
|
|
import io.reactivex.exceptions.Exceptions;
|
|
import io.reactivex.functions.Action;
|
|
import io.reactivex.functions.Consumer;
|
|
import io.reactivex.internal.disposables.DisposableHelper;
|
|
import io.reactivex.internal.functions.Functions;
|
|
import io.reactivex.observers.LambdaConsumerIntrospection;
|
|
import io.reactivex.plugins.RxJavaPlugins;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class LambdaObserver<T> extends AtomicReference<Disposable> implements Observer<T>, Disposable, LambdaConsumerIntrospection {
|
|
private static final long serialVersionUID = -7251123623727029452L;
|
|
final Action onComplete;
|
|
final Consumer<? super Throwable> onError;
|
|
final Consumer<? super T> onNext;
|
|
final Consumer<? super Disposable> onSubscribe;
|
|
|
|
public LambdaObserver(Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action, Consumer<? super Disposable> consumer3) {
|
|
this.onNext = consumer;
|
|
this.onError = consumer2;
|
|
this.onComplete = action;
|
|
this.onSubscribe = consumer3;
|
|
}
|
|
|
|
@Override // io.reactivex.disposables.Disposable
|
|
public void dispose() {
|
|
DisposableHelper.dispose(this);
|
|
}
|
|
|
|
public boolean hasCustomOnError() {
|
|
return this.onError != Functions.e;
|
|
}
|
|
|
|
public boolean isDisposed() {
|
|
return get() == DisposableHelper.DISPOSED;
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
lazySet(DisposableHelper.DISPOSED);
|
|
try {
|
|
this.onComplete.run();
|
|
} catch (Throwable th) {
|
|
Exceptions.b(th);
|
|
RxJavaPlugins.b(th);
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
if (isDisposed()) {
|
|
RxJavaPlugins.b(th);
|
|
return;
|
|
}
|
|
lazySet(DisposableHelper.DISPOSED);
|
|
try {
|
|
this.onError.accept(th);
|
|
} catch (Throwable th2) {
|
|
Exceptions.b(th2);
|
|
RxJavaPlugins.b(new CompositeException(th, th2));
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onNext(T t) {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
try {
|
|
this.onNext.accept(t);
|
|
} catch (Throwable th) {
|
|
Exceptions.b(th);
|
|
get().dispose();
|
|
onError(th);
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
if (DisposableHelper.setOnce(this, disposable)) {
|
|
try {
|
|
this.onSubscribe.accept(this);
|
|
} catch (Throwable th) {
|
|
Exceptions.b(th);
|
|
disposable.dispose();
|
|
onError(th);
|
|
}
|
|
}
|
|
}
|
|
}
|