diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-07 15:31:59 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-07 15:31:59 +0300 |
commit | 54c4142db7f4869f7f9b7625386f8c8ac83b9e66 (patch) | |
tree | 8fe3a9550cee71c0d794410b538284e95d606e78 /app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments | |
parent | f47085822807cd3fb515138b48ff4dd5c900b6ce (diff) | |
parent | ad1dc0af2d004dbf33ab2bcce7cc12b6733196ae (diff) |
Merge branch 'master' into edit-comments
# Conflicts:
# app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java
# app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments')
2 files changed, 7 insertions, 7 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java index 9bd4a7ed5..e4571a352 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java @@ -41,8 +41,6 @@ import static it.niedermann.nextcloud.deck.util.DimensionUtil.getAvatarDimension public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapter.ItemCommentViewHolder> { @NonNull - private final Context context; - @NonNull private final List<DeckComment> comments; @NonNull private final Account account; @@ -57,7 +55,6 @@ public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapte CardCommentsAdapter(@NonNull Context context, @NonNull List<DeckComment> comments, @NonNull Account account, @NonNull MenuInflater menuInflater, @NonNull CommentDeletedListener commentDeletedListener) { this(context, comments, account, menuInflater, commentDeletedListener, null, null); - setHasStableIds(true); } CardCommentsAdapter(@NonNull Context context, @NonNull List<DeckComment> comments, @NonNull Account account, @NonNull MenuInflater menuInflater, @NonNull CommentDeletedListener commentDeletedListener, @Nullable CommentEditedListener commentEditedListener, @Nullable FragmentManager fragmentManager) { @@ -84,13 +81,15 @@ public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapte @Override public void onBindViewHolder(@NonNull ItemCommentViewHolder holder, int position) { - DeckComment comment = comments.get(position); + final Context context = holder.itemView.getContext(); + final DeckComment comment = comments.get(position); + ViewUtil.addAvatar(context, holder.binding.avatar, account.getUrl(), account.getUserName(), getAvatarDimension(context, R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); holder.binding.message.setText(comment.getMessage()); holder.binding.actorDisplayName.setText(comment.getActorDisplayName()); holder.binding.creationDateTime.setText(DateUtil.getRelativeDateTimeString(context, comment.getCreationDateTime().getTime())); - holder.binding.getRoot().setOnClickListener(View::showContextMenu); - holder.binding.getRoot().setOnCreateContextMenuListener((menu, v, menuInfo) -> { + holder.itemView.setOnClickListener(View::showContextMenu); + holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> { menuInflater.inflate(R.menu.comment_menu, menu); menu.findItem(android.R.id.copy).setOnMenuItemClickListener(item -> copyToClipboard(context, comment.getMessage())); menu.findItem(R.id.delete).setOnMenuItemClickListener(item -> { @@ -116,6 +115,7 @@ public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapte } private void setupMentions(List<Mention> mentions, TextView tv) { + Context context = tv.getContext(); SpannableStringBuilder messageBuilder = new SpannableStringBuilder(tv.getText()); // Step 1 diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java index af7898849..418be4a16 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsFragment.java @@ -72,7 +72,7 @@ public class CardCommentsFragment extends Fragment implements CommentEditedListe binding.emptyContentView.setVisibility(GONE); binding.comments.setVisibility(VISIBLE); if (requireActivity() instanceof CommentEditedListener) { - binding.comments.setAdapter(new CardCommentsAdapter(requireContext(), comments, account, requireActivity().getMenuInflater(), (CommentDeletedListener) requireActivity(), (CommentEditedListener) requireActivity(), requireActivity().getSupportFragmentManager())); + binding.comments.setAdapter(new CardCommentsAdapter(comments, account, requireActivity().getMenuInflater(), (CommentDeletedListener) requireActivity(), (CommentEditedListener) requireActivity(), requireActivity().getSupportFragmentManager())); } else { binding.comments.setAdapter(new CardCommentsAdapter(requireContext(), comments, account, requireActivity().getMenuInflater(), (CommentDeletedListener) requireActivity())); } |