use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class RepositoryActivity method loadStarringState.
private void loadStarringState(boolean force) {
if (!Gh4Application.get().isAuthorized()) {
return;
}
StarringService service = ServiceFactory.get(StarringService.class, force);
service.checkIfRepositoryIsStarred(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure).map(result -> true).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, false)).compose(makeLoaderSingle(ID_LOADER_STARRING, force)).subscribe(result -> {
mIsStarring = result;
supportInvalidateOptionsMenu();
}, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class RepositoryActivity method loadWatchingState.
private void loadWatchingState(boolean force) {
if (!Gh4Application.get().isAuthorized()) {
return;
}
WatchingService service = ServiceFactory.get(WatchingService.class, force);
service.getRepositorySubscription(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure).map(Subscription::subscribed).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, false)).compose(makeLoaderSingle(ID_LOADER_WATCHING, force)).subscribe(result -> {
mIsWatching = result;
supportInvalidateOptionsMenu();
}, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class GistActivity method loadStarredState.
private void loadStarredState(boolean force) {
GistService service = ServiceFactory.get(GistService.class, force);
service.checkIfGistIsStarred(mGistId).map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(makeLoaderSingle(ID_LOADER_STARRED, force)).subscribe(result -> {
mIsStarred = result;
supportInvalidateOptionsMenu();
}, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class GistActivity method updateStarringState.
private void updateStarringState() {
GistService service = ServiceFactory.get(GistService.class, false);
Single<Response<Void>> responseSingle = mIsStarred ? service.unstarGist(mGistId) : service.starGist(mGistId);
responseSingle.map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils::doInBackground).subscribe(result -> {
mIsStarred = !mIsStarred;
supportInvalidateOptionsMenu();
}, error -> {
handleActionFailure("Updating gist starring state failed", error);
supportInvalidateOptionsMenu();
});
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class GistActivity method loadGist.
private void loadGist(boolean force) {
GistService service = ServiceFactory.get(GistService.class, force);
service.getGist(mGistId).map(ApiHelpers::throwOnFailure).compose(makeLoaderSingle(ID_LOADER_GIST, force)).subscribe(result -> {
fillData(result);
setContentShown(true);
supportInvalidateOptionsMenu();
}, this::handleLoadFailure);
}
Aggregations