Loading app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java +6 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; Loading Loading @@ -64,8 +65,13 @@ public class NotificationsVM extends AndroidViewModel { super(application); } private static void sortDesc(List<Notification> notificationList) { Collections.sort(notificationList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void addFetchMoreNotifications(List<Notification> notificationList, List<Notification> timelineNotifications, TimelinesVM.TimelineParams timelineParams) throws DBException { if (notificationList != null && notificationList.size() > 0 && timelineNotifications != null && timelineNotifications.size() > 0) { sortDesc(notificationList); if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { //When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole if (notificationList.get(notificationList.size() - 1).id.compareToIgnoreCase(timelineNotifications.get(0).id) > 0) { Loading app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,10 @@ public class TimelinesVM extends AndroidViewModel { Collections.sort(statusList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void sortDescConv(List<Conversation> conversationList) { Collections.sort(conversationList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void addFetchMore(List<Status> statusList, List<Status> timelineStatuses, TimelineParams timelineParams) throws DBException { if (statusList != null && statusList.size() > 0 && timelineStatuses != null && timelineStatuses.size() > 0) { sortDesc(statusList); Loading @@ -121,6 +125,7 @@ public class TimelinesVM extends AndroidViewModel { private static void addFetchMoreConversation(List<Conversation> conversationList, List<Conversation> timelineConversations, TimelineParams timelineParams) throws DBException { if (conversationList != null && conversationList.size() > 0 && timelineConversations != null && timelineConversations.size() > 0) { sortDescConv(conversationList); if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { //When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole if (conversationList.get(conversationList.size() - 1).id.compareToIgnoreCase(timelineConversations.get(0).id) > 0) { Loading Loading
app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java +6 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; Loading Loading @@ -64,8 +65,13 @@ public class NotificationsVM extends AndroidViewModel { super(application); } private static void sortDesc(List<Notification> notificationList) { Collections.sort(notificationList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void addFetchMoreNotifications(List<Notification> notificationList, List<Notification> timelineNotifications, TimelinesVM.TimelineParams timelineParams) throws DBException { if (notificationList != null && notificationList.size() > 0 && timelineNotifications != null && timelineNotifications.size() > 0) { sortDesc(notificationList); if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { //When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole if (notificationList.get(notificationList.size() - 1).id.compareToIgnoreCase(timelineNotifications.get(0).id) > 0) { Loading
app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,10 @@ public class TimelinesVM extends AndroidViewModel { Collections.sort(statusList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void sortDescConv(List<Conversation> conversationList) { Collections.sort(conversationList, (obj1, obj2) -> obj2.id.compareToIgnoreCase(obj1.id)); } private static void addFetchMore(List<Status> statusList, List<Status> timelineStatuses, TimelineParams timelineParams) throws DBException { if (statusList != null && statusList.size() > 0 && timelineStatuses != null && timelineStatuses.size() > 0) { sortDesc(statusList); Loading @@ -121,6 +125,7 @@ public class TimelinesVM extends AndroidViewModel { private static void addFetchMoreConversation(List<Conversation> conversationList, List<Conversation> timelineConversations, TimelineParams timelineParams) throws DBException { if (conversationList != null && conversationList.size() > 0 && timelineConversations != null && timelineConversations.size() > 0) { sortDescConv(conversationList); if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { //When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole if (conversationList.get(conversationList.size() - 1).id.compareToIgnoreCase(timelineConversations.get(0).id) > 0) { Loading