From 5eaf4ab8fef1c50cfec708f2f15d3ee4fdd3df47 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 17 Jan 2022 17:30:56 +0800 Subject: Show child reply count in comments. --- .../CommentsListingRecyclerViewAdapter.java | 3 +- .../adapters/CommentsRecyclerViewAdapter.java | 44 +++++++++++++++++++--- .../adapters/PostDetailRecyclerViewAdapter.java | 7 ++++ .../infinityforreddit/comment/Comment.java | 13 +++++++ .../infinityforreddit/comment/ParseComment.java | 12 ++++++ .../fragments/ViewPostDetailFragment.java | 6 +++ app/src/main/res/layout/item_comment.xml | 9 +++-- .../res/layout/item_comment_fully_collapsed.xml | 12 ++++++ 8 files changed, 95 insertions(+), 11 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index 6ebce53e..33fd9075 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -374,7 +374,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter 0) { + ((CommentViewHolder) holder).expandButton.setText("+" + comment.getChildCount()); + } if (comment.isExpanded()) { - ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp); + ((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null); } else { - ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp); + ((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null); } ((CommentViewHolder) holder).expandButton.setVisibility(View.VISIBLE); } @@ -486,6 +494,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter 0) { + ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setVisibility(View.VISIBLE); + ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setText("+" + comment.getChildCount()); + } else { + ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setVisibility(View.GONE); + } if (mShowElapsedTime) { ((CommentFullyCollapsedViewHolder) holder).commentTimeTextView.setText(Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis())); } else { @@ -603,6 +617,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter newList = new ArrayList<>(); @@ -1439,7 +1467,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter comments, ArrayList visibleComments, boolean setExpanded) { for (Comment c : comments) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index eabcb073..a7b4a15b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -703,12 +703,18 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mCommentsAdapter != null) { mCommentsAdapter.addComment(comment); } + if (mPostAdapter != null) { + mPostAdapter.addOneComment(); + } } public void addChildComment(Comment comment, String parentFullname, int parentPosition) { if (mCommentsAdapter != null) { mCommentsAdapter.addChildComment(comment, parentFullname, parentPosition); } + if (mPostAdapter != null) { + mPostAdapter.addOneComment(); + } } public void editComment(String commentAuthor, String commentContentMarkdown, int position) { diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index e6d3f89d..e087c087 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -171,15 +171,18 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> - + +