Java Code Examples for rx.schedulers.Schedulers#io()

The following examples show how to use rx.schedulers.Schedulers#io() . 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: FragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@FragmentScope @Provides AppViewManager providesAppViewManager(
    AppViewModelManager appViewModelManager, InstallManager installManager,
    DownloadFactory downloadFactory, AppCenter appCenter, ReviewsManager reviewsManager,
    AdsManager adsManager, FlagManager flagManager, StoreUtilsProxy storeUtilsProxy,
    AptoideAccountManager aptoideAccountManager, DownloadStateParser downloadStateParser,
    AppViewAnalytics appViewAnalytics, NotificationAnalytics notificationAnalytics,
    InstallAnalytics installAnalytics, Resources resources, WindowManager windowManager,
    @Named("marketName") String marketName, AppCoinsManager appCoinsManager,
    MoPubAdsManager moPubAdsManager, PromotionsManager promotionsManager,
    AppcMigrationManager appcMigrationManager,
    LocalNotificationSyncManager localNotificationSyncManager,
    AppcPromotionNotificationStringProvider appcPromotionNotificationStringProvider) {
  return new AppViewManager(appViewModelManager, installManager, downloadFactory, appCenter,
      reviewsManager, adsManager, flagManager, storeUtilsProxy, aptoideAccountManager,
      moPubAdsManager, downloadStateParser, appViewAnalytics, notificationAnalytics,
      installAnalytics, (Type.APPS_GROUP.getPerLineCount(resources, windowManager) * 6),
      Schedulers.io(), marketName, appCoinsManager, promotionsManager, appcMigrationManager,
      localNotificationSyncManager, appcPromotionNotificationStringProvider);
}
 
Example 2
Source File: UploaderTest.java    From RxUploader with Apache License 2.0 6 votes vote down vote up
@Test
public void testUploadFailedUnhandledException() throws Exception {
    final File file = getFile(TEST_FILE);
    final String jobId = "job-id";
    final Job job = Job.builder()
            .setId(jobId)
            .setStatus(Status.createQueued(jobId))
            .setMetadata(Collections.emptyMap())
            .setFilepath(file.getPath())
            .setMimeType("text/plain")
            .build();

    final UploadService service = mock(UploadService.class);
    when(service.upload(anyMap(), any(MultipartBody.Part.class)))
            .thenThrow(new RuntimeException(""));

    final Uploader uploader = new Uploader(service, Schedulers.io());
    final TestSubscriber<Status> ts = TestSubscriber.create();
    uploader.upload(job, file).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertError(RuntimeException.class);
    ts.assertNoValues();
}
 
Example 3
Source File: UploaderTest.java    From RxUploader with Apache License 2.0 6 votes vote down vote up
@Test
public void testUploadFileNotFoundException() throws Exception {
    final File file = new File("invalid");
    final String jobId = "job-id";
     final Job job = Job.builder()
            .setId(jobId)
            .setStatus(Status.createQueued(jobId))
            .setMetadata(Collections.emptyMap())
            .setFilepath("invalid")
            .setMimeType("text/plain")
            .build();

    final UploadService service = mock(UploadService.class);

    final Uploader uploader = new Uploader(service, Schedulers.io());
    final TestSubscriber<Status> ts = TestSubscriber.create();
    uploader.upload(job, file).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertError(FileNotFoundException.class);
    ts.assertNoValues();
}
 
Example 4
Source File: UserSearchActivity.java    From GithubUsersSearchApp with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_search);
    userSearchPresenter = new UserSearchPresenter(Injection.provideUserRepo(), Schedulers.io(),
            AndroidSchedulers.mainThread());
    userSearchPresenter.attachView(this);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    textViewErrorMessage = (TextView) findViewById(R.id.text_view_error_msg);
    recyclerViewUsers = (RecyclerView) findViewById(R.id.recycler_view_users);
    usersAdapter = new UsersAdapter(null, this);
    recyclerViewUsers.setAdapter(usersAdapter);

}
 
Example 5
Source File: FragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@FragmentScope @Provides AppsPresenter providesAppsPresenter(AppsManager appsManager,
    AptoideAccountManager aptoideAccountManager, AppsNavigator appsNavigator) {
  return new AppsPresenter(((AppsFragmentView) fragment), appsManager,
      AndroidSchedulers.mainThread(), Schedulers.io(), CrashReport.getInstance(),
      new PermissionManager(), ((PermissionService) fragment.getContext()), aptoideAccountManager,
      appsNavigator);
}
 
Example 6
Source File: CassandraLoadBalancerStore.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Inject
public CassandraLoadBalancerStore(CassandraStoreConfiguration configuration,
                                  @Named(LOAD_BALANCER_SANITIZER) EntitySanitizer entitySanitizer,
                                  @Named(LOAD_BALANCER_CASSANDRA_SESSION) Session session) {
    this.configuration = configuration;
    this.entitySanitizer = entitySanitizer;

    this.session = session;
    this.storeHelper = new CassStoreHelper(session, Schedulers.io());
    this.loadBalancerStateMap = new ConcurrentHashMap<>();
    this.jobToAssociatedLoadBalancersMap = new ConcurrentHashMap<>();

    this.selectAssociations = session.prepare(GET_ALL_ASSOCIATIONS).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
    this.insertAssociation = session.prepare(INSERT_ASSOCIATION).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
    this.deleteAssociation = session.prepare(DELETE_ASSOCIATION).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);

    this.selectTargetsForLoadBalancer = session.prepare(
            select(COLUMN_LOAD_BALANCER, COLUMN_IP_ADDRESS, COLUMN_TASK_ID, COLUMN_STATE)
                    .from(TABLE_LOAD_BALANCER_TARGETS)
                    .where(eq(COLUMN_LOAD_BALANCER, bindMarker()))
    ).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
    this.insertTarget = session.prepare(
            insertInto(TABLE_LOAD_BALANCER_TARGETS).values(
                    Arrays.asList(COLUMN_LOAD_BALANCER, COLUMN_IP_ADDRESS, COLUMN_TASK_ID, COLUMN_STATE),
                    Arrays.asList(bindMarker(), bindMarker(), bindMarker(), bindMarker())
            )
    ).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
    this.deleteDeregisteredTarget = session.prepare(
            delete().from(TABLE_LOAD_BALANCER_TARGETS)
                    .where(eq(COLUMN_LOAD_BALANCER, bindMarker()))
                    .and(eq(COLUMN_IP_ADDRESS, bindMarker()))
                    .onlyIf(eq(COLUMN_STATE, "DEREGISTERED"))
    ).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
}
 
Example 7
Source File: FragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@FragmentScope @Provides SearchResultPresenter provideSearchResultPresenter(
    SearchAnalytics searchAnalytics, SearchNavigator searchNavigator, SearchManager searchManager,
    TrendingManager trendingManager, SearchSuggestionManager searchSuggestionManager,
    BottomNavigationMapper bottomNavigationMapper) {
  return new SearchResultPresenter((SearchResultView) fragment, searchAnalytics, searchNavigator,
      CrashReport.getInstance(), AndroidSchedulers.mainThread(), searchManager, trendingManager,
      searchSuggestionManager, (AptoideBottomNavigator) fragment.getActivity(),
      bottomNavigationMapper, Schedulers.io());
}
 
Example 8
Source File: FragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@FragmentScope @Provides ImagePickerPresenter provideImagePickerPresenter(
    AccountPermissionProvider accountPermissionProvider, PhotoFileGenerator photoFileGenerator,
    ImageValidator imageValidator, UriToPathResolver uriToPathResolver,
    ImagePickerNavigator imagePickerNavigator) {
  return new ImagePickerPresenter((ImagePickerView) fragment, CrashReport.getInstance(),
      accountPermissionProvider, photoFileGenerator, imageValidator,
      AndroidSchedulers.mainThread(), uriToPathResolver, imagePickerNavigator,
      fragment.getActivity()
          .getContentResolver(), ImageLoader.with(fragment.getContext()), Schedulers.io());
}
 
Example 9
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Singleton @Provides AccountPersistence providesAccountPersistence(AccountManager accountManager,
    DatabaseStoreDataPersist databaseStoreDataPersist, AccountFactory accountFactory,
    AndroidAccountProvider androidAccountProvider,
    AuthenticationPersistence authenticationPersistence) {
  return new AndroidAccountManagerPersistence(accountManager, databaseStoreDataPersist,
      accountFactory, androidAccountProvider, authenticationPersistence, Schedulers.io());
}
 
Example 10
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Singleton @Provides WalletService providesWalletService(WalletService.ServiceV7 service) {
  return new WalletService(service, Schedulers.io());
}
 
Example 11
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Singleton @Provides DonationsService providesDonationsService(
    DonationsService.ServiceV8 service) {
  return new DonationsService(service, Schedulers.io());
}
 
Example 12
Source File: ArchiApplication.java    From archi with Apache License 2.0 4 votes vote down vote up
public Scheduler defaultSubscribeScheduler() {
    if (defaultSubscribeScheduler == null) {
        defaultSubscribeScheduler = Schedulers.io();
    }
    return defaultSubscribeScheduler;
}
 
Example 13
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Singleton @Provides ReactionsService providesReactionsService(
    ReactionsRemoteService.ServiceV8 reactionServiceV8) {
  return new ReactionsRemoteService(reactionServiceV8, Schedulers.io());
}
 
Example 14
Source File: ViewSubscriptions.java    From scoop with Apache License 2.0 4 votes vote down vote up
public ViewSubscriptions() {
    this.subscribeOnScheduler = Schedulers.io();
    this.observeOnScheduler = AndroidSchedulers.mainThread();
}
 
Example 15
Source File: DataModule.java    From materialistic with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton @Named(IO_THREAD)
public Scheduler provideIoScheduler() {
    return Schedulers.io();
}
 
Example 16
Source File: UploadInteractorImpl.java    From RxUploader with Apache License 2.0 4 votes vote down vote up
@NonNull
static UploadInteractor create(@NonNull Uploader uploader, @NonNull UploadDataStore dataStore,
        @NonNull UploadErrorAdapter errorAdapter) {
    return new UploadInteractorImpl(uploader, dataStore, errorAdapter, Schedulers.io());
}
 
Example 17
Source File: TestModelModule.java    From android-step-by-step with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
@Named(Const.IO_THREAD)
Scheduler provideSchedulerIO() {
    return Schedulers.io();
}
 
Example 18
Source File: Utils.java    From StudentAttendanceCheck with MIT License 4 votes vote down vote up
public Scheduler defaultSubscribeScheduler() {
    if (defaultSubscribeScheduler == null) {
        defaultSubscribeScheduler = Schedulers.io();
    }
    return defaultSubscribeScheduler;
}
 
Example 19
Source File: Rx.java    From mesos-rxjava with Apache License 2.0 2 votes vote down vote up
/**
 * This method will return the {@link Scheduler} that is used for all "io" workloads.
 * <p>
 * The idea of a io workload is one that is IO bound (disk, network, etc.).
 * @return The {@link Scheduler} that is to be used for all IO bound workloads.
 */
@NotNull
public static Scheduler io() {
    return Schedulers.io();
}
 
Example 20
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link QueueListenerFactory}. The default {@link Schedulers#io()} scheduler is used for listener
 * notification and I/O operations.
 *
 * @param disqueURI the DisqueURI
 * @param codec use this codec to encode/decode keys and values, must note be {@literal null}
 * @param queues the queue names
 * @param <K> Key type
 * @param <V> Value type
 * @return a new instance of {@link QueueListenerFactory}
 */
public static <K, V> QueueListenerFactory<K, V> create(DisqueURI disqueURI, RedisCodec<K, V> codec, K... queues) {
    return new QueueListenerFactory<K, V>(Schedulers.io(), disqueURI, codec, queues);
}