소스 검색

As async, it can happen that list already changed

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 6 년 전
부모
커밋
f91a9725d7
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) {
             if (success) {
                 int position = holder.getAdapterPosition();
-                notificationsList.remove(position);
-                notifyItemRemoved(position);
+
+                if (position > 0 && position < notificationsList.size()) {
+                    notificationsList.remove(position);
+                    notifyItemRemoved(position);
+                }
             } else {
                 setButtonEnabled(holder, true);
                 DisplayUtils.showSnackMessage(notificationsActivity, "Failed to execute action!");