diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-04-19 20:00:59 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-04-19 20:00:59 +0000 |
commit | c199a78799b1e53ced01be9d5e18d758d1883bf7 (patch) | |
tree | 78783e83bfb69f3047a8301e6bc7e6f8fcaf9db5 /app | |
parent | 8503e78a8e42f8e29b57f0017dafcfc615512d69 (diff) | |
download | infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar.gz infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar.bz2 infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar.lz infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar.xz infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.tar.zst infinity-for-reddit-c199a78799b1e53ced01be9d5e18d758d1883bf7.zip |
Maybe fixed CommentsRecyclerViewAdapter inconsistent update.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 5254c6db..b8c38039 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -821,6 +821,26 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi this.canStartActivity = canStartActivity; } + @Nullable + private Comment getCurrentComment(RecyclerView.ViewHolder holder) { + return getCurrentComment(holder.getBindingAdapterPosition()); + } + + @Nullable + private Comment getCurrentComment(int position) { + if (mIsSingleCommentThreadMode) { + if (position - 1 >= 0 && position - 1 < mVisibleComments.size()) { + return mVisibleComments.get(position - 1); + } + } else { + if (position >= 0 && position < mVisibleComments.size()) { + return mVisibleComments.get(position); + } + } + + return null; + } + private int getParentPosition(int position) { if (position >= 0 && position < mVisibleComments.size()) { int childDepth = mVisibleComments.get(position).getDepth(); @@ -906,10 +926,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } public void addComments(@NonNull ArrayList<Comment> comments, boolean hasMoreComments) { - if (mVisibleComments.size() == 0) { + if (mVisibleComments.isEmpty()) { isInitiallyLoading = false; isInitiallyLoadingFailed = false; - if (comments.size() == 0) { + if (comments.isEmpty()) { notifyItemChanged(0); } else { notifyItemRemoved(0); @@ -919,7 +939,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi int sizeBefore = mVisibleComments.size(); mVisibleComments.addAll(comments); if (mIsSingleCommentThreadMode) { - notifyItemRangeInserted(sizeBefore, comments.size() + 1); + notifyItemRangeInserted(sizeBefore + 1, comments.size()); } else { notifyItemRangeInserted(sizeBefore, comments.size()); } @@ -1809,26 +1829,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } } - @Nullable - private Comment getCurrentComment(RecyclerView.ViewHolder holder) { - return getCurrentComment(holder.getBindingAdapterPosition()); - } - - @Nullable - private Comment getCurrentComment(int position) { - if (mIsSingleCommentThreadMode) { - if (position - 1 >= 0 && position - 1 < mVisibleComments.size()) { - return mVisibleComments.get(position - 1); - } - } else { - if (position >= 0 && position < mVisibleComments.size()) { - return mVisibleComments.get(position); - } - } - - return null; - } - class CommentFullyCollapsedViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.vertical_block_indentation_item_comment_fully_collapsed) CommentIndentationView commentIndentationView; |