Skip to content

Instantly share code, notes, and snippets.

@bullheadandplato
Created December 5, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullheadandplato/55054b8be35f9e1fcf4dddc9df80fba7 to your computer and use it in GitHub Desktop.
Save bullheadandplato/55054b8be35f9e1fcf4dddc9df80fba7 to your computer and use it in GitHub Desktop.
private void openImage(long imageId) {
if (disposable != null) {
disposable.dispose();
}
disposable = commonService.getImageById(imageId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(error -> Single.error(ApiExceptionUtil.generalException(error)))
.subscribe(v -> {
hideProgress();
context().ifPresent(c -> FullscreenImageViewerActivity.Companion.show(c, v.images()));
}, error -> {
hideProgress();
handleError(error);
});
}
private void openVideo(long videoId) {
if (disposable != null) {
disposable.dispose();
}
disposable = commonService.getVideoById(videoId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(error -> Single.error(ApiExceptionUtil.generalException(error)))
.subscribe(v -> {
hideProgress();
context().ifPresent(c -> YoutubePlayerActivity.show(c, v));
}, error -> {
hideProgress();
handleError(error);
});
}
private void openCategory(long id){
if (disposable != null) {
disposable.dispose();
}
disposable = commonService.getCategoryById(id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(error -> Single.error(ApiExceptionUtil.generalException(error)))
.subscribe(cat -> {
hideProgress();
context().ifPresent(c -> DetailActivity.show(c, cat));
}, error -> {
hideProgress();
activity().ifPresent(a -> DialogUtil.showOk(a, error.getLocalizedMessage()));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment