mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Fix not showing all comments in single comment thread mode in CommentsRecyclerViewAdapter.
This commit is contained in:
parent
7b1221bfc9
commit
d5c65ff492
@ -13,6 +13,7 @@ import android.text.Spanned;
|
|||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -773,6 +774,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void collapseChildren(int position) {
|
private void collapseChildren(int position) {
|
||||||
|
Log.i("asdfasdf", "s " + position);
|
||||||
mVisibleComments.get(position).setExpanded(false);
|
mVisibleComments.get(position).setExpanded(false);
|
||||||
int depth = mVisibleComments.get(position).getDepth();
|
int depth = mVisibleComments.get(position).getDepth();
|
||||||
int allChildrenSize = 0;
|
int allChildrenSize = 0;
|
||||||
@ -788,15 +790,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
mVisibleComments.subList(position + 1, position + 1 + allChildrenSize).clear();
|
mVisibleComments.subList(position + 1, position + 1 + allChildrenSize).clear();
|
||||||
}
|
}
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
|
Log.i("asdfasdf", "s1 " + getItemCount());
|
||||||
|
notifyItemRangeRemoved(position + 2, allChildrenSize);
|
||||||
if (mFullyCollapseComment) {
|
if (mFullyCollapseComment) {
|
||||||
notifyItemChanged(position + 1);
|
notifyItemChanged(position + 1);
|
||||||
}
|
}
|
||||||
notifyItemRangeRemoved(position + 2, allChildrenSize);
|
|
||||||
} else {
|
} else {
|
||||||
|
notifyItemRangeRemoved(position + 1, allChildrenSize);
|
||||||
if (mFullyCollapseComment) {
|
if (mFullyCollapseComment) {
|
||||||
notifyItemChanged(position);
|
notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
notifyItemRangeRemoved(position + 1, allChildrenSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +817,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int sizeBefore = mVisibleComments.size();
|
int sizeBefore = mVisibleComments.size();
|
||||||
mVisibleComments.addAll(comments);
|
mVisibleComments.addAll(comments);
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
notifyItemRangeInserted(sizeBefore + 1, comments.size());
|
notifyItemRangeInserted(sizeBefore, comments.size() + 1);
|
||||||
} else {
|
} else {
|
||||||
notifyItemRangeInserted(sizeBefore, comments.size());
|
notifyItemRangeInserted(sizeBefore, comments.size());
|
||||||
}
|
}
|
||||||
@ -1069,6 +1072,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
|
Log.i("asdfasdf", "now " + (mVisibleComments.size() + 1));
|
||||||
return mVisibleComments.size() + 1;
|
return mVisibleComments.size() + 1;
|
||||||
} else {
|
} else {
|
||||||
return mVisibleComments.size();
|
return mVisibleComments.size();
|
||||||
@ -1438,26 +1442,25 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
expandButton.setOnClickListener(view -> {
|
expandButton.setOnClickListener(view -> {
|
||||||
if (expandButton.getVisibility() == View.VISIBLE) {
|
if (expandButton.getVisibility() == View.VISIBLE) {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? getBindingAdapterPosition() - 1 : getBindingAdapterPosition();
|
int commentPosition = mIsSingleCommentThreadMode ? getBindingAdapterPosition() - 1 : getBindingAdapterPosition();
|
||||||
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
Comment comment = getCurrentComment(this);
|
||||||
Comment comment = getCurrentComment(this);
|
if (comment != null) {
|
||||||
if (comment != null) {
|
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
||||||
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
collapseChildren(commentPosition);
|
||||||
collapseChildren(commentPosition);
|
Log.i("asdfasdf", "ssf");
|
||||||
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
||||||
} else {
|
} else {
|
||||||
comment.setExpanded(true);
|
comment.setExpanded(true);
|
||||||
ArrayList<Comment> newList = new ArrayList<>();
|
ArrayList<Comment> newList = new ArrayList<>();
|
||||||
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
||||||
mVisibleComments.get(commentPosition).setExpanded(true);
|
mVisibleComments.get(commentPosition).setExpanded(true);
|
||||||
mVisibleComments.addAll(commentPosition + 1, newList);
|
mVisibleComments.addAll(commentPosition + 1, newList);
|
||||||
|
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
notifyItemRangeInserted(commentPosition + 2, newList.size());
|
notifyItemRangeInserted(commentPosition + 2, newList.size());
|
||||||
} else {
|
} else {
|
||||||
notifyItemRangeInserted(commentPosition + 1, newList.size());
|
notifyItemRangeInserted(commentPosition + 1, newList.size());
|
||||||
}
|
|
||||||
expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
|
|
||||||
}
|
}
|
||||||
|
expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mFullyCollapseComment) {
|
} else if (mFullyCollapseComment) {
|
||||||
|
Loading…
Reference in New Issue
Block a user