jimu-decompiled/sources/io/reactivex/internal/operators/observable/ObservableDoOnEach.java
2025-05-13 19:24:51 +02:00

122 lines
3.7 KiB
Java

package io.reactivex.internal.operators.observable;
import io.reactivex.ObservableSource;
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.plugins.RxJavaPlugins;
/* loaded from: classes2.dex */
public final class ObservableDoOnEach<T> extends AbstractObservableWithUpstream<T, T> {
final Consumer<? super T> b;
final Consumer<? super Throwable> c;
final Action d;
final Action e;
static final class DoOnEachObserver<T> implements Observer<T>, Disposable {
final Observer<? super T> a;
final Consumer<? super T> b;
final Consumer<? super Throwable> c;
final Action d;
final Action e;
Disposable f;
boolean g;
DoOnEachObserver(Observer<? super T> observer, Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action, Action action2) {
this.a = observer;
this.b = consumer;
this.c = consumer2;
this.d = action;
this.e = action2;
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
this.f.dispose();
}
@Override // io.reactivex.Observer
public void onComplete() {
if (this.g) {
return;
}
try {
this.d.run();
this.g = true;
this.a.onComplete();
try {
this.e.run();
} catch (Throwable th) {
Exceptions.b(th);
RxJavaPlugins.b(th);
}
} catch (Throwable th2) {
Exceptions.b(th2);
onError(th2);
}
}
@Override // io.reactivex.Observer
public void onError(Throwable th) {
if (this.g) {
RxJavaPlugins.b(th);
return;
}
this.g = true;
try {
this.c.accept(th);
} catch (Throwable th2) {
Exceptions.b(th2);
th = new CompositeException(th, th2);
}
this.a.onError(th);
try {
this.e.run();
} catch (Throwable th3) {
Exceptions.b(th3);
RxJavaPlugins.b(th3);
}
}
@Override // io.reactivex.Observer
public void onNext(T t) {
if (this.g) {
return;
}
try {
this.b.accept(t);
this.a.onNext(t);
} catch (Throwable th) {
Exceptions.b(th);
this.f.dispose();
onError(th);
}
}
@Override // io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
if (DisposableHelper.validate(this.f, disposable)) {
this.f = disposable;
this.a.onSubscribe(this);
}
}
}
public ObservableDoOnEach(ObservableSource<T> observableSource, Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action, Action action2) {
super(observableSource);
this.b = consumer;
this.c = consumer2;
this.d = action;
this.e = action2;
}
@Override // io.reactivex.Observable
public void subscribeActual(Observer<? super T> observer) {
this.a.subscribe(new DoOnEachObserver(observer, this.b, this.c, this.d, this.e));
}
}