refactor: move request to their own methods
This commit is contained in:
@@ -27,6 +27,34 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
|
|||||||
if ((this instanceof FollowingListFragment || this instanceof FollowerListFragment) && targetAccount != null){
|
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 && account.getDomain() != null){
|
if(account != null && account.getDomain() != null){
|
||||||
|
loadRemoteFollower(offset, count, account);
|
||||||
|
} else {
|
||||||
|
loadFollower(offset, count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadFollower(offset, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadFollower(int offset, int count) {
|
||||||
|
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
||||||
|
.setCallback(new SimpleCallback<>(this){
|
||||||
|
@Override
|
||||||
|
public void onSuccess(HeaderPaginationList<Account> result){
|
||||||
|
if(result.nextPageUri!=null)
|
||||||
|
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
||||||
|
else
|
||||||
|
nextMaxID=null;
|
||||||
|
if (getActivity() == null) return;
|
||||||
|
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec(accountID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadRemoteFollower(int offset, int count, Account account) {
|
||||||
currentRequest=onCreateRemoteRequest(account.id, offset==0 ? null : nextMaxID, count)
|
currentRequest=onCreateRemoteRequest(account.id, offset==0 ? null : nextMaxID, count)
|
||||||
.setCallback(new SimpleCallback<>(this){
|
.setCallback(new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
@@ -46,38 +74,6 @@ public abstract class PaginatedAccountListFragment extends BaseAccountListFragme
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.execNoAuth(targetAccount.getDomain());
|
.execNoAuth(targetAccount.getDomain());
|
||||||
} else {
|
|
||||||
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
|
||||||
.setCallback(new SimpleCallback<>(this){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Account> result){
|
|
||||||
if(result.nextPageUri!=null)
|
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
|
||||||
else
|
|
||||||
nextMaxID=null;
|
|
||||||
if (getActivity() == null) return;
|
|
||||||
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentRequest=onCreateRequest(offset==0 ? null : nextMaxID, count)
|
|
||||||
.setCallback(new SimpleCallback<>(this){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Account> result){
|
|
||||||
if(result.nextPageUri!=null)
|
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
|
||||||
else
|
|
||||||
nextMaxID=null;
|
|
||||||
if (getActivity() == null) return;
|
|
||||||
onDataLoaded(result.stream().map(AccountItem::new).collect(Collectors.toList()), nextMaxID!=null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user