use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.
the class UserManager method getAllPeopleList.
public static void getAllPeopleList(final CanvasContext canvasContext, StatusCallback<List<User>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
// We don't want the canvas context on the paginated params
final RestParams paginatedParams = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
final RestBuilder adapter = new RestBuilder(callback);
StatusCallback<List<User>> depaginatedCallback = new ExhaustiveListCallback<User>(callback) {
@Override
public void getNextPage(@NonNull StatusCallback<List<User>> callback, @NonNull String nextUrl, boolean isCached) {
UserAPI.getPeopleList(adapter, paginatedParams, canvasContext.getId(), callback);
}
};
adapter.setStatusCallback(depaginatedCallback);
UserAPI.getPeopleList(adapter, params, canvasContext.getId(), depaginatedCallback);
}
}
Aggregations