aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java45
1 files changed, 13 insertions, 32 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 ffede2c9..806d60a7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -10,7 +10,6 @@ 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;
@@ -957,16 +956,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
collapseChildren(commentPosition);
((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
} else {
- //expandChildren(commentPosition);
+ comment.setExpanded(true);
ArrayList<CommentData> newList = new ArrayList<>();
- eC(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
+ expandChildren(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 {
@@ -1269,33 +1264,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
return -1;
}
- private void expandChildren(int position) {
- CommentData comment = mVisibleComments.get(position);
- if (!comment.isExpanded()) {
- comment.setExpanded(true);
- ArrayList<CommentData> children = comment.getChildren();
- if (children != null && children.size() > 0) {
- for (int i = 0; i < children.size(); i++) {
- children.get(i).setExpanded(false);
- }
- mVisibleComments.addAll(position + 1, children);
- if (mIsSingleCommentThreadMode) {
- notifyItemRangeInserted(position + 3, children.size());
- } else {
- notifyItemRangeInserted(position + 2, children.size());
- }
- }
- }
- }
-
- private void eC(ArrayList<CommentData> comments, ArrayList<CommentData> newList, int position) {
+ private void expandChildren(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++) {
+ position++;
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();
+ expandChildren(comments.get(i).getChildren(), newList, position);
+ position = position + comments.get(i).getChildren().size();
}
comments.get(i).setExpanded(true);
}
@@ -1386,11 +1362,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mVisibleComments.get(parentPosition).addChild(comment);
mVisibleComments.get(parentPosition).setHasReply(true);
if (!mVisibleComments.get(parentPosition).isExpanded()) {
- expandChildren(parentPosition);
+ ArrayList<CommentData> newList = new ArrayList<>();
+ expandChildren(mVisibleComments.get(parentPosition).getChildren(), newList, 0);
+ mVisibleComments.get(parentPosition).setExpanded(true);
+ mVisibleComments.addAll(parentPosition + 1, newList);
if (mIsSingleCommentThreadMode) {
notifyItemChanged(parentPosition + 2);
+ notifyItemRangeInserted(parentPosition + 3, newList.size());
} else {
notifyItemChanged(parentPosition + 1);
+ notifyItemRangeInserted(parentPosition + 2, newList.size());
}
} else {
mVisibleComments.add(parentPosition + 1, comment);
>-61/+147 2019-11-26Fix force stop when navigating top-level comments. Fix invisible retry loadin...Alex Ning7-67/+69 2019-11-19Version 1.6.0Alex Ning2-6/+3 2019-11-19Swipe down to refresh is available in other activities.Alex Ning13-127/+178 2019-11-19Superscript is now available.Alex Ning12-12/+53 2019-11-19Disable double touch to upvote in comments due to the link in comments cannot...Alex Ning2-66/+0 2019-11-18Hide the FloatingActionButton in ViewPostDetailActivity when scrolling down b...Alex Ning1-0/+88 2019-11-17Double tap to upvote comments.Alex Ning2-0/+68 2019-11-17Add a Fab to scroll down parent comments. Use volume up and down keys to navi...Alex Ning7-4/+131 2019-11-15Swipe right to go back from ViewPostDetailActivity. Fix inconsistency in elap...Alex Ning9-38/+76 2019-11-15Swiping to refresh posts is now available.Alex Ning7-38/+60 2019-11-14Move util classes to Utils package.Alex Ning68-43/+84 2019-11-12Showing elapsed time in posts and comments is available.Alex Ning18-77/+187 2019-11-12Show low-resolution images in compact layout. Send notifications of messages ...Alex Ning7-48/+83 2019-11-11Set post layout for subreddit and user posts individually.Alex Ning10-22/+30 2019-11-11Changing post layout in other activities is available. Show username in card ...Alex Ning11-17/+151 2019-11-11Changing post layout in ViewSubredditDetailActivity is available. Tweak the c...Alex Ning7-15/+55 2019-11-09Update README.mdDocile-Alligator1-2/+3 2019-11-08Compact post layout is available. Fixed WebView cannot be inflated on Android...Alex Ning16-213/+1454 2019-11-05Fixed IllegalStateException in SubredditSelectionActivity. Downgrade material...Alex Ning3-67/+71 2019-10-29Minor UI issue fixed.Alex Ning1-1/+1 2019-10-29Fixed UI issues in posts and comments. Version 1.4.0.Alex Ning14-322/+171 2019-10-29Placing vote buttons on the right for comments is now available.Alex Ning7-24/+210 2019-10-29Make Placing vote buttons on the right an option.Alex Ning42-196/+334