浏览代码

Merge pull request #3225 from nextcloud/notificationOutOfBounds

As async, it can happen that list already changed
Andy Scherzinger 6 年之前
父节点
当前提交
8ba7257628
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java

+ 5 - 2
src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java

@@ -234,8 +234,11 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
         protected void onPostExecute(Boolean success) {
         protected void onPostExecute(Boolean success) {
             if (success) {
             if (success) {
                 int position = holder.getAdapterPosition();
                 int position = holder.getAdapterPosition();
-                notificationsList.remove(position);
-                notifyItemRemoved(position);
+
+                if (position >= 0 && position < notificationsList.size()) {
+                    notificationsList.remove(position);
+                    notifyItemRemoved(position);
+                }
             } else {
             } else {
                 setButtonEnabled(holder, true);
                 setButtonEnabled(holder, true);
                 DisplayUtils.showSnackMessage(notificationsActivity, "Failed to execute action!");
                 DisplayUtils.showSnackMessage(notificationsActivity, "Failed to execute action!");