Search in sources :

Example 1 with SubscriptionRequest

use of com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest in project gh4a by slapperwan.

the class NotificationListFragment method unsubscribe.

@Override
public void unsubscribe(NotificationHolder notificationHolder) {
    NotificationThread notification = notificationHolder.notification;
    NotificationService service = ServiceFactory.get(NotificationService.class, false);
    SubscriptionRequest request = SubscriptionRequest.builder().subscribed(false).build();
    service.setNotificationThreadSubscription(notification.id(), request).map(ApiHelpers::throwOnFailure).compose(RxUtils::doInBackground).subscribe(result -> handleMarkAsRead(null, notification));
}
Also used : SubscriptionRequest(com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest) NotificationThread(com.meisolsson.githubsdk.model.NotificationThread) ApiHelpers(com.gh4a.utils.ApiHelpers) NotificationService(com.meisolsson.githubsdk.service.activity.NotificationService)

Example 2 with SubscriptionRequest

use of com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest 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();
    });
}
Also used : SubscriptionRequest(com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest) WatchingService(com.meisolsson.githubsdk.service.activity.WatchingService)

Aggregations

SubscriptionRequest (com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest)2 ApiHelpers (com.gh4a.utils.ApiHelpers)1 NotificationThread (com.meisolsson.githubsdk.model.NotificationThread)1 NotificationService (com.meisolsson.githubsdk.service.activity.NotificationService)1 WatchingService (com.meisolsson.githubsdk.service.activity.WatchingService)1