diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-10-20 13:27:30 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-10-20 13:27:30 +0000 |
commit | af04240dfa014b5d61ac0c83ea57b7983e086dd4 (patch) | |
tree | 2ffd1897d22e6451777d92fea35a949dccc302fe /app/src/main/java/ml/docilealligator | |
parent | f997e22f90150957440e750d0886a4115aaf9471 (diff) | |
download | infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar.gz infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar.bz2 infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar.lz infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar.xz infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.tar.zst infinity-for-reddit-af04240dfa014b5d61ac0c83ea57b7983e086dd4.zip |
Continue applying comment filter.
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java | 125 |
1 files changed, 67 insertions, 58 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 36fecec9..1e372602 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -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; - - 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(); - } - } - } - } + FetchCommentFilter.fetchCommentFilter(mExecutor, new Handler(Looper.getMainLooper()), mRedditDataRoomDatabase, + mPost.getSubredditName(), new FetchCommentFilter.FetchCommentFilterListener() { + @Override + public void success(CommentFilter commentFilter) { + mCommentFilter = commentFilter; + commentFilterFetched = true; - 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 (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; + + 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(); + } + } + } - if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { - fetchMoreComments(); + @Override + public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { + if (newState == RecyclerView.SCROLL_STATE_IDLE) { + mIsSmoothScrolling = false; + } + } + }); } } - } - @Override - public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { - if (newState == RecyclerView.SCROLL_STATE_IDLE) { - mIsSmoothScrolling = false; + @Override + public void onParseCommentFailed() { + mCommentsAdapter.initiallyLoadCommentsFailed(); } - } - }); - } - } - - @Override - public void onParseCommentFailed() { - mCommentsAdapter.initiallyLoadCommentsFailed(); + }); } - }); - } + } + }); } @Override |