339 lines
13 KiB
Java
339 lines
13 KiB
Java
package io.reactivex.internal.operators.observable;
|
|
|
|
import io.reactivex.Emitter;
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.ObservableSource;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.Scheduler;
|
|
import io.reactivex.functions.Action;
|
|
import io.reactivex.functions.BiConsumer;
|
|
import io.reactivex.functions.BiFunction;
|
|
import io.reactivex.functions.Consumer;
|
|
import io.reactivex.functions.Function;
|
|
import io.reactivex.internal.functions.Functions;
|
|
import io.reactivex.internal.functions.ObjectHelper;
|
|
import io.reactivex.observables.ConnectableObservable;
|
|
import java.util.List;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class ObservableInternalHelper {
|
|
|
|
static final class BufferedReplayCallable<T> implements Callable<ConnectableObservable<T>> {
|
|
private final Observable<T> a;
|
|
private final int b;
|
|
|
|
BufferedReplayCallable(Observable<T> observable, int i) {
|
|
this.a = observable;
|
|
this.b = i;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
public ConnectableObservable<T> call() {
|
|
return this.a.replay(this.b);
|
|
}
|
|
}
|
|
|
|
static final class BufferedTimedReplayCallable<T> implements Callable<ConnectableObservable<T>> {
|
|
private final Observable<T> a;
|
|
private final int b;
|
|
private final long c;
|
|
private final TimeUnit d;
|
|
private final Scheduler e;
|
|
|
|
BufferedTimedReplayCallable(Observable<T> observable, int i, long j, TimeUnit timeUnit, Scheduler scheduler) {
|
|
this.a = observable;
|
|
this.b = i;
|
|
this.c = j;
|
|
this.d = timeUnit;
|
|
this.e = scheduler;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
public ConnectableObservable<T> call() {
|
|
return this.a.replay(this.b, this.c, this.d, this.e);
|
|
}
|
|
}
|
|
|
|
static final class FlatMapIntoIterable<T, U> implements Function<T, ObservableSource<U>> {
|
|
private final Function<? super T, ? extends Iterable<? extends U>> a;
|
|
|
|
FlatMapIntoIterable(Function<? super T, ? extends Iterable<? extends U>> function) {
|
|
this.a = function;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // io.reactivex.functions.Function
|
|
public /* bridge */ /* synthetic */ Object apply(Object obj) throws Exception {
|
|
return apply((FlatMapIntoIterable<T, U>) obj);
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
public ObservableSource<U> apply(T t) throws Exception {
|
|
Iterable<? extends U> apply = this.a.apply(t);
|
|
ObjectHelper.a(apply, "The mapper returned a null Iterable");
|
|
return new ObservableFromIterable(apply);
|
|
}
|
|
}
|
|
|
|
static final class FlatMapWithCombinerInner<U, R, T> implements Function<U, R> {
|
|
private final BiFunction<? super T, ? super U, ? extends R> a;
|
|
private final T b;
|
|
|
|
FlatMapWithCombinerInner(BiFunction<? super T, ? super U, ? extends R> biFunction, T t) {
|
|
this.a = biFunction;
|
|
this.b = t;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
public R apply(U u) throws Exception {
|
|
return this.a.apply(this.b, u);
|
|
}
|
|
}
|
|
|
|
static final class FlatMapWithCombinerOuter<T, R, U> implements Function<T, ObservableSource<R>> {
|
|
private final BiFunction<? super T, ? super U, ? extends R> a;
|
|
private final Function<? super T, ? extends ObservableSource<? extends U>> b;
|
|
|
|
FlatMapWithCombinerOuter(BiFunction<? super T, ? super U, ? extends R> biFunction, Function<? super T, ? extends ObservableSource<? extends U>> function) {
|
|
this.a = biFunction;
|
|
this.b = function;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // io.reactivex.functions.Function
|
|
public /* bridge */ /* synthetic */ Object apply(Object obj) throws Exception {
|
|
return apply((FlatMapWithCombinerOuter<T, R, U>) obj);
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
public ObservableSource<R> apply(T t) throws Exception {
|
|
ObservableSource<? extends U> apply = this.b.apply(t);
|
|
ObjectHelper.a(apply, "The mapper returned a null ObservableSource");
|
|
return new ObservableMap(apply, new FlatMapWithCombinerInner(this.a, t));
|
|
}
|
|
}
|
|
|
|
static final class ItemDelayFunction<T, U> implements Function<T, ObservableSource<T>> {
|
|
final Function<? super T, ? extends ObservableSource<U>> a;
|
|
|
|
ItemDelayFunction(Function<? super T, ? extends ObservableSource<U>> function) {
|
|
this.a = function;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // io.reactivex.functions.Function
|
|
public /* bridge */ /* synthetic */ Object apply(Object obj) throws Exception {
|
|
return apply((ItemDelayFunction<T, U>) obj);
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
public ObservableSource<T> apply(T t) throws Exception {
|
|
ObservableSource<U> apply = this.a.apply(t);
|
|
ObjectHelper.a(apply, "The itemDelay returned a null ObservableSource");
|
|
return new ObservableTake(apply, 1L).map(Functions.c(t)).defaultIfEmpty(t);
|
|
}
|
|
}
|
|
|
|
static final class ObserverOnComplete<T> implements Action {
|
|
final Observer<T> a;
|
|
|
|
ObserverOnComplete(Observer<T> observer) {
|
|
this.a = observer;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Action
|
|
public void run() throws Exception {
|
|
this.a.onComplete();
|
|
}
|
|
}
|
|
|
|
static final class ObserverOnError<T> implements Consumer<Throwable> {
|
|
final Observer<T> a;
|
|
|
|
ObserverOnError(Observer<T> observer) {
|
|
this.a = observer;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Consumer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void accept(Throwable th) throws Exception {
|
|
this.a.onError(th);
|
|
}
|
|
}
|
|
|
|
static final class ObserverOnNext<T> implements Consumer<T> {
|
|
final Observer<T> a;
|
|
|
|
ObserverOnNext(Observer<T> observer) {
|
|
this.a = observer;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Consumer
|
|
public void accept(T t) throws Exception {
|
|
this.a.onNext(t);
|
|
}
|
|
}
|
|
|
|
static final class ReplayCallable<T> implements Callable<ConnectableObservable<T>> {
|
|
private final Observable<T> a;
|
|
|
|
ReplayCallable(Observable<T> observable) {
|
|
this.a = observable;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
public ConnectableObservable<T> call() {
|
|
return this.a.replay();
|
|
}
|
|
}
|
|
|
|
static final class ReplayFunction<T, R> implements Function<Observable<T>, ObservableSource<R>> {
|
|
private final Function<? super Observable<T>, ? extends ObservableSource<R>> a;
|
|
private final Scheduler b;
|
|
|
|
ReplayFunction(Function<? super Observable<T>, ? extends ObservableSource<R>> function, Scheduler scheduler) {
|
|
this.a = function;
|
|
this.b = scheduler;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public ObservableSource<R> apply(Observable<T> observable) throws Exception {
|
|
ObservableSource<R> apply = this.a.apply(observable);
|
|
ObjectHelper.a(apply, "The selector returned a null ObservableSource");
|
|
return Observable.wrap(apply).observeOn(this.b);
|
|
}
|
|
}
|
|
|
|
static final class SimpleBiGenerator<T, S> implements BiFunction<S, Emitter<T>, S> {
|
|
final BiConsumer<S, Emitter<T>> a;
|
|
|
|
SimpleBiGenerator(BiConsumer<S, Emitter<T>> biConsumer) {
|
|
this.a = biConsumer;
|
|
}
|
|
|
|
public S a(S s, Emitter<T> emitter) throws Exception {
|
|
this.a.a(s, emitter);
|
|
return s;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // io.reactivex.functions.BiFunction
|
|
public /* bridge */ /* synthetic */ Object apply(Object obj, Object obj2) throws Exception {
|
|
a(obj, (Emitter) obj2);
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
static final class SimpleGenerator<T, S> implements BiFunction<S, Emitter<T>, S> {
|
|
final Consumer<Emitter<T>> a;
|
|
|
|
SimpleGenerator(Consumer<Emitter<T>> consumer) {
|
|
this.a = consumer;
|
|
}
|
|
|
|
public S a(S s, Emitter<T> emitter) throws Exception {
|
|
this.a.accept(emitter);
|
|
return s;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // io.reactivex.functions.BiFunction
|
|
public /* bridge */ /* synthetic */ Object apply(Object obj, Object obj2) throws Exception {
|
|
a(obj, (Emitter) obj2);
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
static final class TimedReplayCallable<T> implements Callable<ConnectableObservable<T>> {
|
|
private final Observable<T> a;
|
|
private final long b;
|
|
private final TimeUnit c;
|
|
private final Scheduler d;
|
|
|
|
TimedReplayCallable(Observable<T> observable, long j, TimeUnit timeUnit, Scheduler scheduler) {
|
|
this.a = observable;
|
|
this.b = j;
|
|
this.c = timeUnit;
|
|
this.d = scheduler;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
public ConnectableObservable<T> call() {
|
|
return this.a.replay(this.b, this.c, this.d);
|
|
}
|
|
}
|
|
|
|
static final class ZipIterableFunction<T, R> implements Function<List<ObservableSource<? extends T>>, ObservableSource<? extends R>> {
|
|
private final Function<? super Object[], ? extends R> a;
|
|
|
|
ZipIterableFunction(Function<? super Object[], ? extends R> function) {
|
|
this.a = function;
|
|
}
|
|
|
|
@Override // io.reactivex.functions.Function
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public ObservableSource<? extends R> apply(List<ObservableSource<? extends T>> list) {
|
|
return Observable.zipIterable(list, this.a, false, Observable.bufferSize());
|
|
}
|
|
}
|
|
|
|
public static <T, S> BiFunction<S, Emitter<T>, S> a(Consumer<Emitter<T>> consumer) {
|
|
return new SimpleGenerator(consumer);
|
|
}
|
|
|
|
public static <T, U> Function<T, ObservableSource<T>> b(Function<? super T, ? extends ObservableSource<U>> function) {
|
|
return new ItemDelayFunction(function);
|
|
}
|
|
|
|
public static <T> Consumer<T> c(Observer<T> observer) {
|
|
return new ObserverOnNext(observer);
|
|
}
|
|
|
|
public static <T, S> BiFunction<S, Emitter<T>, S> a(BiConsumer<S, Emitter<T>> biConsumer) {
|
|
return new SimpleBiGenerator(biConsumer);
|
|
}
|
|
|
|
public static <T> Consumer<Throwable> b(Observer<T> observer) {
|
|
return new ObserverOnError(observer);
|
|
}
|
|
|
|
public static <T, R> Function<List<ObservableSource<? extends T>>, ObservableSource<? extends R>> c(Function<? super Object[], ? extends R> function) {
|
|
return new ZipIterableFunction(function);
|
|
}
|
|
|
|
public static <T> Action a(Observer<T> observer) {
|
|
return new ObserverOnComplete(observer);
|
|
}
|
|
|
|
public static <T, U, R> Function<T, ObservableSource<R>> a(Function<? super T, ? extends ObservableSource<? extends U>> function, BiFunction<? super T, ? super U, ? extends R> biFunction) {
|
|
return new FlatMapWithCombinerOuter(biFunction, function);
|
|
}
|
|
|
|
public static <T, U> Function<T, ObservableSource<U>> a(Function<? super T, ? extends Iterable<? extends U>> function) {
|
|
return new FlatMapIntoIterable(function);
|
|
}
|
|
|
|
public static <T> Callable<ConnectableObservable<T>> a(Observable<T> observable) {
|
|
return new ReplayCallable(observable);
|
|
}
|
|
|
|
public static <T> Callable<ConnectableObservable<T>> a(Observable<T> observable, int i) {
|
|
return new BufferedReplayCallable(observable, i);
|
|
}
|
|
|
|
public static <T> Callable<ConnectableObservable<T>> a(Observable<T> observable, int i, long j, TimeUnit timeUnit, Scheduler scheduler) {
|
|
return new BufferedTimedReplayCallable(observable, i, j, timeUnit, scheduler);
|
|
}
|
|
|
|
public static <T> Callable<ConnectableObservable<T>> a(Observable<T> observable, long j, TimeUnit timeUnit, Scheduler scheduler) {
|
|
return new TimedReplayCallable(observable, j, timeUnit, scheduler);
|
|
}
|
|
|
|
public static <T, R> Function<Observable<T>, ObservableSource<R>> a(Function<? super Observable<T>, ? extends ObservableSource<R>> function, Scheduler scheduler) {
|
|
return new ReplayFunction(function, scheduler);
|
|
}
|
|
}
|