use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.
the class DiscussionAttachmentTest method shouldShowToUser_unlockedAndVisible.
@Test
public void shouldShowToUser_unlockedAndVisible() {
DiscussionAttachment attachment = new DiscussionAttachment();
attachment.setHidden(false);
attachment.setHiddenForUser(false);
attachment.setLocked(false);
attachment.setLockedForUser(false);
assertEquals(true, attachment.shouldShowToUser());
}
use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.
the class DiscussionAttachmentTest method shouldShowToUser_lockedForUser_unlockDateNotPassed.
@Test
public void shouldShowToUser_lockedForUser_unlockDateNotPassed() {
Date lockDate = new Date(System.currentTimeMillis() + MILLIS_PER_DAY);
DiscussionAttachment attachment = new DiscussionAttachment();
attachment.setUnlockAt(APIHelper.dateToString(lockDate));
attachment.setLockedForUser(true);
assertEquals(false, attachment.shouldShowToUser());
}
use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.
the class DiscussionManager method postToDiscussionTopic.
public static void postToDiscussionTopic(CanvasContext canvasContext, long topicId, String message, File attachment, String mimeType, StatusCallback<DiscussionEntry> callback) {
if (isTesting() || mTesting) {
// TODO:
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().build();
DiscussionAPI.postToDiscussionTopicWithAttachment(adapter, canvasContext, topicId, message, attachment, mimeType, callback, params);
}
}
use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.
the class DiscussionManager method createDiscussion.
public static void createDiscussion(CanvasContext canvasContext, DiscussionTopicHeader newDiscussionHeader, @Nullable MultipartBody.Part attachment, StatusCallback<DiscussionTopicHeader> callback) {
if (isTesting() || mTesting) {
// TODO
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
DiscussionAPI.createDiscussion(adapter, params, canvasContext, newDiscussionHeader, attachment, callback);
}
}
use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.
the class QuizQuestionsFragment method onFileUploadEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFileUploadEvent(FileUploadEvent event) {
// update the adapter item
event.get(new Function1<FileUploadNotification, Unit>() {
@Override
public Unit invoke(FileUploadNotification notification) {
final Intent statusIntent = notification.getIntent();
if (statusIntent != null) {
if (FileUploadService.QUIZ_UPLOAD_COMPLETE.equals(statusIntent.getAction())) {
if (statusIntent.hasExtra(Const.ATTACHMENT)) {
long questionId = statusIntent.getLongExtra(Const.QUIZ_ANSWER_ID, -1);
int position = statusIntent.getIntExtra(Const.POSITION, -1);
Attachment attachment = (Attachment) statusIntent.getExtras().get(Const.ATTACHMENT);
if (attachment != null && questionId != -1) {
quizQuestionAdapter.setFileUploadForQuiz(questionId, attachment, position);
}
}
} else if (FileUploadService.UPLOAD_ERROR.equals(statusIntent.getAction())) {
final Bundle bundle = statusIntent.getExtras();
if (bundle != null && bundle.containsKey(Const.MESSAGE)) {
String errorMessage = bundle.getString(Const.MESSAGE);
if (null == errorMessage || "".equals(errorMessage)) {
errorMessage = getString(R.string.errorUploadingFile);
}
showToast(errorMessage);
}
final long questionId = statusIntent.getLongExtra(Const.QUIZ_ANSWER_ID, -1);
if (questionId != -1) {
final int position = statusIntent.getIntExtra(Const.POSITION, -1);
quizQuestionAdapter.setIsLoading(questionId, false, position);
}
}
}
return null;
}
});
}
Aggregations