Fix bugs of showing top-level comments.

This commit is contained in:
Alex Ning 2020-02-03 16:59:25 +08:00
parent 802a70e9c9
commit 73980544db
2 changed files with 11 additions and 6 deletions

View File

@ -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) {

View File

@ -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;
}