Commit ab0c5329 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RocketChatMessageAttachmentsLayout.java

parent 077b203d
...@@ -71,21 +71,21 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -71,21 +71,21 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
return; return;
} }
this.attachments = attachments; this.attachments = attachments;
removeAllViews();
for (int i = 0, size = attachments.size(); i < size; i++) { for (int i = 0, size = attachments.size(); i < size; i++) {
appendAttachmentView(attachments.get(i), autoloadImages); appendAttachmentView(attachments.get(i), autoloadImages, true);
} }
} }
public void appendAttachmentView(Attachment attachment, boolean autoloadImages) { public void appendAttachmentView(Attachment attachment, boolean autoloadImages, boolean showAttachmentStrip) {
if (attachment == null) { if (attachment == null) {
return; return;
} }
removeAllViews();
View attachmentView = inflater.inflate(R.layout.message_inline_attachment, this, false); View attachmentView = inflater.inflate(R.layout.message_inline_attachment, this, false);
colorizeAttachmentBar(attachment, attachmentView); colorizeAttachmentBar(attachment, attachmentView, showAttachmentStrip);
showAuthorAttachment(attachment, attachmentView); showAuthorAttachment(attachment, attachmentView);
showTitleAttachment(attachment, attachmentView); showTitleAttachment(attachment, attachmentView);
showReferenceAttachment(attachment, attachmentView); showReferenceAttachment(attachment, attachmentView);
...@@ -97,19 +97,23 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -97,19 +97,23 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
addView(attachmentView); addView(attachmentView);
} }
private void colorizeAttachmentBar(Attachment attachment, View attachmentView) { private void colorizeAttachmentBar(Attachment attachment, View attachmentView, boolean showAttachmentStrip) {
final View attachmentStrip = attachmentView.findViewById(R.id.attachment_strip); final View attachmentStrip = attachmentView.findViewById(R.id.attachment_strip);
final String colorString = attachment.getColor(); if (showAttachmentStrip) {
if (TextUtils.isEmpty(colorString)) { final String colorString = attachment.getColor();
attachmentStrip.setBackgroundResource(R.color.inline_attachment_quote_line); if (TextUtils.isEmpty(colorString)) {
return; attachmentStrip.setBackgroundResource(R.color.inline_attachment_quote_line);
} return;
}
try { try {
attachmentStrip.setBackgroundColor(Color.parseColor(colorString)); attachmentStrip.setBackgroundColor(Color.parseColor(colorString));
} catch (Exception e) { } catch (Exception e) {
attachmentStrip.setBackgroundResource(R.color.inline_attachment_quote_line); attachmentStrip.setBackgroundResource(R.color.inline_attachment_quote_line);
}
} else {
attachmentStrip.setVisibility(GONE);
} }
} }
...@@ -204,8 +208,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -204,8 +208,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
} }
} }
private void showImageAttachment(Attachment attachment, View attachmentView, private void showImageAttachment(Attachment attachment, View attachmentView, boolean autoloadImages) {
boolean autoloadImages) {
final View imageContainer = attachmentView.findViewById(R.id.image_container); final View imageContainer = attachmentView.findViewById(R.id.image_container);
if (attachment.getImageUrl() == null) { if (attachment.getImageUrl() == null) {
imageContainer.setVisibility(GONE); imageContainer.setVisibility(GONE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment