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());
}
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;
}
Aggregations