From 44fefe9064991ad907a7bbc76a4330ed9bae54e1 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Fri, 25 Oct 2019 09:16:58 +0200 Subject: [PATCH] fix notification task, if it failed first Signed-off-by: tobiasKaminsky --- .../ui/activity/NotificationsActivity.java | 6 ++++-- .../ui/adapter/NotificationListAdapter.java | 17 ++++++++++++----- .../NotificationExecuteActionTask.java | 9 +++++++-- .../ui/notifications/NotificationsContract.java | 5 ++++- 4 files changed, 27 insertions(+), 10 deletions(-) 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 9fcab5777c..1fbe351e3e 100644 --- a/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java @@ -392,11 +392,13 @@ public class NotificationsActivity extends FileActivity implements Notifications } @Override - public void onActionCallback(boolean isSuccess, NotificationListAdapter.NotificationViewHolder holder) { + public void onActionCallback(boolean isSuccess, + Notification notification, + NotificationListAdapter.NotificationViewHolder holder) { if (isSuccess) { adapter.removeNotification(holder); } else { - adapter.setButtonEnabled(holder, true); + adapter.setButtons(holder, notification); DisplayUtils.showSnackMessage(this, getString(R.string.notification_action_failed)); } } diff --git a/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java index 065eda0048..ec3506524d 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java @@ -140,14 +140,24 @@ public class NotificationListAdapter extends RecyclerView.Adapter new DeleteNotificationTask(client, notification, holder, + notificationsActivity).execute()); + } + + public void setButtons(NotificationViewHolder holder, Notification notification) { // add action buttons holder.buttons.removeAllViews(); MaterialButton button; Resources resources = notificationsActivity.getResources(); - NotificationExecuteActionTask task = new NotificationExecuteActionTask(client, holder, notificationsActivity); + NotificationExecuteActionTask task = new NotificationExecuteActionTask(client, + holder, + notification, + notificationsActivity); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT); + ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(20, 0, 20, 0); for (Action action : notification.getActions()) { @@ -184,9 +194,6 @@ public class NotificationListAdapter extends RecyclerView.Adapter new DeleteNotificationTask(client, notification, holder, - notificationsActivity).execute()); } private SpannableStringBuilder makeSpecialPartsBold(Notification notification) { diff --git a/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java b/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java index 691f37db3d..bb921fe81a 100644 --- a/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java +++ b/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java @@ -6,6 +6,7 @@ import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.notifications.models.Action; +import com.owncloud.android.lib.resources.notifications.models.Notification; import com.owncloud.android.ui.activity.NotificationsActivity; import com.owncloud.android.ui.adapter.NotificationListAdapter; @@ -22,12 +23,16 @@ public class NotificationExecuteActionTask extends AsyncTask