diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-02-03 08:59:25 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-02-03 08:59:25 +0000 |
commit | 73980544db791bf27b08b26d3f64f9ef2e3e822e (patch) | |
tree | 758e65d9f8be7be772d1068f264c965649c688dd /app/src/main | |
parent | 802a70e9c9d63c799e86e1d889801d74a517212f (diff) | |
download | infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar.gz infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar.bz2 infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar.lz infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar.xz infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.tar.zst infinity-for-reddit-73980544db791bf27b08b26d3f64f9ef2e3e822e.zip |
Fix bugs of showing top-level comments.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java | 4 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java index 8fb9a851..2af9275e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchComment.java @@ -67,6 +67,10 @@ public class FetchComment { ArrayList<String> allChildren, int startingIndex, int depth, boolean expandChildren, Locale locale, FetchMoreCommentListener fetchMoreCommentListener) { + if (allChildren == null) { + return; + } + StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 100; i++) { if (allChildren.size() <= startingIndex + i) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 54101eba..1650b6bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -95,12 +95,15 @@ public class ParseComment { } } - private static void expandChildren(ArrayList<CommentData> comments, ArrayList<CommentData> visibleComments) { + private static void expandChildren(ArrayList<CommentData> comments, ArrayList<CommentData> visibleComments, + boolean setExpanded) { for (CommentData c : comments) { visibleComments.add(c); if (c.hasReply()) { - c.setExpanded(true); - expandChildren(c.getChildren(), visibleComments); + if (setExpanded) { + c.setExpanded(true); + } + expandChildren(c.getChildren(), visibleComments, setExpanded); } if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) { //Add a load more placeholder @@ -239,9 +242,7 @@ public class ParseComment { protected Void doInBackground(Void... voids) { try { parseCommentRecursion(commentsJSONArray, newComments, moreChildrenFullnames, depth, locale); - if (expandChildren) { - expandChildren(newComments, expandedNewComments); - } + expandChildren(newComments, expandedNewComments, expandChildren); } catch (JSONException e) { parseFailed = true; } |