refactor(follower): move remote check to own method
This commit is contained in:
parent
c3c76126a3
commit
ed75a62228
|
@ -9,7 +9,6 @@ import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
import org.joinmastodon.android.model.HeaderPaginationList;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import me.grishka.appkit.api.Callback;
|
import me.grishka.appkit.api.Callback;
|
||||||
|
@ -27,8 +26,7 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
if(GlobalUserPreferences.loadRemoteAccountFollowers && targetAccount.getDomain() != null){
|
if (shouldLoadRemote()) {
|
||||||
if ((this instanceof FollowingListFragment || this instanceof FollowerListFragment) && targetAccount != null){
|
|
||||||
UiUtils.lookupRemoteAccount(getContext(), targetAccount, accountID, null, account -> {
|
UiUtils.lookupRemoteAccount(getContext(), targetAccount, accountID, null, account -> {
|
||||||
if(account != null){
|
if(account != null){
|
||||||
loadRemoteFollower(offset, count, account);
|
loadRemoteFollower(offset, count, account);
|
||||||
|
@ -36,12 +34,18 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
|
||||||
loadFollower(offset, count);
|
loadFollower(offset, count);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
loadFollower(offset, count);
|
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) {
|
void loadFollower(int offset, int count) {
|
||||||
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
||||||
.setCallback(new SimpleCallback<>(this){
|
.setCallback(new SimpleCallback<>(this){
|
||||||
|
|
Loading…
Reference in New Issue