Java 类io.reactivex.android.plugins.RxAndroidPlugins 实例源码

项目:GitHub    文件:AndroidSchedulersTest.java   
@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());
}
项目:OpenChat    文件:RxPluginTestRule.java   
@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();
        }
    };
}
项目:RxCommand    文件:ImmediateSchedulersRule.java   
@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();
            }
        }
    };
}
项目:mvvm-template    文件:RxSchedulersOverrideRule.java   
@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();
        }
    };
}
项目:cleanarchitecture-unidirectional    文件:RxSchedulersOverrideRule.java   
@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();
        }
    };
}
项目:RIBs    文件:AndroidSchedulersRule.java   
@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;
        }
      });
}
项目:android-mvvm-sample    文件:MovieDetailsViewModelTest.java   
@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();
        }
    });
}
项目:android-mvvm-sample    文件:MoviesViewModelTest.java   
@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();
        }
    });
}
项目:RxRedux    文件:ImmediateSchedulersRule.java   
@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();
            }
        }
    };
}
项目:RxSchedulerRule    文件:RxSchedulerRule.java   
@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();
        }
    };
}
项目:AndroidBaseApplication    文件:GetCountriesUsecaseTest.java   
@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( ) );

}
项目:quill    文件:RxSchedulersRule.java   
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();
            }
        }
    };
}
项目:loklak_wok_android    文件:SuggestPresenterTest.java   
@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();
}
项目:GitHub    文件:HomePresenterTest.java   
@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();
        }
      });
}
项目:GitHub    文件:HomePresenterTest.java   
@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();
        }
      });
}
项目:RxDiffUtil    文件:BaseTest.java   
@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();
        }
    });
}
项目:InstantAppStarter    文件:NewsSourcePresenterTest.java   
@BeforeClass
public static void onlyOnce() throws Exception {
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(
            new Function<Callable<Scheduler>, Scheduler>() {
                @Override
                public Scheduler apply(Callable<Scheduler> schedulerCallable)
                        throws Exception {
                    return Schedulers.trampoline();
                }
            });
}
项目:Quran    文件:RecentPageModelTest.java   
@BeforeClass
public static void setup() {
  RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.io());

  // sample recent pages
  long timestamp = System.currentTimeMillis();
  SAMPLE_RECENT_PAGES.add(new RecentPage(49, timestamp));
  SAMPLE_RECENT_PAGES.add(new RecentPage(100, timestamp - 10000));
}
项目:RIBs    文件:WorkflowTest.java   
@Before
public void setup() {
  RxAndroidPlugins.setInitMainThreadSchedulerHandler(
        new Function<Callable<Scheduler>, Scheduler>() {
            @Override
            public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
                return Schedulers.trampoline();
            }
        });
}
项目:RIBs    文件:AndroidSchedulersRule.java   
@Override
protected void finished(Description description) {
  RxAndroidPlugins.reset();
  if (restoreHandlers) {
    // https://github.com/ReactiveX/RxAndroid/pull/358
    //
    // RxAndroidPlugins.setInitMainThreadSchedulerHandler(originalInitMainThreadInitHandler);
    //            RxAndroidPlugins.setMainThreadSchedulerHandler(originalMainThreadHandler);
  }
}
项目:flowless    文件:LoginPresenterTest.java   
@Before
public void init() {
    loginPresenter = new LoginPresenter();
    // BoltsConfig.configureMocks();
    BundleFactoryConfig.setProvider(() -> Mockito.mock(Bundle.class));
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
}
项目:Moviper    文件:RxAndroidSchedulersOverrideRule.java   
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.setInitMainThreadSchedulerHandler(__ -> Schedulers.trampoline());
            base.evaluate();
        }
    };
}
项目:MVP-RX-Android-Sample    文件:NewsUseCaseTest.java   
@Before
public void setUp() throws Exception {
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(__ -> Schedulers.trampoline());
    RxJavaPlugins.setIoSchedulerHandler(__ -> Schedulers.trampoline());
    testModelsGenerator = new TestModelsGenerator();
    newsModelTestSubscriber = new TestSubscriber<>();
    compositeDisposable = new CompositeDisposable();
}
项目:mosby    文件:HomePresenterTest.java   
@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();
        }
      });
}
项目:Bill-Calculator    文件:RxJavaBaseTest.java   
@Before
public void init() {
    testScheduler = new TestScheduler();
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> testScheduler);
    RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> testScheduler);
    RxJavaPlugins.setIoSchedulerHandler(scheduler -> testScheduler);
}
项目:GitHub    文件:HomePresenterTest.java   
@AfterClass public static void tearDown() throws Exception {
  RxAndroidPlugins.reset();
}
项目:GitHub    文件:AndroidSchedulers.java   
/** A {@link Scheduler} which executes actions on the Android main thread. */
public static Scheduler mainThread() {
    return RxAndroidPlugins.onMainThreadScheduler(MAIN_THREAD);
}
项目:GitHub    文件:AndroidSchedulersTest.java   
@Before @After
public void setUpAndTearDown() {
    RxAndroidPlugins.reset();
}
项目:GitHub    文件:HomePresenterTest.java   
@AfterClass public static void tearDown() throws Exception {
  RxAndroidPlugins.reset();
}
项目:InstantAppStarter    文件:NewsSourcePresenterTest.java   
@After
public void tearDown(){
    mockMvpPresenter.onDetach();
    RxAndroidPlugins.reset();
}
项目:Quran    文件:TagBookmarkPresenterTest.java   
@BeforeClass
public static void setup() {
  RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.io());
}
项目:Quran    文件:BookmarkPresenterTest.java   
@BeforeClass
public static void setup() {
  RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.io());
}
项目:RIBs    文件:WorkflowTest.java   
@After
public void cleanup() {
    RxAndroidPlugins.reset();
}
项目:flowless    文件:RepositoriesPresenterTest.java   
@Before
public void init() {
    repositoriesPresenter = new RepositoriesPresenter();
    // BoltsConfig.configureMocks();
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
}
项目:AndroidBaseApplication    文件:GetCountriesUsecaseTest.java   
@After
public void tearDown ()
{
    RxAndroidPlugins.reset( );
}
项目:MVP-RX-Android-Sample    文件:NewsUseCaseTest.java   
@After
public void tearDown() {
    RxJavaPlugins.reset();
    RxAndroidPlugins.reset();
}
项目:mosby    文件:HomePresenterTest.java   
@AfterClass public static void tearDown() throws Exception {
  RxAndroidPlugins.reset();
}
项目:Bill-Calculator    文件:RxJavaBaseTest.java   
@After
public void shutDown() throws Exception {
    RxJavaPlugins.reset();
    RxAndroidPlugins.reset();
}