Search in sources :

Example 16 with ExhaustiveListCallback

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

the class AssignmentManager method getAllSubmissionsForAssignment.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Submission>> callback, @NonNull String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageSubmissions(nextUrl, adapter, forceNetwork, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageSubmissionsForAssignment(courseId, assignmentId, forceNetwork, adapter, depaginatedCallback);
    }
}
Also used : Submission(com.instructure.canvasapi2.models.Submission) 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 17 with ExhaustiveListCallback

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

the class AssignmentManager method getAllAssignments.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Assignment>> callback, @NonNull String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageAssignments(nextUrl, adapter, forceNetwork, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageAssignments(courseId, forceNetwork, adapter, depaginatedCallback);
    }
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) 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 18 with ExhaustiveListCallback

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

the class CalendarEventManager method getCalendarEventsExhaustive.

public static void getCalendarEventsExhaustive(final boolean allEvents, @NonNull final CalendarEventAPI.CalendarEventType type, @Nullable final String startDate, @Nullable final String endDate, @NonNull final List<String> canvasContexts, @NonNull StatusCallback<List<ScheduleItem>> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
        CalendarEventManager_Test.getCalendarEvents(callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
        StatusCallback<List<ScheduleItem>> exhaustiveCallback = new ExhaustiveListCallback<ScheduleItem>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<ScheduleItem>> callback, @NonNull String nextUrl, boolean isCached) {
                CalendarEventAPI.getCalendarEvents(allEvents, type, startDate, endDate, canvasContexts, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(exhaustiveCallback);
        CalendarEventAPI.getCalendarEvents(allEvents, type, startDate, endDate, canvasContexts, adapter, exhaustiveCallback, params);
    }
}
Also used : ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) RestParams(com.instructure.canvasapi2.builders.RestParams) 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 19 with ExhaustiveListCallback

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

the class CourseManager method getCourses.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Course>> callback, @NonNull String nextUrl, boolean isCached) {
                CourseAPI.getNextPageCourses(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        CourseAPI.getFirstPageCourses(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) ArrayList(java.util.ArrayList) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) Course(com.instructure.canvasapi2.models.Course) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 20 with ExhaustiveListCallback

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

the class CourseManager method getAllCourseStudents.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<User>> callback, @NonNull String nextUrl, boolean isCached) {
                CourseAPI.getNextPageCourseStudents(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        CourseAPI.getFirstPageCourseStudents(courseId, adapter, depaginatedCallback, params);
    }
}
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) ArrayList(java.util.ArrayList) 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