mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 09:57:16 +01:00
86 lines
3.1 KiB
Java
86 lines
3.1 KiB
Java
package io.reactivex.rxjava3.android.plugins;
|
|
|
|
import io.reactivex.rxjava3.core.Scheduler;
|
|
import io.reactivex.rxjava3.exceptions.Exceptions;
|
|
import io.reactivex.rxjava3.functions.Function;
|
|
import java.util.concurrent.Callable;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes.dex */
|
|
public final class RxAndroidPlugins {
|
|
private static volatile Function<Callable<Scheduler>, Scheduler> onInitMainThreadHandler;
|
|
private static volatile Function<Scheduler, Scheduler> onMainThreadHandler;
|
|
|
|
private RxAndroidPlugins() {
|
|
throw new AssertionError("No instances.");
|
|
}
|
|
|
|
public static <T, R> R apply(Function<T, R> function, T t) {
|
|
try {
|
|
return function.apply(t);
|
|
} catch (Throwable th) {
|
|
throw Exceptions.propagate(th);
|
|
}
|
|
}
|
|
|
|
public static Scheduler applyRequireNonNull(Function<Callable<Scheduler>, Scheduler> function, Callable<Scheduler> callable) {
|
|
Scheduler scheduler = (Scheduler) apply(function, callable);
|
|
if (scheduler != null) {
|
|
return scheduler;
|
|
}
|
|
Single$$ExternalSyntheticBUOutline0.m$1("Scheduler Callable returned null");
|
|
return null;
|
|
}
|
|
|
|
public static Scheduler callRequireNonNull(Callable<Scheduler> callable) {
|
|
try {
|
|
Scheduler call = callable.call();
|
|
if (call != null) {
|
|
return call;
|
|
}
|
|
throw new NullPointerException("Scheduler Callable returned null");
|
|
} catch (Throwable th) {
|
|
throw Exceptions.propagate(th);
|
|
}
|
|
}
|
|
|
|
public static Function<Callable<Scheduler>, Scheduler> getInitMainThreadSchedulerHandler() {
|
|
return onInitMainThreadHandler;
|
|
}
|
|
|
|
public static Function<Scheduler, Scheduler> getOnMainThreadSchedulerHandler() {
|
|
return onMainThreadHandler;
|
|
}
|
|
|
|
public static Scheduler initMainThreadScheduler(Callable<Scheduler> callable) {
|
|
if (callable != null) {
|
|
Function<Callable<Scheduler>, Scheduler> function = onInitMainThreadHandler;
|
|
return function == null ? callRequireNonNull(callable) : applyRequireNonNull(function, callable);
|
|
}
|
|
Single$$ExternalSyntheticBUOutline0.m$1("scheduler == null");
|
|
return null;
|
|
}
|
|
|
|
public static Scheduler onMainThreadScheduler(Scheduler scheduler) {
|
|
if (scheduler != null) {
|
|
Function<Scheduler, Scheduler> function = onMainThreadHandler;
|
|
return function == null ? scheduler : (Scheduler) apply(function, scheduler);
|
|
}
|
|
Single$$ExternalSyntheticBUOutline0.m$1("scheduler == null");
|
|
return null;
|
|
}
|
|
|
|
public static void reset() {
|
|
setInitMainThreadSchedulerHandler(null);
|
|
setMainThreadSchedulerHandler(null);
|
|
}
|
|
|
|
public static void setInitMainThreadSchedulerHandler(Function<Callable<Scheduler>, Scheduler> function) {
|
|
onInitMainThreadHandler = function;
|
|
}
|
|
|
|
public static void setMainThreadSchedulerHandler(Function<Scheduler, Scheduler> function) {
|
|
onMainThreadHandler = function;
|
|
}
|
|
}
|