From 70e8756974ea3cdb2f01b20aa3cd25b0dd549480 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 25 Dec 2022 18:07:25 +0100 Subject: [PATCH] Fix issue #672 - Support pagination for search / trending --- .../android/client/endpoints/MastodonTimelinesService.java | 4 +++- .../ui/fragment/timeline/FragmentMastodonAccount.java | 4 ++++ .../ui/fragment/timeline/FragmentMastodonTimeline.java | 7 ++++++- .../app/fedilab/android/viewmodel/mastodon/SearchVM.java | 1 - 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java b/app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java index 7fdf0744..619bc92a 100644 --- a/app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java +++ b/app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java @@ -62,7 +62,9 @@ public interface MastodonTimelinesService { @GET("trends/tags") - Call> getTagTrends(@Header("Authorization") String token); + Call> getTagTrends(@Header("Authorization") String token, + @Query("offset") Integer offset, + @Query("limit") Integer limit); //Public Tags timelines @GET("timelines/tag/{hashtag}") diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonAccount.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonAccount.java index 7c7289b7..b71ef24c 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonAccount.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonAccount.java @@ -86,6 +86,10 @@ public class FragmentMastodonAccount extends Fragment { accountsVM = new ViewModelProvider(FragmentMastodonAccount.this).get(viewModelKey, AccountsVM.class); max_id = null; offset = 0; + if (search != null) { + binding.swipeContainer.setRefreshing(false); + binding.swipeContainer.setEnabled(false); + } router(true); } diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index 0256564a..443d8d19 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -266,7 +266,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } public void scrollToTop() { - if (binding != null) { + if (binding != null && search == null) { binding.swipeContainer.setRefreshing(true); flagLoading = false; route(DIRECTION.SCROLL_TOP, true); @@ -290,6 +290,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. if (max_id == null && !isViewInitialized && rememberPosition) { max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null); } + if (search != null) { + binding.swipeContainer.setRefreshing(false); + binding.swipeContainer.setEnabled(false); + } //Only fragment in main view pager should not have the view initialized //AND Only the first fragment will initialize its view flagLoading = false; @@ -507,6 +511,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } return; } + binding.loader.setVisibility(View.GONE); binding.noAction.setVisibility(View.GONE); binding.swipeContainer.setRefreshing(false); diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java index 23bb6d0b..5e259a50 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/SearchVM.java @@ -123,7 +123,6 @@ public class SearchVM extends AndroidViewModel { if (results.hashtags == null) { results.hashtags = new ArrayList<>(); } - results.pagination.offset = finalLimit; } } } catch (Exception e) {