Search in sources :

Example 21 with LinkHeaders

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

the class UserManager_Test method getObserveesForParent.

public static void getObserveesForParent(String airwolfDomain, RestBuilder adapter, RestParams params, String parentId, StatusCallback<List<Student>> callback) {
    adapter.setStatusCallback(callback);
    Response response = new Response.Builder().code(200).message("success").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "success".getBytes())).addHeader("content-type", "application/json").build();
    retrofit2.Response response1 = retrofit2.Response.success(response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.API);
}
Also used : Response(okhttp3.Response) ParentResponse(com.instructure.canvasapi2.models.ParentResponse) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 22 with LinkHeaders

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

the class APIHelperTest method parseLinkHeaderResponse.

@Test
public void parseLinkHeaderResponse() throws Exception {
    Headers headers = new Headers.Builder().add("link: <https://mobiledev.instructure.com/api/v1/courses/123456/discussion_topics.json?page2>; rel=\"next\"").build();
    LinkHeaders linkHeaders = APIHelper.parseLinkHeaderResponse(headers);
    assertEquals(linkHeaders.nextUrl, "courses/123456/discussion_topics.json?page2");
}
Also used : LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Headers(okhttp3.Headers) Test(org.junit.Test)

Example 23 with LinkHeaders

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

the class FileFolderManager method getFirstPageFilesRoot.

public static void getFirstPageFilesRoot(CanvasContext canvasContext, boolean forceNetwork, final StatusCallback<List<FileFolder>> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        final RestParams fileParams = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).build();
        FileFolderAPI.getRootFolderForContext(adapter, canvasContext, new StatusCallback<FileFolder>() {

            @Override
            public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                FileFolderAPI.getFirstPageFiles(adapter, response.body().getId(), callback, fileParams);
            }
        }, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) FileFolder(com.instructure.canvasapi2.models.FileFolder) UpdateFileFolder(com.instructure.canvasapi2.models.UpdateFileFolder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ApiType(com.instructure.canvasapi2.utils.ApiType) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 24 with LinkHeaders

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

the class FileFolderManager method getAllFoldersRoot.

public static void getAllFoldersRoot(CanvasContext canvasContext, final boolean forceNetwork, final StatusCallback<List<FileFolder>> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        FileFolderAPI.getRootFolderForContext(adapter, canvasContext, new StatusCallback<FileFolder>() {

            @Override
            public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                getAllFolders(response.body().getId(), forceNetwork, callback);
            }
        }, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) FileFolder(com.instructure.canvasapi2.models.FileFolder) UpdateFileFolder(com.instructure.canvasapi2.models.UpdateFileFolder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ApiType(com.instructure.canvasapi2.utils.ApiType) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 25 with LinkHeaders

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

the class CourseModuleProgressionFragment method setButtonListeners.

private void setButtonListeners() {
    prev.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            setupPrevModuleName(currentPos);
            setupPreviousModule(getModuleItemGroup(currentPos));
            if (currentPos >= 1) {
                viewPager.setCurrentItem(--currentPos);
            }
            updateBottomNavBarButtons();
        }
    });
    next.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            setupNextModuleName(currentPos);
            setupNextModule(getModuleItemGroup(currentPos));
            if (currentPos < (NUM_ITEMS - 1)) {
                viewPager.setCurrentItem(++currentPos);
            }
            updateBottomNavBarButtons();
        }
    });
    markDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (getModelObject() != null && getModelObject().getCompletionRequirement() != null) {
                if (getModelObject().getCompletionRequirement().isCompleted()) {
                    ModuleManager.markAsNotDone(getCanvasContext(), getModelObject().getModuleId(), getModelObject().getId(), new StatusCallback<ResponseBody>() {

                        @Override
                        public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                            markDoneCheckBox.setChecked(false);
                            getModelObject().getCompletionRequirement().setCompleted(false);
                            notifyOfItemChanged(getModelObject());
                        }
                    });
                } else {
                    ModuleManager.markAsDone(getCanvasContext(), getModelObject().getModuleId(), getModelObject().getId(), new StatusCallback<ResponseBody>() {

                        @Override
                        public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                            markDoneCheckBox.setChecked(true);
                            getModelObject().getCompletionRequirement().setCompleted(true);
                            notifyOfItemChanged(getModelObject());
                        }
                    });
                }
            }
        }
    });
}
Also used : Response(retrofit2.Response) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) NonNull(android.support.annotation.NonNull) ApiType(com.instructure.canvasapi2.utils.ApiType) OnClickListener(android.view.View.OnClickListener) StatusCallback(com.instructure.canvasapi2.StatusCallback) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)87 Response (okhttp3.Response)57 ArrayList (java.util.ArrayList)31 Request (okhttp3.Request)27 List (java.util.List)25 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)24 ApiType (com.instructure.canvasapi2.utils.ApiType)23 Response (retrofit2.Response)15 QuizSubmissionResponse (com.instructure.canvasapi2.models.QuizSubmissionResponse)13 QuizSubmissionQuestionResponse (com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse)12 ParentResponse (com.instructure.canvasapi2.models.ParentResponse)10 Conversation (com.instructure.canvasapi2.models.Conversation)9 NonNull (android.support.annotation.NonNull)8 GradingPeriodResponse (com.instructure.canvasapi2.models.GradingPeriodResponse)8 StatusCallback (com.instructure.canvasapi2.StatusCallback)7 FileFolder (com.instructure.canvasapi2.models.FileFolder)6 Submission (com.instructure.canvasapi2.models.Submission)6 Assignment (com.instructure.canvasapi2.models.Assignment)5 CourseNickname (com.instructure.canvasapi2.models.CourseNickname)5 ResponseBody (okhttp3.ResponseBody)5