Search in sources :

Example 26 with ExhaustiveListCallback

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

the class GroupManager method getAllGroupsForCourse.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Group>> callback, @NonNull String nextUrl, boolean isCached) {
                GroupAPI.getNextPageGroups(nextUrl, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        GroupAPI.getGroupsForCourse(adapter, depaginatedCallback, params, courseId);
    }
}
Also used : Group(com.instructure.canvasapi2.models.Group) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 27 with ExhaustiveListCallback

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

the class QuizManager method getAllQuizzes.

public static void getAllQuizzes(long courseId, final boolean forceNetwork, StatusCallback<List<Quiz>> callback) {
    if (isTesting() || mTesting) {
        QuizManager_Test.getQuizesQuestions(callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<Quiz>> depaginatedCallback = new ExhaustiveListCallback<Quiz>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Quiz>> callback, @NonNull String nextUrl, boolean isCached) {
                QuizAPI.getNextPageQuizzes(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        QuizAPI.getFirstPageQuizzes(courseId, forceNetwork, adapter, depaginatedCallback);
    }
}
Also used : Quiz(com.instructure.canvasapi2.models.Quiz) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 28 with ExhaustiveListCallback

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

the class RecipientManager method searchAllRecipients.

public static void searchAllRecipients(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.getFirstPageRecipients(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 29 with ExhaustiveListCallback

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

the class SectionManager method getAllSectionsForCourse.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Section>> callback, @NonNull String nextUrl, boolean isCached) {
                SectionAPI.getNextPageSections(nextUrl, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        SectionAPI.getFirstSectionsForCourse(courseId, adapter, depaginatedCallback, params);
    }
}
Also used : 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) Section(com.instructure.canvasapi2.models.Section)

Example 30 with ExhaustiveListCallback

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

the class SubmissionManager method getAllStudentSubmissionsForCourse.

public static void getAllStudentSubmissionsForCourse(final long studentId, final long courseId, @NonNull StatusCallback<List<Submission>> callback, boolean forceNetwork) {
    if (isTesting() | mTesting) {
        SubmissionManager_Test.getStudentSubmissionsForCourse(studentId, courseId, callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
        StatusCallback<List<Submission>> depaginatedCallback = new ExhaustiveListCallback<Submission>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Submission>> callback, @NonNull String nextUrl, boolean isCached) {
                SubmissionAPI.getStudentSubmissionsForCourse(courseId, studentId, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        SubmissionAPI.getStudentSubmissionsForCourse(courseId, studentId, adapter, callback, params);
    }
}
Also used : Submission(com.instructure.canvasapi2.models.Submission) 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