本文整理汇总了Java中io.reactivex.android.plugins.RxAndroidPlugins类的典型用法代码示例。如果您正苦于以下问题:Java RxAndroidPlugins类的具体用法?Java RxAndroidPlugins怎么用?Java RxAndroidPlugins使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxAndroidPlugins类属于io.reactivex.android.plugins包,在下文中一共展示了RxAndroidPlugins类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mainThreadCallsThroughToHook
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Test
public void mainThreadCallsThroughToHook() {
final AtomicInteger called = new AtomicInteger();
final Scheduler newScheduler = new EmptyScheduler();
RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override public Scheduler apply(Scheduler scheduler) {
called.getAndIncrement();
return newScheduler;
}
});
assertSame(newScheduler, AndroidSchedulers.mainThread());
assertEquals(1, called.get());
assertSame(newScheduler, AndroidSchedulers.mainThread());
assertEquals(2, called.get());
}
示例2: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例3: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
try {
base.evaluate();
} finally {
RxJavaPlugins.reset();
RxAndroidPlugins.reset();
}
}
};
}
示例4: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.setComputationSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.setNewThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例5: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(mRxAndroidSchedulersHook);
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(mRxJavaImmediateScheduler);
RxJavaPlugins.setNewThreadSchedulerHandler(mRxJavaImmediateScheduler);
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例6: starting
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
protected void starting(Description description) {
if (restoreHandlers) {
// https://github.com/ReactiveX/RxAndroid/pull/358
// originalInitMainThreadInitHandler =
// RxAndroidPlugins.getInitMainThreadScheduler();
// originalMainThreadHandler = RxAndroidPlugins.getMainThreadScheduler();
}
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(
new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
return delegatingMainThreadScheduler;
}
});
RxAndroidPlugins.setMainThreadSchedulerHandler(
new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) throws Exception {
return delegatingMainThreadScheduler;
}
});
}
示例7: setupRxJavaPlugins
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@BeforeClass
public static void setupRxJavaPlugins() {
RxJavaPlugins.setIoSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) throws Exception {
return Schedulers.trampoline();
}
});
RxAndroidPlugins.setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
return Schedulers.trampoline();
}
});
}
示例8: setupClass
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {
RxAndroidPlugins.setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
return Schedulers.trampoline();
}
});
RxJavaPlugins.setIoSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) throws Exception {
return Schedulers.trampoline();
}
});
}
示例9: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.setComputationSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.setNewThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
try {
base.evaluate();
} finally {
RxJavaPlugins.reset();
}
}
};
}
示例10: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerFunctionLazy);
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(schedulerFunction);
RxJavaPlugins.setNewThreadSchedulerHandler(schedulerFunction);
RxJavaPlugins.setComputationSchedulerHandler(schedulerFunction);
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例11: setUp
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Before
public void setUp ()
{
RxAndroidPlugins.setInitMainThreadSchedulerHandler( new Function<Callable<Scheduler>,
Scheduler>( )
{
@Override
public Scheduler apply (@NonNull Callable<Scheduler> schedulerCallable) throws Exception
{
return Schedulers.trampoline( );
}
} );
when( mockCountryRepository.countries( getCountriesList.policy ) )
.thenReturn( Observable.<List<Country>>empty( ) );
}
示例12: apply
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Scheduler scheduler = TrampolineScheduler.instance();
Function<Callable<Scheduler>, Scheduler> schedulerFn = __ -> scheduler;
RxJavaPlugins.reset();
RxJavaPlugins.setInitIoSchedulerHandler(schedulerFn);
RxJavaPlugins.setInitNewThreadSchedulerHandler(schedulerFn);
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerFn);
try {
base.evaluate();
} finally {
RxJavaPlugins.reset();
RxAndroidPlugins.reset();
}
}
};
}
示例13: setUp
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mMockView = mock(SuggestContract.View.class);
mApi = mock(LoklakAPI.class);
mPresenter = new SuggestPresenter(mApi, mDb);
mPresenter.attachView(mMockView);
queries = getFakeQueries();
RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
mDb.beginTransaction();
mDb.copyToRealm(queries);
mDb.commitTransaction();
}
示例14: init
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@BeforeClass public static void init() throws Exception {
// Tell RxAndroid to not use android main ui thread scheduler
RxAndroidPlugins.setInitMainThreadSchedulerHandler(
new Function<Callable<Scheduler>, Scheduler>() {
@Override public Scheduler apply(@NonNull Callable<Scheduler> schedulerCallable)
throws Exception {
return Schedulers.trampoline();
}
});
}
示例15: setupBaseTestBeforeClass
import io.reactivex.android.plugins.RxAndroidPlugins; //导入依赖的package包/类
@BeforeClass
public static void setupBaseTestBeforeClass() {
RxJavaPlugins.onComputationScheduler(Schedulers.trampoline());
RxAndroidPlugins.setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(@NonNull Callable<Scheduler> schedulerCallable) throws Exception {
return Schedulers.trampoline();
}
});
}