Search in sources :

Example 31 with CanvasContext

use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.

the class QuizManager method getQuizSubmissionTime.

public static void getQuizSubmissionTime(CanvasContext canvasContext, QuizSubmission quizSubmission, boolean forceNetwork, final StatusCallback<QuizSubmissionTime> callback) {
    final RestBuilder adapter = new RestBuilder(callback);
    final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
    QuizAPI.getQuizSubmissionTime(canvasContext, quizSubmission.getQuizId(), quizSubmission.getId(), adapter, params, callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 32 with CanvasContext

use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.

the class SubmissionManager method postMediaSubmissionComment.

public static void postMediaSubmissionComment(CanvasContext canvasContext, long assignmentId, long studentId, String mediaId, String mediaType, boolean isGroupComment, StatusCallback<Submission> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).build();
        SubmissionAPI.postMediaSubmissionComment(canvasContext.getId(), assignmentId, studentId, mediaId, mediaType, isGroupComment, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 33 with CanvasContext

use of com.instructure.canvasapi2.models.CanvasContext 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 34 with CanvasContext

use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.

the class UserManager method getUserForContextId.

public static void getUserForContextId(CanvasContext canvasContext, Long userId, StatusCallback<User> callback, boolean forceNetwork) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).withForceReadFromNetwork(forceNetwork).build();
        UserAPI.getUserForContextId(adapter, params, canvasContext, userId, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 35 with CanvasContext

use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.

the class CanvasContextSpinnerAdapter method newAdapterInstance.

public static CanvasContextSpinnerAdapter newAdapterInstance(Context context, List<Course> courses, List<Group> groups) {
    ArrayList<CanvasContext> canvasContexts = new ArrayList<>();
    if (!courses.isEmpty()) {
        Course courseSeparator = new Course();
        courseSeparator.setName(context.getString(R.string.courses));
        courseSeparator.setId(COURSE_SEPARATOR);
        canvasContexts.add(courseSeparator);
        canvasContexts.addAll(courses);
    }
    if (!groups.isEmpty()) {
        Course groupSeparator = new Course();
        groupSeparator.setName(context.getString(R.string.groups));
        groupSeparator.setId(GROUP_SEPARATOR);
        canvasContexts.add(groupSeparator);
        canvasContexts.addAll(groups);
    }
    return new CanvasContextSpinnerAdapter(context, canvasContexts);
}
Also used : ArrayList(java.util.ArrayList) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) Course(com.instructure.canvasapi2.models.Course)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)60 RestParams (com.instructure.canvasapi2.builders.RestParams)55 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)19 StatusCallback (com.instructure.canvasapi2.StatusCallback)8 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)7 List (java.util.List)7 ApiType (com.instructure.canvasapi2.utils.ApiType)6 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)6 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)5 FileFolder (com.instructure.canvasapi2.models.FileFolder)5 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)5 NonNull (android.support.annotation.NonNull)4 View (android.view.View)4 TextView (android.widget.TextView)4 UpdateFileFolder (com.instructure.canvasapi2.models.UpdateFileFolder)4 Bundle (android.os.Bundle)3 ImageView (android.widget.ImageView)3 BindView (butterknife.BindView)3 Course (com.instructure.canvasapi2.models.Course)3