autodispose-android / com.uber.autodispose.android / AutoDisposeAndroidPlugins / setOnCheckMainThread

setOnCheckMainThread

static fun setOnCheckMainThread(@Nullable mainThreadChecker: BooleanSupplier): Unit
static fun setOnCheckMainThread(@Nullable mainThreadChecker: BooleanSupplier): Unit

Sets the preferred main thread checker. If not null, the mainThreadChecker will be preferred in all main thread checks in #onCheckMainThread(BooleanSupplier) calls. This can be useful for JVM testing environments, where standard Android Looper APIs cannot be stubbed and thus should be overridden with a custom check.

This is a reset-able API, which means you can pass null as the parameter value to reset it. Alternatively, you can call #reset().

Parameters

mainThreadChecker - a BooleanSupplier to call to check if current execution is on the main thread. Should return true if it is on the main thread or false if not.