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