Continue applying comment filter.

This commit is contained in:
Docile-Alligator
2023-10-20 09:27:30 -04:00
parent f997e22f90
commit af04240dfa

View File

@ -1357,71 +1357,80 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mRecyclerView.setAdapter(mConcatAdapter);
}
if (mRespectSubredditRecommendedSortType) {
fetchCommentsRespectRecommendedSort(false);
} else {
ParseComment.parseComment(mExecutor, new Handler(), response.body(),
mExpandChildren, mCommentFilter, new ParseComment.ParseCommentListener() {
@Override
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments, ArrayList<Comment> expandedComments, String parentId, ArrayList<String> moreChildrenIds) {
ViewPostDetailFragment.this.children = moreChildrenIds;
FetchCommentFilter.fetchCommentFilter(mExecutor, new Handler(Looper.getMainLooper()), mRedditDataRoomDatabase,
mPost.getSubredditName(), new FetchCommentFilter.FetchCommentFilterListener() {
@Override
public void success(CommentFilter commentFilter) {
mCommentFilter = commentFilter;
commentFilterFetched = true;
hasMoreChildren = children.size() != 0;
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
if (mRespectSubredditRecommendedSortType) {
fetchCommentsRespectRecommendedSort(false);
} else {
ParseComment.parseComment(mExecutor, new Handler(), response.body(),
mExpandChildren, mCommentFilter, new ParseComment.ParseCommentListener() {
@Override
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments, ArrayList<Comment> expandedComments, String parentId, ArrayList<String> moreChildrenIds) {
ViewPostDetailFragment.this.children = moreChildrenIds;
if (children.size() > 0) {
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).clearOnScrollListeners();
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) {
if (!recyclerView.canScrollVertically(1)) {
activity.hideFab();
} else {
if (dy > 0) {
if (mSwipeUpToHideFab) {
activity.showFab();
} else {
activity.hideFab();
hasMoreChildren = children.size() != 0;
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
if (children.size() > 0) {
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).clearOnScrollListeners();
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) {
if (!recyclerView.canScrollVertically(1)) {
activity.hideFab();
} else {
if (dy > 0) {
if (mSwipeUpToHideFab) {
activity.showFab();
} else {
activity.hideFab();
}
} else {
if (mSwipeUpToHideFab) {
activity.hideFab();
} else {
activity.showFab();
}
}
}
}
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
int firstVisibleItemPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
fetchMoreComments();
}
}
}
} else {
if (mSwipeUpToHideFab) {
activity.hideFab();
} else {
activity.showFab();
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
mIsSmoothScrolling = false;
}
}
}
});
}
}
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
int firstVisibleItemPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
fetchMoreComments();
}
@Override
public void onParseCommentFailed() {
mCommentsAdapter.initiallyLoadCommentsFailed();
}
}
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
mIsSmoothScrolling = false;
}
}
});
}
});
}
@Override
public void onParseCommentFailed() {
mCommentsAdapter.initiallyLoadCommentsFailed();
}
});
}
}
});
}
@Override