Search in sources :

Example 16 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionManager method createStudentDiscussion.

public static void createStudentDiscussion(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.createStudentDiscussion(adapter, params, canvasContext, newDiscussionHeader, attachment, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 17 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class FileSubmitObject method toAttachment.

/**
 * Used to get a basic attachment object for display.
 * @return A skin & bones attachment object
 */
@NonNull
public Attachment toAttachment() {
    Attachment attachment = new Attachment();
    attachment.setContentType(contentType);
    attachment.setDisplayName(name);
    attachment.setThumbnailUrl(fullPath);
    return attachment;
}
Also used : Attachment(com.instructure.canvasapi2.models.Attachment) NonNull(android.support.annotation.NonNull)

Example 18 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_hidden.

@Test
public void shouldShowToUser_hidden() {
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setHidden(true);
    assertEquals(false, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Test(org.junit.Test)

Example 19 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_locked_noUnlockDate.

@Test
public void shouldShowToUser_locked_noUnlockDate() {
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setLocked(true);
    attachment.setUnlockAt(null);
    assertEquals(false, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Test(org.junit.Test)

Example 20 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_locked_unlockDateNotPassed.

@Test
public void shouldShowToUser_locked_unlockDateNotPassed() {
    Date lockDate = new Date(System.currentTimeMillis() + MILLIS_PER_DAY);
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setUnlockAt(APIHelper.dateToString(lockDate));
    attachment.setLocked(true);
    assertEquals(false, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DiscussionAttachment (com.instructure.canvasapi2.models.DiscussionAttachment)9 Test (org.junit.Test)9 Attachment (com.instructure.canvasapi2.models.Attachment)5 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)4 RestParams (com.instructure.canvasapi2.builders.RestParams)4 Date (java.util.Date)4 Paint (android.graphics.Paint)3 Intent (android.content.Intent)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 AttachmentView (com.instructure.candroid.view.AttachmentView)2 RemoteFile (com.instructure.canvasapi2.models.RemoteFile)2 BeforePageView (com.instructure.canvasapi2.utils.pageview.BeforePageView)2 PageView (com.instructure.canvasapi2.utils.pageview.PageView)2 FileUploadNotification (com.instructure.pandautils.utils.FileUploadNotification)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 Dialog (android.app.Dialog)1