use of com.instructure.canvasapi2.models.FileFolder 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.models.FileFolder in project instructure-android by instructure.
the class FileFolderTest method compareTo_FileAndFolder.
@Test
public void compareTo_FileAndFolder() {
FileFolder folder = new FileFolder();
folder.setFullName("fileFolder");
FileFolder file = new FileFolder();
file.setDisplayName("fileFolder");
assertEquals(1, file.compareTo(folder));
}
use of com.instructure.canvasapi2.models.FileFolder in project instructure-android by instructure.
the class FileFolderTest method compareTo_FileAndFile.
@Test
public void compareTo_FileAndFile() {
FileFolder file1 = new FileFolder();
file1.setFullName("File 1");
FileFolder file2 = new FileFolder();
file2.setFullName("File 2");
assertEquals(-1, file1.compareTo(file2));
}
use of com.instructure.canvasapi2.models.FileFolder in project instructure-android by instructure.
the class FileFolderTest method compareTo_FolderAndFolder.
@Test
public void compareTo_FolderAndFolder() {
FileFolder folder1 = new FileFolder();
folder1.setFullName("Folder 1");
FileFolder folder2 = new FileFolder();
folder2.setFullName("Folder 2");
assertEquals(-1, folder1.compareTo(folder2));
}
use of com.instructure.canvasapi2.models.FileFolder in project instructure-android by instructure.
the class FileFolderTest method compareTo_FolderAndFolderReversed.
@Test
public void compareTo_FolderAndFolderReversed() {
FileFolder folder1 = new FileFolder();
folder1.setFullName("Folder 1");
FileFolder folder2 = new FileFolder();
folder2.setFullName("Folder 2");
assertEquals(1, folder2.compareTo(folder1));
}
Aggregations