From f5b10b516c06119e9343700f988bed15efb45bc5 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sun, 22 Oct 2023 05:14:21 +0300 Subject: [PATCH] Show all followers when creating a list --- .../account_list/AddNewListMembersFragment.java | 9 ++++++--- .../joinmastodon/android/model/HeaderPaginationList.java | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/AddNewListMembersFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/AddNewListMembersFragment.java index 755338a7..802318b9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/AddNewListMembersFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/AddNewListMembersFragment.java @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.res.TypedArray; import android.os.Bundle; import android.text.TextUtils; -import android.view.ViewGroup; import android.widget.Button; import org.joinmastodon.android.R; @@ -17,6 +16,7 @@ import org.joinmastodon.android.model.viewmodel.AccountViewModel; import org.joinmastodon.android.ui.viewholders.AccountViewHolder; import java.util.List; +import java.util.stream.Collectors; import me.grishka.appkit.api.SimpleCallback; import me.grishka.appkit.utils.V; @@ -24,6 +24,7 @@ import me.grishka.appkit.utils.V; @SuppressLint("ValidFragment") // This shouldn't be part of any saved states anyway public class AddNewListMembersFragment extends AccountSearchFragment{ private Listener listener; + private String maxID; public AddNewListMembersFragment(Listener listener){ this.listener=listener; @@ -38,11 +39,13 @@ public class AddNewListMembersFragment extends AccountSearchFragment{ @Override protected void doLoadData(int offset, int count){ if(TextUtils.isEmpty(currentQuery)){ - currentRequest=new GetAccountFollowing(AccountSessionManager.get(accountID).self.id, null, 10) + currentRequest=new GetAccountFollowing(AccountSessionManager.get(accountID).self.id, offset>0 ? maxID : null, count) .setCallback(new SimpleCallback<>(this){ @Override public void onSuccess(HeaderPaginationList result){ - AddNewListMembersFragment.this.onSuccess(result); + setEmptyText(""); + onDataLoaded(result.stream().map(a->new AccountViewModel(a, accountID)).collect(Collectors.toList()), result.nextPageUri!=null); + maxID=result.getNextPageMaxID(); } }) .exec(accountID); diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/HeaderPaginationList.java b/mastodon/src/main/java/org/joinmastodon/android/model/HeaderPaginationList.java index 10390e31..37c56e93 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/HeaderPaginationList.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/HeaderPaginationList.java @@ -21,4 +21,10 @@ public class HeaderPaginationList extends ArrayList{ public HeaderPaginationList(@NonNull Collection c){ super(c); } + + public String getNextPageMaxID(){ + if(nextPageUri==null) + return null; + return nextPageUri.getQueryParameter("max_id"); + } }