diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-11-25 22:32:31 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-11-25 22:32:31 +0300 |
commit | 082737ffc9e2151135ac7dd3033a0b68c5bfecf8 (patch) | |
tree | 9e0589790bd132e6f52d98cd0a63a811ad549950 /app/src/main/java/it/niedermann | |
parent | 5a162167612fb98ec5bc8dd614e1ca7f0269610f (diff) |
Refactored Mentions support for MarkdownViewer
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/ItemCommentViewHolder.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/ItemCommentViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/ItemCommentViewHolder.java index 42431ae0c..df44e58ef 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/ItemCommentViewHolder.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/ItemCommentViewHolder.java @@ -40,11 +40,15 @@ public class ItemCommentViewHolder extends RecyclerView.ViewHolder { public void bind(@NonNull FullDeckComment comment, @NonNull Account account, @ColorInt int mainColor, @NonNull MenuInflater inflater, @NonNull CommentDeletedListener deletedListener, @NonNull CommentSelectAsReplyListener selectAsReplyListener, @NonNull FragmentManager fragmentManager) { ViewUtil.addAvatar(binding.avatar, account.getUrl(), comment.getComment().getActorId(), DimensionUtil.INSTANCE.dpToPx(binding.avatar.getContext(), R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); - binding.message.setMarkdownString(comment.getComment().getMessage()); + final Map<String, String> mentions = new HashMap<>(comment.getComment().getMentions().size()); + for (Mention mention : comment.getComment().getMentions()) { + mentions.put(mention.getMentionId(), mention.getMentionDisplayName()); + } + binding.message.setMarkdownString(comment.getComment().getMessage(), mentions); binding.actorDisplayName.setText(comment.getComment().getActorDisplayName()); binding.creationDateTime.setText(DateUtil.getRelativeDateTimeString(binding.creationDateTime.getContext(), comment.getComment().getCreationDateTime().toEpochMilli())); - itemView.setOnClickListener(View::showContextMenu); + itemView.setOnClickListener(View::showContextMenu); itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> { inflater.inflate(R.menu.comment_menu, menu); menu.findItem(android.R.id.copy).setOnMenuItemClickListener(item -> ClipboardUtil.INSTANCE.copyToClipboard(itemView.getContext(), comment.getComment().getMessage())); @@ -73,16 +77,10 @@ public class ItemCommentViewHolder extends RecyclerView.ViewHolder { } }); + TooltipCompat.setTooltipText(binding.creationDateTime, comment.getComment().getCreationDateTime().atZone(ZoneId.systemDefault()).format(dateFormatter)); DrawableCompat.setTint(binding.notSyncedYet.getDrawable(), mainColor); binding.notSyncedYet.setVisibility(DBStatus.LOCAL_EDITED.equals(comment.getStatusEnum()) ? View.VISIBLE : View.GONE); - TooltipCompat.setTooltipText(binding.creationDateTime, comment.getComment().getCreationDateTime().atZone(ZoneId.systemDefault()).format(dateFormatter)); - final Map<String, String> mentions = new HashMap<>(comment.getComment().getMentions().size()); - for (Mention mention : comment.getComment().getMentions()) { - mentions.put(mention.getMentionId(), mention.getMentionDisplayName()); - } - binding.message.setMentions(mentions); - if (comment.getParent() == null) { binding.parentContainer.setVisibility(View.GONE); } else { |