Search in sources :

Example 11 with ExhaustiveListCallback

use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.

the class RecipientManager method searchAllRecipientsNoSyntheticContexts.

/**
 * Synthetic contexts == sections and groups, so this will return only actual users, not groups or sections
 *
 * @param forceNetwork
 * @param searchQuery
 * @param context
 * @param callback
 */
public static void searchAllRecipientsNoSyntheticContexts(final boolean forceNetwork, String searchQuery, String context, StatusCallback<List<Recipient>> callback) {
    if (isTesting() || mTesting) {
    // TODO...
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<Recipient>> depaginatedCallback = new ExhaustiveListCallback<Recipient>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Recipient>> callback, @NonNull String nextUrl, boolean isCached) {
                RecipientAPI.getNextPageRecipients(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        RecipientAPI.getFirstPageRecipientsNoSyntheticContexts(forceNetwork, searchQuery, context, adapter, depaginatedCallback);
    }
}
Also used : NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) Recipient(com.instructure.canvasapi2.models.Recipient) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 12 with ExhaustiveListCallback

use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.

the class UserManager method getAllEnrollmentsPeopleList.

public static void getAllEnrollmentsPeopleList(final CanvasContext canvasContext, StatusCallback<List<User>> callback, final 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.getAllPeopleList(adapter, paginatedParams, canvasContext.getId(), callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        UserAPI.getAllPeopleList(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)

Example 13 with ExhaustiveListCallback

use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.

the class AccountNotificationManager method getAllAccountNotifications.

public static void getAllAccountNotifications(StatusCallback<List<AccountNotification>> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        StatusCallback<List<AccountNotification>> depaginatedCallback = new ExhaustiveListCallback<AccountNotification>(callback) {

            @Override
            public void getNextPage(StatusCallback<List<AccountNotification>> callback, String nextUrl, boolean isCached) {
                AccountNotificationAPI.getAccountNotifications(adapter, params, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AccountNotificationAPI.getAccountNotifications(adapter, params, depaginatedCallback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) AccountNotification(com.instructure.canvasapi2.models.AccountNotification)

Example 14 with ExhaustiveListCallback

use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.

the class AssignmentManager method getAllGradeableStudentsForAssignment.

public static void getAllGradeableStudentsForAssignment(long courseId, long assignmentId, final boolean forceNetwork, StatusCallback<List<GradeableStudent>> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAllGradeableStudentsForAssignment(courseId, assignmentId, callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<GradeableStudent>> depaginatedCallback = new ExhaustiveListCallback<GradeableStudent>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<List<GradeableStudent>> callback, @NotNull String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageGradeableStudents(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageGradeableStudentsForAssignment(courseId, assignmentId, adapter, depaginatedCallback);
    }
}
Also used : GradeableStudent(com.instructure.canvasapi2.models.GradeableStudent) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with ExhaustiveListCallback

use of com.instructure.canvasapi2.utils.ExhaustiveListCallback in project instructure-android by instructure.

the class AssignmentManager method getAssignmentGroupsWithAssignmentsForGradingPeriod.

public static void getAssignmentGroupsWithAssignmentsForGradingPeriod(long courseId, final long gradingPeriodId, boolean scopeToStudent, final boolean forceNetwork, StatusCallback<List<AssignmentGroup>> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAssignmentGroupsWithAssignmentsForGradingPeriod(courseId, callback, gradingPeriodId);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        StatusCallback<List<AssignmentGroup>> depaginatedCallback = new ExhaustiveListCallback<AssignmentGroup>(callback) {

            @Override
            public void getNextPage(StatusCallback<List<AssignmentGroup>> callback, String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageAssignmentGroupsWithAssignmentsForGradingPeriod(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageAssignmentGroupsWithAssignmentsForGradingPeriod(courseId, gradingPeriodId, scopeToStudent, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) AssignmentGroup(com.instructure.canvasapi2.models.AssignmentGroup) 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