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

133 lines
4.3 KiB
Java

package io.reactivex.internal.operators.observable;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.BiFunction;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.internal.disposables.EmptyDisposable;
import io.reactivex.internal.functions.ObjectHelper;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.Iterator;
/* loaded from: classes2.dex */
public final class ObservableZipIterable<T, U, V> extends Observable<V> {
final Observable<? extends T> a;
final Iterable<U> b;
final BiFunction<? super T, ? super U, ? extends V> c;
static final class ZipIterableObserver<T, U, V> implements Observer<T>, Disposable {
final Observer<? super V> a;
final Iterator<U> b;
final BiFunction<? super T, ? super U, ? extends V> c;
Disposable d;
boolean e;
ZipIterableObserver(Observer<? super V> observer, Iterator<U> it, BiFunction<? super T, ? super U, ? extends V> biFunction) {
this.a = observer;
this.b = it;
this.c = biFunction;
}
void a(Throwable th) {
this.e = true;
this.d.dispose();
this.a.onError(th);
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
this.d.dispose();
}
@Override // io.reactivex.Observer
public void onComplete() {
if (this.e) {
return;
}
this.e = true;
this.a.onComplete();
}
@Override // io.reactivex.Observer
public void onError(Throwable th) {
if (this.e) {
RxJavaPlugins.b(th);
} else {
this.e = true;
this.a.onError(th);
}
}
@Override // io.reactivex.Observer
public void onNext(T t) {
if (this.e) {
return;
}
try {
U next = this.b.next();
ObjectHelper.a(next, "The iterator returned a null value");
try {
V apply = this.c.apply(t, next);
ObjectHelper.a(apply, "The zipper function returned a null value");
this.a.onNext(apply);
try {
if (this.b.hasNext()) {
return;
}
this.e = true;
this.d.dispose();
this.a.onComplete();
} catch (Throwable th) {
Exceptions.b(th);
a(th);
}
} catch (Throwable th2) {
Exceptions.b(th2);
a(th2);
}
} catch (Throwable th3) {
Exceptions.b(th3);
a(th3);
}
}
@Override // io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
if (DisposableHelper.validate(this.d, disposable)) {
this.d = disposable;
this.a.onSubscribe(this);
}
}
}
public ObservableZipIterable(Observable<? extends T> observable, Iterable<U> iterable, BiFunction<? super T, ? super U, ? extends V> biFunction) {
this.a = observable;
this.b = iterable;
this.c = biFunction;
}
@Override // io.reactivex.Observable
public void subscribeActual(Observer<? super V> observer) {
try {
Iterator<U> it = this.b.iterator();
ObjectHelper.a(it, "The iterator returned by other is null");
Iterator<U> it2 = it;
try {
if (it2.hasNext()) {
this.a.subscribe(new ZipIterableObserver(observer, it2, this.c));
} else {
EmptyDisposable.complete(observer);
}
} catch (Throwable th) {
Exceptions.b(th);
EmptyDisposable.error(th, observer);
}
} catch (Throwable th2) {
Exceptions.b(th2);
EmptyDisposable.error(th2, observer);
}
}
}