diff --git a/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java b/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java index fec393de5f..8834f58db3 100644 --- a/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java @@ -374,17 +374,21 @@ public class NotificationsActivity extends FileActivity implements Notifications } @Override - public void onRemovedNotification(boolean isSuccess, NotificationListAdapter.NotificationViewHolder holder) { - if (isSuccess) { - adapter.removeNotification(holder); - - if (adapter.getItemCount() == 0) { - setEmptyContent(noResultsHeadline, noResultsMessage); - swipeListRefreshLayout.setVisibility(View.GONE); - swipeEmptyListRefreshLayout.setVisibility(View.VISIBLE); - } - } else { + public void onRemovedNotification(boolean isSuccess) { + if (!isSuccess) { DisplayUtils.showSnackMessage(this, getString(R.string.remove_notification_failed)); + fetchAndSetData(); + } + } + + @Override + public void removeNotification(NotificationListAdapter.NotificationViewHolder holder) { + adapter.removeNotification(holder); + + if (adapter.getItemCount() == 0) { + setEmptyContent(noResultsHeadline, noResultsMessage); + swipeListRefreshLayout.setVisibility(View.GONE); + swipeEmptyListRefreshLayout.setVisibility(View.VISIBLE); } } diff --git a/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java b/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java index ca765cf4e2..bc813190bb 100644 --- a/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java +++ b/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java @@ -48,8 +48,12 @@ public class DeleteNotificationTask extends AsyncTask { } @Override - protected Boolean doInBackground(Action... actions) { + protected void onPreExecute() { + notificationsActivity.removeNotification(holder); + } + @Override + protected Boolean doInBackground(Action... actions) { RemoteOperationResult result = new DeleteNotificationRemoteOperation(notification.notificationId) .execute(client); @@ -58,6 +62,6 @@ public class DeleteNotificationTask extends AsyncTask { @Override protected void onPostExecute(Boolean success) { - notificationsActivity.onRemovedNotification(success, holder); + notificationsActivity.onRemovedNotification(success); } } diff --git a/src/main/java/com/owncloud/android/ui/notifications/NotificationsContract.java b/src/main/java/com/owncloud/android/ui/notifications/NotificationsContract.java index 80ef81439f..bebd4eb0ec 100644 --- a/src/main/java/com/owncloud/android/ui/notifications/NotificationsContract.java +++ b/src/main/java/com/owncloud/android/ui/notifications/NotificationsContract.java @@ -26,7 +26,9 @@ import com.owncloud.android.ui.adapter.NotificationListAdapter; public interface NotificationsContract { interface View { - void onRemovedNotification(boolean isSuccess, NotificationListAdapter.NotificationViewHolder holder); + void onRemovedNotification(boolean isSuccess); + + void removeNotification(NotificationListAdapter.NotificationViewHolder holder); void onRemovedAllNotifications(boolean isSuccess);