Fixes timelines and notifications tabs fetching progressively further down when they are restarted.

main
Vavassor 7 years ago
parent 93d71c30fd
commit d1a3e943d2
  1. 5
      app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java
  2. 7
      app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java
  3. 16
      app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java

@ -134,6 +134,11 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi
} }
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
bottomLoading = false;
bottomFetches = 0;
topLoading = false;
topFetches = 0;
return rootView; return rootView;
} }

@ -133,6 +133,13 @@ public class NotificationsFragment extends SFragment implements
LocalBroadcastManager.getInstance(context.getApplicationContext()) LocalBroadcastManager.getInstance(context.getApplicationContext())
.registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null)); .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null));
topLoading = false;
topFetches = 0;
bottomLoading = false;
bottomFetches = 0;
bottomId = null;
topId = null;
return rootView; return rootView;
} }

@ -100,7 +100,7 @@ public class TimelineFragment extends SFragment implements
@Nullable @Nullable
private String bottomId; private String bottomId;
@Nullable @Nullable
private String upToId; private String topId;
private PairedList<Status, StatusViewData> statuses = private PairedList<Status, StatusViewData> statuses =
new PairedList<>(ViewDataUtils.statusMapper()); new PairedList<>(ViewDataUtils.statusMapper());
@ -159,6 +159,13 @@ public class TimelineFragment extends SFragment implements
LocalBroadcastManager.getInstance(context.getApplicationContext()) LocalBroadcastManager.getInstance(context.getApplicationContext())
.registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind)); .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind));
topLoading = false;
topFetches = 0;
bottomLoading = false;
bottomFetches = 0;
bottomId = null;
topId = null;
return rootView; return rootView;
} }
@ -240,7 +247,7 @@ public class TimelineFragment extends SFragment implements
@Override @Override
public void onRefresh() { public void onRefresh() {
sendFetchTimelineRequest(null, upToId, FetchEnd.TOP); sendFetchTimelineRequest(null, topId, FetchEnd.TOP);
} }
@Override @Override
@ -597,7 +604,7 @@ public class TimelineFragment extends SFragment implements
bottomId = fromId; bottomId = fromId;
} }
if (toId != null) { if (toId != null) {
upToId = toId; topId = toId;
} }
if (statuses.isEmpty()) { if (statuses.isEmpty()) {
// This construction removes duplicates while preserving order. // This construction removes duplicates while preserving order.
@ -619,6 +626,9 @@ public class TimelineFragment extends SFragment implements
} }
private void addItems(List<Status> newStatuses, @Nullable String fromId) { private void addItems(List<Status> newStatuses, @Nullable String fromId) {
if (ListUtils.isEmpty(newStatuses)) {
return;
}
int end = statuses.size(); int end = statuses.size();
Status last = statuses.get(end - 1); Status last = statuses.get(end - 1);
if (last != null && !findStatus(newStatuses, last.id)) { if (last != null && !findStatus(newStatuses, last.id)) {

Loading…
Cancel
Save