Fix post refreshing bug

Fix bug where the whole post disappears after refreshing it.
This commit is contained in:
Balazs Toldi 2023-07-27 17:45:14 +02:00
parent 9d6e15edb7
commit 2fc4020b72
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 10 additions and 9 deletions

View File

@ -1937,4 +1937,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((TextView) itemView).setTextColor(mColorAccent);
}
}
public void clearLoadedComments() {
loadedComments.clear();
}
}

View File

@ -1408,16 +1408,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
String suggestedCommentSort = "top";
SortType.Type sortTypeType;
if (suggestedCommentSort == null || suggestedCommentSort.equals("null") || suggestedCommentSort.equals("")) {
mRespectSubredditRecommendedSortType = false;
try {
sortTypeType = SortType.Type.fromValue(suggestedCommentSort);
} catch (IllegalArgumentException e) {
e.printStackTrace();
sortTypeType = loadSortType();
} else {
try {
sortTypeType = SortType.Type.valueOf(suggestedCommentSort.toUpperCase(Locale.US));
} catch (IllegalArgumentException e) {
e.printStackTrace();
sortTypeType = loadSortType();
}
}
activity.setTitle(sortTypeType.fullName);
ViewPostDetailFragment.this.sortType = sortTypeType;
@ -1582,6 +1577,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mSwipeRefreshLayout.setRefreshing(false);
if (fetchComments) {
pages_loaded = 0;
mCommentsAdapter.clearLoadedComments();
fetchCommentsRespectRecommendedSort(true);
} else {
isRefreshing = false;