Created
December 5, 2021 19:47
-
-
Save bullheadandplato/55054b8be35f9e1fcf4dddc9df80fba7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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