Search in sources :

Example 21 with Attachment

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

the class DiscussionAttachmentTest method shouldShowToUser_locked_unlockDatePassed.

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

Example 22 with Attachment

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

the class DiscussionEntryHTMLHelper method getContentHTML.

private static String getContentHTML(DiscussionEntry discussionEntry, String message) {
    if (message == null || message.equals("null")) {
        return "";
    } else {
        StringBuilder html = new StringBuilder();
        html.append("<div class=\"width\">");
        html.append(message);
        for (RemoteFile attachment : discussionEntry.getAttachments()) {
            if (!attachment.isHiddenForUser() && !discussionEntry.isDeleted()) {
                html.append("<div class=\"nowrap\">");
                html.append(String.format("<img class=\"attachment_img\" src=\"" + ATTACHMENT_ICON + "\" /> <a class=\"attachment_link\" href=\"%s\">%s</a>", attachment.getUrl(), attachment.getDisplayName()));
                html.append("</div>");
            }
        }
        html.append("</div>");
        return html.toString();
    }
}
Also used : RemoteFile(com.instructure.canvasapi2.models.RemoteFile)

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