Search in sources :

Example 21 with ExhaustiveListCallback

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

the class DiscussionManager method getAllPinnedDiscussions.

public static void getAllPinnedDiscussions(@NonNull CanvasContext canvasContext, final boolean forceNetwork, StatusCallback<List<DiscussionTopicHeader>> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(false).build();
        StatusCallback<List<DiscussionTopicHeader>> depaginatedCallback = new ExhaustiveListCallback<DiscussionTopicHeader>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<List<DiscussionTopicHeader>> callback, @NotNull String nextUrl, boolean isCached) {
                DiscussionAPI.getNextPage(nextUrl, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        DiscussionAPI.getFirstPagePinnedDiscussions(canvasContext, adapter, depaginatedCallback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with ExhaustiveListCallback

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

the class DiscussionManager method getStudentGroupDiscussionTopicHeaderExhaustive.

public static void getStudentGroupDiscussionTopicHeaderExhaustive(@NonNull CanvasContext canvasContext, final long rootTopicId, final boolean forceNetwork, StatusCallback<List<DiscussionTopicHeader>> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        StatusCallback<List<DiscussionTopicHeader>> depaginatedCallback = new ExhaustiveListCallback<DiscussionTopicHeader>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<List<DiscussionTopicHeader>> callback, @NotNull String nextUrl, boolean isCached) {
                DiscussionAPI.getNextPage(nextUrl, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        DiscussionAPI.getFirstPageStudentGroupDiscussionTopicHeader(canvasContext, rootTopicId, depaginatedCallback, adapter, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with ExhaustiveListCallback

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

the class EnrollmentManager method getAllEnrollmentsForCourse.

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

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

Example 24 with ExhaustiveListCallback

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

the class FileFolderManager method getAllFiles.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<FileFolder>> callback, @NonNull String nextUrl, boolean isCached) {
                FileFolderAPI.getNextPageFilesFolder(adapter, nextUrl, callback, params);
            }
        };
        FileFolderAPI.getFirstPageFiles(adapter, folderId, depaginatedCallback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) FileFolder(com.instructure.canvasapi2.models.FileFolder) UpdateFileFolder(com.instructure.canvasapi2.models.UpdateFileFolder) 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 25 with ExhaustiveListCallback

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

the class FileFolderManager method getAllFolders.

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

            @Override
            public void getNextPage(@NonNull StatusCallback<List<FileFolder>> callback, @NonNull String nextUrl, boolean isCached) {
                FileFolderAPI.getNextPageFilesFolder(adapter, nextUrl, callback, params);
            }
        };
        FileFolderAPI.getFirstPageFolders(adapter, folderId, depaginatedCallback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) FileFolder(com.instructure.canvasapi2.models.FileFolder) UpdateFileFolder(com.instructure.canvasapi2.models.UpdateFileFolder) 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