From 13665a11cacbf4130c618475fa5ec05a7cd7a912 Mon Sep 17 00:00:00 2001 From: Grishka Date: Mon, 17 Jan 2022 21:55:15 +0300 Subject: [PATCH] Load more of the home timeline on scroll --- .../android/fragments/HomeTimelineFragment.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java index 385a1acb..b07ded75 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -34,11 +34,18 @@ public class HomeTimelineFragment extends StatusListFragment{ @Override protected void doLoadData(int offset, int count){ - new GetHomeTimeline(null, null, count) + String maxID; + if(offset>0 && !preloadedData.isEmpty()) + maxID=preloadedData.get(preloadedData.size()-1).id; + else if(offset>0 && !data.isEmpty()) + maxID=data.get(data.size()-1).id; + else + maxID=null; + new GetHomeTimeline(maxID, null, count) .setCallback(new SimpleCallback<>(this){ @Override public void onSuccess(List result){ - onDataLoaded(result, false); + onDataLoaded(result, !result.isEmpty()); } }) .exec(accountID);