Java Code Examples for io.reactivex.android.schedulers.AndroidSchedulers#mainThread()

The following examples show how to use io.reactivex.android.schedulers.AndroidSchedulers#mainThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadModeCastToSchedulersUtil.java    From RxEventBus with Apache License 2.0 6 votes vote down vote up
public static Scheduler cast(ThreadMode threadMode) {
    Scheduler scheduler = null;
    switch (threadMode) {
        case COMPUTATION:
            scheduler = Schedulers.computation();
            break;
        case NEWTHREAD:
            scheduler = Schedulers.newThread();
            break;
        case MAIN:
            scheduler = AndroidSchedulers.mainThread();
            break;
        case IO:
            scheduler = Schedulers.io();
            break;
        default:
            scheduler = AndroidSchedulers.mainThread();
            break;
    }
    return scheduler;
}
 
Example 2
Source File: RxBus.java    From RxBus2 with Apache License 2.0 6 votes vote down vote up
/**
 * 用于处理订阅事件在那个线程中执行
 *
 * @param observable       d
 * @param subscriberMethod d
 * @return Observable
 */
private Flowable postToObservable(Flowable observable, SubscriberMethod subscriberMethod) {
    Scheduler scheduler;
    switch (subscriberMethod.threadMode) {
        case MAIN:
            scheduler = AndroidSchedulers.mainThread();
            break;

        case NEW_THREAD:
            scheduler = Schedulers.newThread();
            break;

        case CURRENT_THREAD:
            scheduler = Schedulers.trampoline();
            break;
        default:
            throw new IllegalStateException("Unknown thread mode: " + subscriberMethod.threadMode);
    }
    return observable.observeOn(scheduler);
}
 
Example 3
Source File: CurrencyDetailsActivityModule.java    From exchange-rates-mvvm with Apache License 2.0 5 votes vote down vote up
@Provides
@CurrencyDetailsActivityScope
@Override
public GetCurrencySeriesUseCase provideGetCurrenciesUseCase(final CurrencyRepository currencyRepository) {
    return new GetCurrencySeriesUseCase(Schedulers.io(), AndroidSchedulers.mainThread(),
            currencyRepository);
}
 
Example 4
Source File: DefaultUseCaseThreadExecutor.java    From FederatedAndroidTrainer with MIT License 4 votes vote down vote up
@Override
public Scheduler getPostScheduler() {
    return AndroidSchedulers.mainThread();
}
 
Example 5
Source File: SchedulersFacade.java    From DaggerAndroidMVP with Apache License 2.0 4 votes vote down vote up
/**
 * Main Thread scheduler
 */
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 6
Source File: EoscSchedulerProvider.java    From EosCommander with MIT License 4 votes vote down vote up
@Override
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 7
Source File: SchedulerProvider.java    From Melophile with Apache License 2.0 4 votes vote down vote up
@NonNull
public Scheduler ui() {
  return AndroidSchedulers.mainThread();
}
 
Example 8
Source File: ThreadUtil.java    From AndroidGodEye with Apache License 2.0 4 votes vote down vote up
public static Scheduler mainScheduler() {
    if (sMainScheduler != null) {
        return sMainScheduler;
    }
    return AndroidSchedulers.mainThread();
}
 
Example 9
Source File: SchedulersFacade.java    From DaggerAndroidMVVM with Apache License 2.0 4 votes vote down vote up
/**
 * Main Thread scheduler
 */
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 10
Source File: AppSchedulerProvider.java    From android-mvvm-architecture with Apache License 2.0 4 votes vote down vote up
@Override
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 11
Source File: AppSchedulerProvider.java    From android-mvp-interactor-architecture with Apache License 2.0 4 votes vote down vote up
@Override
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 12
Source File: SchedulerProvider.java    From News with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 13
Source File: Rx.java    From klingar with Apache License 2.0 4 votes vote down vote up
private static Rx production() {
  return new Rx(Schedulers.io(), AndroidSchedulers.mainThread(), Schedulers.newThread());
}
 
Example 14
Source File: MockApplicationModule.java    From twittererer with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
Scheduler provideScheduler() {
    return AndroidSchedulers.mainThread();
}
 
Example 15
Source File: GeneralModule.java    From adamant-android with GNU General Public License v3.0 4 votes vote down vote up
@Named(Constants.UI_SCHEDULER)
@Singleton
@Provides
public static Scheduler provideUIObserveScheduler() {
    return AndroidSchedulers.mainThread();
}
 
Example 16
Source File: CurrenciesActivityModule.java    From exchange-rates-mvvm with Apache License 2.0 4 votes vote down vote up
@Provides
@CurrenciesActivityScope
@Override
public GetCurrenciesRatesDate provideGetCurrenciesRatesDate(final PreferencesData preferencesData) {
    return new GetCurrenciesRatesDate(Schedulers.io(), AndroidSchedulers.mainThread(), preferencesData);
}
 
Example 17
Source File: SchedulerProvider.java    From mockstar with MIT License 4 votes vote down vote up
@Override
@NonNull
public Scheduler ui() {
    return AndroidSchedulers.mainThread();
}
 
Example 18
Source File: UIThread.java    From Android-CleanArchitecture with Apache License 2.0 4 votes vote down vote up
@Override public Scheduler getScheduler() {
  return AndroidSchedulers.mainThread();
}
 
Example 19
Source File: MainActivity.java    From Database-First with Apache License 2.0 3 votes vote down vote up
@Override
protected UsersPresenter createPresenter() {

    UsersRemoteRepo remoteUsersRepo = new UsersRemoteRepoImpl();
    LocalDB localDB = Room.databaseBuilder(getApplicationContext(), LocalDB.class, DBConstant.DB_NAME).build();


    UsersLocalRepo localUsersRepo = new UsersLocalRepoImpl(localDB.usersDao());

    UsersRepo usersRepo = new UsersRepoImpl(remoteUsersRepo, localUsersRepo);

    return new UsersPresenterImpl(usersRepo, AndroidSchedulers.mainThread());
}
 
Example 20
Source File: SchedulerProviderImplementation.java    From NYBus with Apache License 2.0 2 votes vote down vote up
/**
 * Provides the main thread Scheduler.
 *
 * @return provides the main thread Scheduler.
 */
@Override
public Scheduler provideMainThreadScheduler() {
    return AndroidSchedulers.mainThread();
}