use of com.instructure.canvasapi2.utils.ExhaustiveCallback in project instructure-android by instructure.
the class CourseManager method getGroupsForCourse.
public static void getGroupsForCourse(long courseId, StatusCallback<List<Group>> callback, final boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
final RestBuilder adapter = new RestBuilder(callback);
StatusCallback<List<Group>> exhaustiveCallback = new ExhaustiveListCallback<Group>(callback) {
@Override
public void getNextPage(@NonNull StatusCallback<List<Group>> callback, @NonNull String nextUrl, boolean isCached) {
CourseAPI.getNextPageGroups(nextUrl, adapter, callback, params);
}
};
adapter.setStatusCallback(exhaustiveCallback);
CourseAPI.getFirstPageGroups(courseId, adapter, exhaustiveCallback, params);
}
}
use of com.instructure.canvasapi2.utils.ExhaustiveCallback 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);
}
}
use of com.instructure.canvasapi2.utils.ExhaustiveCallback in project instructure-android by instructure.
the class QuizManager method getAllQuizSubmissions.
public static void getAllQuizSubmissions(final CanvasContext canvasContext, final long quizId, final boolean forceNetwork, final StatusCallback<List<QuizSubmission>> callback) {
if (isTesting() || mTesting) {
QuizManager_Test.getAllQuizSubmissions(callback);
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
final ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission> paginatedCallback = new ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission>(callback) {
@Override
public void getNextPage(@NotNull StatusCallback<QuizSubmissionResponse> callback, @NotNull String nextUrl, boolean isCached) {
QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, callback, params);
}
@NotNull
@Override
public List<QuizSubmission> extractItems(QuizSubmissionResponse response) {
return response.getQuizSubmissions();
}
};
adapter.setStatusCallback(paginatedCallback);
QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, paginatedCallback, params);
}
}
Aggregations