use of com.meisolsson.githubsdk.service.activity.NotificationService 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));
}
use of com.meisolsson.githubsdk.service.activity.NotificationService in project gh4a by slapperwan.
the class HomeActivity method loadNotificationIndicator.
private void loadNotificationIndicator(boolean force) {
NotificationService service = ServiceFactory.get(NotificationService.class, force, null, null, 1);
HashMap<String, Object> options = new HashMap<>();
options.put("all", false);
options.put("participating", false);
service.getNotifications(options, 1).map(ApiHelpers::throwOnFailure).map(result -> !result.items().isEmpty()).compose(makeLoaderSingle(ID_LOADER_NOTIFICATIONS_INDICATOR, force)).subscribe(this::setNotificationsIndicatorVisible, this::handleLoadFailure);
}
use of com.meisolsson.githubsdk.service.activity.NotificationService in project gh4a by slapperwan.
the class SingleFactory method getNotifications.
public static Single<NotificationListLoadResult> getNotifications(boolean all, boolean participating, boolean bypassCache) {
final NotificationService service = ServiceFactory.get(NotificationService.class, bypassCache);
final Map<String, Object> options = new HashMap<>();
options.put("all", all);
options.put("participating", participating);
return ApiHelpers.PageIterator.toSingle(page -> service.getNotifications(options, page)).map(SingleFactory::notificationsToResult);
}
use of com.meisolsson.githubsdk.service.activity.NotificationService in project gh4a by slapperwan.
the class NotificationHandlingService method markNotificationAsRead.
private void markNotificationAsRead(String repoOwner, String repoName, long timestamp) {
NotificationService service = ServiceFactory.get(NotificationService.class, false);
NotificationReadRequest request = NotificationReadRequest.builder().lastReadAt(new Date(timestamp)).build();
try {
service.markAllRepositoryNotificationsRead(repoOwner, repoName, request).blockingGet();
} catch (Exception e) {
Log.w(Gh4Application.LOG_TAG, "Could not mark repo \"" + repoOwner + "/" + repoName + "\" as read", e);
}
}
use of com.meisolsson.githubsdk.service.activity.NotificationService in project gh4a by slapperwan.
the class NotificationListFragment method markAsRead.
private void markAsRead(Repository repository, NotificationThread notification) {
NotificationService service = ServiceFactory.get(NotificationService.class, false);
final Single<Response<Void>> responseSingle;
if (notification != null) {
responseSingle = service.markNotificationRead(notification.id());
} else {
NotificationReadRequest request = NotificationReadRequest.builder().lastReadAt(mNotificationsLoadTime).build();
if (repository != null) {
responseSingle = service.markAllRepositoryNotificationsRead(repository.owner().login(), repository.name(), request);
} else {
responseSingle = service.markAllNotificationsRead(request);
}
}
responseSingle.map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils::doInBackground).subscribe(result -> handleMarkAsRead(repository, notification), error -> handleActionFailure("Mark notifications as read failed", error));
}
Aggregations