use of com.meisolsson.githubsdk.service.activity.WatchingService 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.meisolsson.githubsdk.service.activity.WatchingService in project gh4a by slapperwan.
the class RepositoryActivity method toggleWatchingState.
private void toggleWatchingState() {
WatchingService service = ServiceFactory.get(WatchingService.class, false);
final Single<?> responseSingle;
if (mIsWatching) {
responseSingle = service.deleteRepositorySubscription(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure);
} else {
SubscriptionRequest request = SubscriptionRequest.builder().subscribed(true).build();
responseSingle = service.setRepositorySubscription(mRepoOwner, mRepoName, request).map(ApiHelpers::throwOnFailure);
}
responseSingle.compose(RxUtils::doInBackground).subscribe(result -> {
if (mIsWatching != null) {
mIsWatching = !mIsWatching;
}
supportInvalidateOptionsMenu();
}, error -> {
handleActionFailure("Updating repo watching state failed", error);
supportInvalidateOptionsMenu();
});
}
Aggregations