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 +++ 6 files changed, 77 insertions(+), 8 deletions(-) (limited to 'app/src/main/java') 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) { -- cgit v1.2.3