From c199a78799b1e53ced01be9d5e18d758d1883bf7 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:00:59 -0400 Subject: Maybe fixed CommentsRecyclerViewAdapter inconsistent update. --- .../adapters/CommentsRecyclerViewAdapter.java | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'app/src/main') 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= 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 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= 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; -- cgit v1.2.3