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


Java Schedulers类代码示例

本文整理汇总了Java中io.reactivex.schedulers.Schedulers的典型用法代码示例。如果您正苦于以下问题:Java Schedulers类的具体用法?Java Schedulers怎么用?Java Schedulers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Schedulers类属于io.reactivex.schedulers包,在下文中一共展示了Schedulers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applySchedules

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public static <T> FlowableTransformer<T, T> applySchedules(final IView view) {
    return new FlowableTransformer<T, T>() {
        @Override
        public Publisher<T> apply(Flowable<T> upstream) {
            return upstream.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Subscription>() {
                        @Override
                        public void accept(Subscription subscription) throws Exception {
                            view.showLoading();
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnTerminate(new Action() {
                        @Override
                        public void run() throws Exception {
                            view.hideLoading();
                        }
                    });
        }
    };
}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:23,代码来源:RxUtils.java

示例2: loadRequest

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public void loadRequest(int id) {
    checkViewAttached();
    getMvpView().showLoadingProgress(true);

    mSubscription.add(mDataManager.getRequest(id)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribeWith(new DisposableSingleObserver<Request>() {
                @Override
                public void onSuccess(Request request) {
                    getMvpView().showRequest(request);
                    getMvpView().showLoadingProgress(false);
                }

                @Override
                public void onError(Throwable error) {
                    getMvpView().showError(error.getMessage());
                    getMvpView().showLoadingProgress(false);
                }
            }));
}
 
开发者ID:stuxo,项目名称:REDAndroid,代码行数:22,代码来源:RequestPresenter.java

示例3: getMoviesList

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
@MainThread
@NonNull
LiveData<Response<List<Country>>> getMoviesList() {
    if (countriesLiveData == null) {
        countriesLiveData = new MutableLiveData<>();
        countriesRepository.getCountries()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnSubscribe(disposable -> loadingLiveData.setValue(true))
                .doAfterTerminate(() -> loadingLiveData.setValue(false))
                .subscribe(
                        countries1 -> countriesLiveData.setValue(Response.success(countries1)),
                        throwable -> countriesLiveData.setValue(Response.error(throwable))
                );
    }
    return countriesLiveData;
}
 
开发者ID:graviton57,项目名称:NewAndroidArchitecture,代码行数:18,代码来源:CountriesViewModel.java

示例4: restart

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
private void restart() {
    mCompositeDisposable.add(FFMService.restart()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doFinally(new Action() {
                @Override
                public void run() throws Exception {
                    findPreference("restart_webqq").setEnabled(true);
                }
            })
            .subscribe(new Consumer<FFMResult>() {
                @Override
                public void accept(FFMResult ffmResult) throws Exception {
                    Toast.makeText(getContext(), "Succeed.", Toast.LENGTH_SHORT).show();
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    Toast.makeText(getContext(), "Network error:\n" + throwable.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }));
}
 
开发者ID:RikkaApps,项目名称:FCM-for-Mojo,代码行数:23,代码来源:ServerSettingsFragment.java

示例5: choose

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
private void choose(TrackPath source, SingleTrackAlbumBuilder result) {
	final Single<Boolean> dbOp = Single.fromCallable(() -> {
		new TrackPathNormalizer(source).removeTags();
		db.addAlbum(result.build());
		updateHits(result);
		return true;
	}).observeOn(Schedulers.io());

	Single.fromCallable(() -> {
		return askForRemoval(source);
	}).zipWith(dbOp, (one, another) -> one && another)
	.subscribe(toDelete -> {
		if(toDelete) {
			Files.delete(source.getPath());
		}
	});
}
 
开发者ID:JPDSousa,项目名称:rookit-core,代码行数:18,代码来源:ImportAction.java

示例6: load

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public static void load() {
    RxHelper.safeObservable(Observable.fromCallable(() -> {
        try {
            InputStream stream = App.getInstance().getAssets().open(PATH);
            List<Emoji> emojis = EmojiLoader.loadEmojis(stream);
            ALL_EMOJIS = emojis;
            for (Emoji emoji : emojis) {
                for (String tag : emoji.getTags()) {
                    if (EMOJIS_BY_TAG.get(tag) == null) {
                        EMOJIS_BY_TAG.put(tag, new HashSet<>());
                    }
                    EMOJIS_BY_TAG.get(tag).add(emoji);
                }
                for (String alias : emoji.getAliases()) {
                    EMOJIS_BY_ALIAS.put(alias, emoji);
                }
            }
            EMOJI_TRIE = new EmojiTrie(emojis);
            stream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    })).subscribeOn(Schedulers.io()).subscribe();
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:26,代码来源:EmojiManager.java

示例7: searchData

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
private void searchData(String tag) {
    mHintText.setText("");
    mTagLayout.setVisibility(View.GONE);
    mProgressBar.setVisibility(View.VISIBLE);
    mSearchTag = tag;
    Observable<GetDataBean> observable = mSearchApi.searchTagData(mSearchTag);
    observable
            .filter(new Predicate<GetDataBean>() {
                @Override
                public boolean test(@NonNull GetDataBean getDataBean) throws Exception {
                    return getDataBean != null;
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(mObserver);
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:18,代码来源:SearchActivity.java

示例8: fetchData

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
private void fetchData() {
  getView().showProgressBar();
  getView().hideListView();
  getCompositeDisposable().add(getDataProvider().getPermissionGroups(false)
      .subscribeOn(Schedulers.computation())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribeWith(new DisposableSingleObserver<ArrayList<PermissionGroupDetails>>() {
        @Override
        public void onSuccess(ArrayList<PermissionGroupDetails> permissionGroupDetails) {
          getView().hideProgressBar();
          getView().showListView();
          permissionList = permissionGroupDetails;
          getView().notifyListAdapter();
        }

        @Override public void onError(Throwable e) {

        }
      }));
}
 
开发者ID:Arjun-sna,项目名称:android-permission-checker-app,代码行数:21,代码来源:PermissionGroupPresenterImpl.java

示例9: getUserProfile

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
private void getUserProfile() {
    mUserService.me()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(u -> {
                        mUserName.setText(u.getUsername());
                        mAvatarView.setAvatarOfUser(u);
                        mReputation.setText(u.getReputation());
                        mPost.setText(u.getPostcount());
                        mFollowing.setText(String.valueOf(u.getFollowingCount()));
                        mFollower.setText(String.valueOf(u.getFollowerCount()));
                        mLoginTime.setText(DateTimeFormatter.format(Long.parseLong(u.getLastonline())));
                        mRegTime.setText(DateTimeFormatter.format(Long.parseLong(u.getJoindate())));
                        mProfileViews.setText(u.getProfileviews());
                        mEmail.setText(u.getEmail());
                        GlideApp.with(UserProfileActivity.this)
                                .load(NodeBBService.url(u.getCoverUrl()))
                                .into(new SimpleTarget<Drawable>() {
                                    @Override
                                    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
                                        mHeaderView.setBackground(resource);
                                    }
                                });
                    });
}
 
开发者ID:hyb1996,项目名称:NodeET,代码行数:26,代码来源:UserProfileActivity.java

示例10: login

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public void login(String username, String password) {
    checkViewAttached();
    getMvpView().showLoadingProgress(true);

    mSubscription.add(mDataManager.login(username, password, 1)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribeWith(new DisposableSingleObserver<Boolean>() {
                @Override
                public void onSuccess(Boolean success) {
                    if (success) {
                        loginWithCookie();
                    } else {
                        getMvpView().showError("Login Failed");
                    }
                }

                @Override
                public void onError(Throwable error) {
                    getMvpView().showError(error.getMessage());
                    getMvpView().showLoadingProgress(false);
                }
            }));
}
 
开发者ID:stuxo,项目名称:REDAndroid,代码行数:25,代码来源:LoginPresenter.java

示例11: login

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public Single<Boolean> login(String username, String password, int stayLoggedIn) {
    return mApiService.login(username, password, stayLoggedIn)
            .subscribeOn(Schedulers.io())
            .flatMap(new Function<Response<ResponseBody>, Single<? extends Boolean>>() {
                @Override public Single<? extends Boolean> apply(
                    Response<ResponseBody> responseBodyResponse) {
                    String header = responseBodyResponse.raw().header("Set-Cookie", "");
                    if (header.contains("session")
                        && !header.contains("deleted")
                        && !header.contains("redirect")) {
                        return Single.just(true);
                    } else {
                        getPreferencesHelper().clearCookies();
                        return Single.just(false);
                    }
                }
            });
}
 
开发者ID:stuxo,项目名称:REDAndroid,代码行数:19,代码来源:DataManager.java

示例12: TranscodingServiceImpl

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
@Inject
TranscodingServiceImpl(ExternalProcessService externalProcessService,
                       TranscoderSettings transcoderSettings,
                       MediaScanSettings mediaScanSettings,
                       OutputParser parser) {
    this.externalProcessService = externalProcessService;
    this.transcoderSettings = transcoderSettings;
    this.mediaScanSettings = mediaScanSettings;

    this.parser = parser;

    this.publisher = PublishSubject.create().toSerialized();

    publisher.ofType(TranscodeTask.class)
             .skipWhile(o -> isActive())
             .observeOn(Schedulers.computation())
             .subscribeOn(Schedulers.io())
             .subscribe(this::prepareTranscode);
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:20,代码来源:TranscodingServiceImpl.java

示例13: loadBookList

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void loadBookList(BookListType type, String tag, int start, int limited) {
    Disposable refreshDispo = getBookListSingle(type, tag, start, limited)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    (beans)-> {
                        mView.finishLoading(beans);
                    }
                    ,
                    (e) ->{
                        mView.showLoadError();
                        LogUtils.e(e);
                    }
            );
    addDisposable(refreshDispo);
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:18,代码来源:BookListPresenter.java

示例14: writeFile

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
public static Single<WriteFileEvent> writeFile(final String content, final Path path, final boolean overwrite) {
    Preconditions.checkNotNull(content);
    Preconditions.checkNotNull(path);
    return Single.fromCallable(() -> {
        if (path.getParent() != null && !Files.exists(path.getParent())) {
            Files.createDirectories(path.getParent());
        }
        if (overwrite) {
            Files.deleteIfExists(path);
        } else if (Files.isDirectory(path)) {
            throw new IOException("There is already a directory at " + path);
        } else if (Files.exists(path)) {
            throw new IOException("There is already a file at " + path);
        }
        final ByteSink sink = MoreFiles.asByteSink(path);
        sink.write(content.getBytes());
        return WriteFileEvent.of(path);
    }).subscribeOn(Schedulers.io());
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:20,代码来源:CommonTasks.java

示例15: fetchMoreData

import io.reactivex.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void fetchMoreData() {
    if (TextUtils.isEmpty(getNextPageUrl()))
        return;

    view.showLoadingMore(true);
    repository.listShotLikesForUserOfNextPage(getNextPageUrl())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .compose(((LifecycleProvider<FragmentEvent>) view).bindUntilEvent(FragmentEvent.DESTROY_VIEW))
            .subscribe(listResponse -> {
                view.showLoadingMore(false);
                view.showMoreData(generateEpoxyModels(listResponse.body()));
                setNextPageUrl(new PageLinks(listResponse).getNext());
            }, throwable -> {
                view.showLoadingMore(false);
                view.showSnackbar(throwable.getMessage());
                throwable.printStackTrace();
            });
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:21,代码来源:ShotLikeListPresenter.java


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