当前位置: 首页>>代码示例>>Java>>正文


Java RxAndroidPlugins.setMainThreadSchedulerHandler方法代码示例

本文整理汇总了Java中io.reactivex.android.plugins.RxAndroidPlugins.setMainThreadSchedulerHandler方法的典型用法代码示例。如果您正苦于以下问题:Java RxAndroidPlugins.setMainThreadSchedulerHandler方法的具体用法?Java RxAndroidPlugins.setMainThreadSchedulerHandler怎么用?Java RxAndroidPlugins.setMainThreadSchedulerHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.android.plugins.RxAndroidPlugins的用法示例。


在下文中一共展示了RxAndroidPlugins.setMainThreadSchedulerHandler方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AndroidSchedulersTest.java

示例2: 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();
            }
        }
    };
}
 
开发者ID:listenzz,项目名称:RxCommand,代码行数:19,代码来源:ImmediateSchedulersRule.java

示例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.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();
        }
    };
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:21,代码来源:RxSchedulersOverrideRule.java

示例4: 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;
        }
      });
}
 
开发者ID:uber,项目名称:RIBs,代码行数:25,代码来源:AndroidSchedulersRule.java

示例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 {
            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();
            }
        }
    };
}
 
开发者ID:Zeyad-37,项目名称:RxRedux,代码行数:18,代码来源:ImmediateSchedulersRule.java

示例6: 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();
}
 
开发者ID:fossasia,项目名称:loklak_wok_android,代码行数:18,代码来源:SuggestPresenterTest.java

示例7: init

import io.reactivex.android.plugins.RxAndroidPlugins; //导入方法依赖的package包/类
@Before
public void init() {
    testScheduler = new TestScheduler();
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> testScheduler);
    RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> testScheduler);
    RxJavaPlugins.setIoSchedulerHandler(scheduler -> testScheduler);
}
 
开发者ID:sewerk,项目名称:Bill-Calculator,代码行数:8,代码来源:RxJavaBaseTest.java


注:本文中的io.reactivex.android.plugins.RxAndroidPlugins.setMainThreadSchedulerHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。