refactor(follower): move remote check to own method

This commit is contained in:
FineFindus 2023-04-16 21:44:05 +02:00
parent c3c76126a3
commit ed75a62228
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
1 changed files with 8 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.HeaderPaginationList;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.Objects;
import java.util.stream.Collectors;
import me.grishka.appkit.api.Callback;
@ -27,8 +26,7 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
@Override
protected void doLoadData(int offset, int count){
if(GlobalUserPreferences.loadRemoteAccountFollowers && targetAccount.getDomain() != null){
if ((this instanceof FollowingListFragment || this instanceof FollowerListFragment) && targetAccount != null){
if (shouldLoadRemote()) {
UiUtils.lookupRemoteAccount(getContext(), targetAccount, accountID, null, account -> {
if(account != null){
loadRemoteFollower(offset, count, account);
@ -36,12 +34,18 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
loadFollower(offset, count);
}
});
}
} else {
loadFollower(offset, count);
}
}
private boolean shouldLoadRemote() {
if (!GlobalUserPreferences.loadRemoteAccountFollowers && (this instanceof FollowingListFragment || this instanceof FollowerListFragment)) {
return false;
}
return targetAccount != null && targetAccount.getDomain() != null;
}
void loadFollower(int offset, int count) {
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
.setCallback(new SimpleCallback<>(this){