Fixes issue #207 - New fixes

This commit is contained in:
stom79 2017-12-28 14:03:08 +01:00
parent 452fdc2a58
commit a98d9d9453
2 changed files with 5 additions and 4 deletions

View File

@ -889,9 +889,9 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
notificationsListAdapter.notifyDataSetChanged(); notificationsListAdapter.notifyDataSetChanged();
Toast.makeText(context,R.string.delete_notification,Toast.LENGTH_LONG).show(); Toast.makeText(context,R.string.delete_notification,Toast.LENGTH_LONG).show();
}else{ }else{
int size = notifications.size();
notifications.clear(); notifications.clear();
notifications = new ArrayList<>(); notificationsListAdapter.notifyItemRangeRemoved(0, size);
notificationsListAdapter.notifyDataSetChanged();
Toast.makeText(context,R.string.delete_notification_all,Toast.LENGTH_LONG).show(); Toast.makeText(context,R.string.delete_notification_all,Toast.LENGTH_LONG).show();
} }

View File

@ -183,6 +183,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
swiped = false; swiped = false;
return; return;
} }
int previousPosition = notifications.size(); int previousPosition = notifications.size();
max_id = apiResponse.getMax_id(); max_id = apiResponse.getMax_id();
List<Notification> notifications = apiResponse.getNotifications(); List<Notification> notifications = apiResponse.getNotifications();
@ -272,8 +273,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
return; return;
if( notification != null){ if( notification != null){
//Makes sure the notifications is not already displayed //Makes sure the notifications is not already displayed
if( notification.getId() != null && notifications != null && notifications.size() > 0 && notifications.get(0)!= null if( lastReadNotifications == null || Long.parseLong(notification.getId()) > Long.parseLong(lastReadNotifications)) {
&& Long.parseLong(notification.getId()) > Long.parseLong(notifications.get(0).getId())) {
//Update the id of the last notification retrieved //Update the id of the last notification retrieved
MainActivity.lastNotificationId = notification.getId(); MainActivity.lastNotificationId = notification.getId();
notifications.add(0, notification); notifications.add(0, notification);
@ -293,6 +293,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
@Override @Override
public void onRetrieveMissingNotifications(List<Notification> notifications) { public void onRetrieveMissingNotifications(List<Notification> notifications) {
if( notifications != null && notifications.size() > 0) { if( notifications != null && notifications.size() > 0) {
for (int i = notifications.size()-1 ; i >= 0 ; i--) { for (int i = notifications.size()-1 ; i >= 0 ; i--) {
if (this.notifications.size() == 0 || if (this.notifications.size() == 0 ||