Search in sources :

Example 31 with ExhaustiveListCallback

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);
    }
}
Also used : User(com.instructure.canvasapi2.models.User) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Aggregations

StatusCallback (com.instructure.canvasapi2.StatusCallback)31 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)31 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)31 List (java.util.List)31 RestParams (com.instructure.canvasapi2.builders.RestParams)25 NonNull (android.support.annotation.NonNull)23 ArrayList (java.util.ArrayList)12 Group (com.instructure.canvasapi2.models.Group)5 NotNull (org.jetbrains.annotations.NotNull)5 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)4 Enrollment (com.instructure.canvasapi2.models.Enrollment)3 User (com.instructure.canvasapi2.models.User)3 AssignmentGroup (com.instructure.canvasapi2.models.AssignmentGroup)2 Course (com.instructure.canvasapi2.models.Course)2 FileFolder (com.instructure.canvasapi2.models.FileFolder)2 Recipient (com.instructure.canvasapi2.models.Recipient)2 Submission (com.instructure.canvasapi2.models.Submission)2 UpdateFileFolder (com.instructure.canvasapi2.models.UpdateFileFolder)2 AccountNotification (com.instructure.canvasapi2.models.AccountNotification)1 Assignment (com.instructure.canvasapi2.models.Assignment)1