Search in sources :

Example 1 with MediaComment

use of com.instructure.canvasapi.model.MediaComment in project instructure-android by instructure.

the class MediaCommentUnitTest method testMediaComment.

@Test
public void testMediaComment() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    MediaComment mediaComment = gson.fromJson(mediaCommentJSON, MediaComment.class);
    assertNotNull(mediaComment);
    assertNotNull(mediaComment.getMediaType());
    assertNotNull(mediaComment.getMediaId());
    assertNotNull(mediaComment.getMimeType());
    assertNotNull(mediaComment.getUrl());
}
Also used : MediaComment(com.instructure.canvasapi.model.MediaComment) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 2 with MediaComment

use of com.instructure.canvasapi.model.MediaComment in project instructure-android by instructure.

the class SubmissionCommentRowFactory method buildRowView.

// ///////////////////////////////////////////////////////////////
// Row Factories
// ///////////////////////////////////////////////////////////////
public static View buildRowView(View convertView, LayoutInflater inflater, SubmissionComment comment, final Activity context, boolean isUser) {
    final ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        if (isUser) {
            convertView = inflater.inflate(R.layout.list_item_user_comment, null);
        } else {
            convertView = inflater.inflate(R.layout.list_item_other_comment, null);
        }
        holder.avatar = (CircleImageView) convertView.findViewById(R.id.avatar);
        holder.comment = (HelveticaTextView) convertView.findViewById(R.id.commentText);
        holder.date = (HelveticaTextView) convertView.findViewById(R.id.date);
        holder.attachmentsHolder = (LinearLayout) convertView.findViewById(R.id.attachmentsHolder);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    String avatarURL = comment.getAuthor().getAvatarImageUrl();
    if (avatarURL != null) {
        Picasso.with(context).load(avatarURL).into(holder.avatar, new Callback() {

            @Override
            public void onSuccess() {
            }

            @Override
            public void onError() {
                holder.avatar.setImageResource(R.drawable.ic_cv_user);
            }
        });
    }
    holder.comment.setText(comment.getComment());
    holder.date.setText(DateHelpers.getShortDate(context, comment.getComparisonDate()) + context.getString(R.string.at) + DateHelpers.getFormattedTime(context, comment.getComparisonDate()) + ", " + comment.getAuthor().getDisplayName());
    holder.attachmentsHolder.removeAllViews();
    List<Attachment> attachments = comment.getAttachments();
    if (attachments != null) {
        for (final Attachment attachment : attachments) {
            if (attachment.getThumbnailUrl() != null && attachment.getUrl() != null) {
                ImageView imageView = getAttachmentImageView(context);
                imageView.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        ((SubmissionListener) context).onMediaOpened(attachment.getMimeType(), attachment.getUrl(), attachment.getFilename());
                    }
                });
                Picasso.with(context).load(attachment.getThumbnailUrl()).into(imageView);
                holder.attachmentsHolder.addView(imageView);
            }
        }
    }
    final MediaComment mediaComment = comment.getMedia_comment();
    if (mediaComment != null) {
        final String url = APIHelpers.getFullDomain(context) + "/media_objects/" + mediaComment.getMediaId() + "/thumbnail?height=140&width=140";
        ImageView imageView = getAttachmentImageView(context);
        imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ((SubmissionListener) context).onMediaOpened(mediaComment.getMimeType(), mediaComment.getUrl(), mediaComment.getFileName());
            }
        });
        Picasso.with(context).load(url).into(imageView);
        holder.attachmentsHolder.addView(imageView);
    }
    return convertView;
}
Also used : MediaComment(com.instructure.canvasapi.model.MediaComment) Callback(com.squareup.picasso.Callback) Attachment(com.instructure.canvasapi.model.Attachment) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) HelveticaTextView(com.instructure.speedgrader.views.HelveticaTextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View)

Aggregations

MediaComment (com.instructure.canvasapi.model.MediaComment)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 Gson (com.google.gson.Gson)1 Attachment (com.instructure.canvasapi.model.Attachment)1 HelveticaTextView (com.instructure.speedgrader.views.HelveticaTextView)1 Callback (com.squareup.picasso.Callback)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1 Test (org.junit.Test)1