Search in sources :

Example 1 with NotificationReadRequest

use of com.meisolsson.githubsdk.model.request.NotificationReadRequest 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);
    }
}
Also used : NotificationReadRequest(com.meisolsson.githubsdk.model.request.NotificationReadRequest) NotificationService(com.meisolsson.githubsdk.service.activity.NotificationService) Date(java.util.Date)

Example 2 with NotificationReadRequest

use of com.meisolsson.githubsdk.model.request.NotificationReadRequest 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));
}
Also used : Response(retrofit2.Response) NotificationReadRequest(com.meisolsson.githubsdk.model.request.NotificationReadRequest) ApiHelpers(com.gh4a.utils.ApiHelpers) NotificationService(com.meisolsson.githubsdk.service.activity.NotificationService)

Aggregations

NotificationReadRequest (com.meisolsson.githubsdk.model.request.NotificationReadRequest)2 NotificationService (com.meisolsson.githubsdk.service.activity.NotificationService)2 ApiHelpers (com.gh4a.utils.ApiHelpers)1 Date (java.util.Date)1 Response (retrofit2.Response)1