diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java index eb1f2a8df..c08d8c1ac 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java @@ -889,9 +889,9 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On notificationsListAdapter.notifyDataSetChanged(); Toast.makeText(context,R.string.delete_notification,Toast.LENGTH_LONG).show(); }else{ + int size = notifications.size(); notifications.clear(); - notifications = new ArrayList<>(); - notificationsListAdapter.notifyDataSetChanged(); + notificationsListAdapter.notifyItemRangeRemoved(0, size); Toast.makeText(context,R.string.delete_notification_all,Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java index 730106230..352b12298 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java @@ -183,6 +183,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve swiped = false; return; } + int previousPosition = notifications.size(); max_id = apiResponse.getMax_id(); List notifications = apiResponse.getNotifications(); @@ -272,8 +273,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve return; if( notification != null){ //Makes sure the notifications is not already displayed - if( notification.getId() != null && notifications != null && notifications.size() > 0 && notifications.get(0)!= null - && Long.parseLong(notification.getId()) > Long.parseLong(notifications.get(0).getId())) { + if( lastReadNotifications == null || Long.parseLong(notification.getId()) > Long.parseLong(lastReadNotifications)) { //Update the id of the last notification retrieved MainActivity.lastNotificationId = notification.getId(); notifications.add(0, notification); @@ -293,6 +293,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve @Override public void onRetrieveMissingNotifications(List notifications) { + if( notifications != null && notifications.size() > 0) { for (int i = notifications.size()-1 ; i >= 0 ; i--) { if (this.notifications.size() == 0 ||