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);
}
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");
}
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);
}
}
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);
}
}
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());
}
});
}
}
}
});
}
Aggregations