From c2f99e130d060114941a5faeabec3c52db148d89 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 25 Nov 2020 15:11:13 +0100 Subject: [PATCH] clean adapter for comment --- .../drawer/CommentListAdapter.java | 101 +++++++----------- 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java index 419486d..cac02eb 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java @@ -33,15 +33,14 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.EditText; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; @@ -59,6 +58,7 @@ import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.data.CommentData.Comment; import app.fedilab.fedilabtube.client.entities.Report; +import app.fedilab.fedilabtube.databinding.DrawerCommentBinding; import app.fedilab.fedilabtube.helper.CommentDecorationHelper; import app.fedilab.fedilabtube.helper.EmojiHelper; import app.fedilab.fedilabtube.helper.Helper; @@ -104,8 +104,8 @@ public class CommentListAdapter extends RecyclerView.Adapter { - PopupMenu popup = new PopupMenu(context, holder.more_actions); + holder.binding.commentAccountProfile.setLayoutParams(params); + holder.binding.moreActions.setOnClickListener(view -> { + PopupMenu popup = new PopupMenu(context, holder.binding.moreActions); popup.getMenuInflater() .inflate(R.menu.comment_menu, popup.getMenu()); if (!Helper.isOwner(context, comment.getAccount())) { @@ -219,7 +219,7 @@ public class CommentListAdapter extends RecyclerView.Adapter { + holder.binding.commentContent.setOnTouchListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { try { view.requestFocus(); @@ -234,22 +234,22 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openCommentThread(comment)); - holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); + holder.binding.mainContainer.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); + holder.binding.commentContent.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); } if (comment.getTotalReplies() > 0) { - holder.number_of_replies.setVisibility(View.VISIBLE); - holder.number_of_replies.setText(context.getResources().getQuantityString(R.plurals.number_of_replies, comment.getTotalReplies(), comment.getTotalReplies())); + holder.binding.numberOfReplies.setVisibility(View.VISIBLE); + holder.binding.numberOfReplies.setText(context.getResources().getQuantityString(R.plurals.number_of_replies, comment.getTotalReplies(), comment.getTotalReplies())); } else { - holder.number_of_replies.setVisibility(View.GONE); + holder.binding.numberOfReplies.setVisibility(View.GONE); } if (comment.getAccount() != null) { @@ -265,10 +265,10 @@ public class CommentListAdapter extends RecyclerView.Adapter { + holder.binding.commentAccountProfile.setOnClickListener(v -> { Bundle b = new Bundle(); Intent intent = new Intent(context, ShowAccountActivity.class); b.putParcelable("account", comment.getAccount()); @@ -287,17 +287,17 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openPostComment(comment, i)); - holder.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + holder.binding.postReplyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); } public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) { @@ -358,40 +358,15 @@ public class CommentListAdapter extends RecyclerView.Adapter