use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.
the class FileDetailsFragment method setUpCallback.
public void setUpCallback() {
fileFolderCanvasCallback = new StatusCallback<FileFolder>() {
@Override
public void onResponse(@NonNull Response<FileFolder> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (!apiCheck()) {
return;
}
// set up everything else now, we should have a file
file = response.body();
if (file != null) {
if (file.getLockInfo() != null) {
// file is locked
icon.setImageResource(R.drawable.vd_lock);
openButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
fileTypeTextView.setVisibility(View.INVISIBLE);
String lockedMessage = "";
if (file.getLockInfo().getLockedModuleName() != null) {
lockedMessage = "<p>" + String.format(getActivity().getString(R.string.lockedFileDesc), "<b>" + file.getLockInfo().getLockedModuleName() + "</b>") + "</p>";
}
if (file.getLockInfo().getModulePrerequisiteNames().size() > 0) {
// we only want to add this text if there are module completion requirements
lockedMessage += getActivity().getString(R.string.mustComplete) + "<br>";
// textViews can't display <ul> and <li> tags, so we need to use "• " instead
for (int i = 0; i < file.getLockInfo().getModulePrerequisiteNames().size(); i++) {
// "• "
lockedMessage += "• " + file.getLockInfo().getModulePrerequisiteNames().get(i);
}
lockedMessage += "<br><br>";
}
// check to see if there is an unlocked date
if (file.getLockInfo().getUnlockAt() != null && file.getLockInfo().getUnlockAt().after(new Date())) {
lockedMessage += DateHelper.createPrefixedDateTimeString(getContext(), getActivity().getString(R.string.unlockedAt) + "<br>• ", file.getLockInfo().getUnlockAt());
}
fileNameTextView.setText(StringUtilities.simplifyHTML(Html.fromHtml(lockedMessage)));
} else {
setupTextViews();
setupClickListeners();
// if the file has a thumbnail then show it. Make it a little bigger since the thumbnail size is pretty small
if (!TextUtils.isEmpty(file.getThumbnailUrl())) {
int dp = (int) ViewUtils.convertDipsToPixels(150, getActivity());
Picasso.with(getActivity()).load(file.getThumbnailUrl()).resize(dp, dp).centerInside().into(icon);
}
}
setPageViewReady();
}
toolbar.setTitle(title());
}
};
markReadCanvasCallback = new StatusCallback<ResponseBody>() {
@Override
public void onResponse(@NonNull Response<ResponseBody> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
}
};
}
use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.
the class LinkHeadersTest method toString_TestPrev.
@Test
public void toString_TestPrev() throws Exception {
LinkHeaders linkHeaders = generateLinkHeaders();
String testVal = linkHeaders.toString();
String[] testValArray = testVal.split("\n");
assertEquals("PREV: prevUrl", testValArray[0]);
}
use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.
the class LinkHeadersTest method toString_TestNext.
@Test
public void toString_TestNext() throws Exception {
LinkHeaders linkHeaders = generateLinkHeaders();
String testVal = linkHeaders.toString();
String[] testValArray = testVal.split("\n");
assertEquals("NEXT: nextUrl", testValArray[1]);
}
use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.
the class LinkHeadersTest method generateLinkHeaders.
private LinkHeaders generateLinkHeaders() {
LinkHeaders linkHeaders = new LinkHeaders();
linkHeaders.prevUrl = "prevUrl";
linkHeaders.nextUrl = "nextUrl";
linkHeaders.lastUrl = "lastUrl";
linkHeaders.firstUrl = "firstUrl";
return linkHeaders;
}
use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.
the class AssignmentManager_Test method getAssignmentGroupsWithAssignments.
public static void getAssignmentGroupsWithAssignments(long courseId, StatusCallback<List<AssignmentGroup>> callback) {
// TODO:
Response httpResponse = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
List<AssignmentGroup> assignments = new ArrayList<>();
retrofit2.Response<List<AssignmentGroup>> response = retrofit2.Response.success(assignments, httpResponse);
callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
Aggregations