From 4521d3b0ce49b908da39e5a299257771f579dc8e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 28 Dec 2019 20:57:19 +0800 Subject: Expand all the children in a comment instead of expanding only the next level of comments. --- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 74c04432..ffede2c9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -10,6 +10,7 @@ import android.net.Uri; import android.os.Bundle; import android.text.style.SuperscriptSpan; import android.text.util.Linkify; +import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; @@ -956,8 +957,21 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter newList = new ArrayList<>(); + eC(mVisibleComments.get(commentPosition).getChildren(), newList, 0); mVisibleComments.get(commentPosition).setExpanded(true); + mVisibleComments.addAll(commentPosition + 1, newList); + Log.i("adfasdf", "s " + newList.size()); + for (CommentData c : newList) { + Log.i("adfasdf", "s " + c.getAuthor()); + } + Log.i("adfasdf", "s " + commentPosition); + if (mIsSingleCommentThreadMode) { + notifyItemRangeInserted(commentPosition + 3, newList.size()); + } else { + notifyItemRangeInserted(commentPosition + 2, newList.size()); + } ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp); } } @@ -1274,6 +1288,20 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter comments, ArrayList newList, int position) { + if (comments != null && comments.size() > 0) { + newList.addAll(position, comments); + int newPosition = position + 1; + for (int i = 0; i < comments.size(); i++) { + if (comments.get(i).getChildren() != null && comments.get(i).getChildren().size() > 0) { + eC(comments.get(i).getChildren(), newList, newPosition); + newPosition += comments.get(i).getChildren().size(); + } + comments.get(i).setExpanded(true); + } + } + } + private void collapseChildren(int position) { mVisibleComments.get(position).setExpanded(false); int depth = mVisibleComments.get(position).getDepth(); -- cgit v1.2.3