diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-12-28 12:57:19 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-12-28 12:57:19 +0000 |
commit | 4521d3b0ce49b908da39e5a299257771f579dc8e (patch) | |
tree | ad5f234c909af337c1e1b07dcbf04c134dd107a1 | |
parent | aefc82803624a13861449ef089f1fe9f9b595be8 (diff) | |
download | infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar.gz infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar.bz2 infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar.lz infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar.xz infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.tar.zst infinity-for-reddit-4521d3b0ce49b908da39e5a299257771f579dc8e.zip |
Expand all the children in a comment instead of expanding only the next level of comments.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java | 30 |
1 files changed, 29 insertions, 1 deletions
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<Recy collapseChildren(commentPosition); ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp); } else { - expandChildren(commentPosition); + //expandChildren(commentPosition); + ArrayList<CommentData> 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<Recy } } + private void eC(ArrayList<CommentData> comments, ArrayList<CommentData> 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(); |