From 96cba0cc2b6ac4f3ed900b8070c667605ab4d744 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Fri, 14 Jul 2017 17:09:44 -0400 Subject: [PATCH] Fixes timelines and notifications tabs fetching progressively further down when they are restarted. --- .../tusky/fragment/AccountListFragment.java | 5 +++++ .../tusky/fragment/NotificationsFragment.java | 7 +++++++ .../tusky/fragment/TimelineFragment.java | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java index 35713ae4..e37cbd57 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java @@ -134,6 +134,11 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi } recyclerView.setAdapter(adapter); + bottomLoading = false; + bottomFetches = 0; + topLoading = false; + topFetches = 0; + return rootView; } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 18aa1875..f98b34c6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -133,6 +133,13 @@ public class NotificationsFragment extends SFragment implements LocalBroadcastManager.getInstance(context.getApplicationContext()) .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null)); + topLoading = false; + topFetches = 0; + bottomLoading = false; + bottomFetches = 0; + bottomId = null; + topId = null; + return rootView; } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index b1415da7..87579446 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -100,7 +100,7 @@ public class TimelineFragment extends SFragment implements @Nullable private String bottomId; @Nullable - private String upToId; + private String topId; private PairedList statuses = new PairedList<>(ViewDataUtils.statusMapper()); @@ -159,6 +159,13 @@ public class TimelineFragment extends SFragment implements LocalBroadcastManager.getInstance(context.getApplicationContext()) .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind)); + topLoading = false; + topFetches = 0; + bottomLoading = false; + bottomFetches = 0; + bottomId = null; + topId = null; + return rootView; } @@ -240,7 +247,7 @@ public class TimelineFragment extends SFragment implements @Override public void onRefresh() { - sendFetchTimelineRequest(null, upToId, FetchEnd.TOP); + sendFetchTimelineRequest(null, topId, FetchEnd.TOP); } @Override @@ -597,7 +604,7 @@ public class TimelineFragment extends SFragment implements bottomId = fromId; } if (toId != null) { - upToId = toId; + topId = toId; } if (statuses.isEmpty()) { // This construction removes duplicates while preserving order. @@ -619,6 +626,9 @@ public class TimelineFragment extends SFragment implements } private void addItems(List newStatuses, @Nullable String fromId) { + if (ListUtils.isEmpty(newStatuses)) { + return; + } int end = statuses.size(); Status last = statuses.get(end - 1); if (last != null && !findStatus(newStatuses, last.id)) {