mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2026-08-18 02:51:58 +00:00
Fix issues in fully expanding comments in CommentsRecyclerViewAdapterNew.
This commit is contained in:
@ -8,6 +8,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -675,6 +676,50 @@ public class CommentsRecyclerViewAdapterNew extends ListAdapter<Comment, Recycle
|
||||
params.setMargins(0, (int) Utils.convertDpToPixel(16, mActivity), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*int bottomToolbarWidth = itemWidth - comment.getDepth() * 12;
|
||||
Log.i("asdfasdf", "S " + bottomToolbarWidth);
|
||||
if (bottomToolbarWidth > 420) {
|
||||
if (((CommentFullyCollapsedViewHolder) holder).saveButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).saveButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).replyButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).replyButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).expandButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (bottomToolbarWidth > 350) {
|
||||
if (((CommentFullyCollapsedViewHolder) holder).saveButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).saveButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).replyButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).replyButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).expandButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (bottomToolbarWidth > 300) {
|
||||
if (((CommentFullyCollapsedViewHolder) holder).saveButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).saveButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).replyButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).replyButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).expandButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (((CommentFullyCollapsedViewHolder) holder).saveButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).saveButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).replyButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).replyButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (((CommentFullyCollapsedViewHolder) holder).expandButton != null) {
|
||||
((CommentFullyCollapsedViewHolder) holder).expandButton.setVisibility(View.GONE);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
||||
Comment placeholder = getItem(position);
|
||||
|
||||
@ -1081,23 +1081,23 @@ class ViewPostDetailFragmentViewModelNew(
|
||||
if (it.isExpanded) {
|
||||
return collapseComment(position)
|
||||
} else {
|
||||
if (!it.children.isNullOrEmpty()) {
|
||||
val newList = ArrayList<Comment>()
|
||||
expandComment(it.children, newList)
|
||||
val updatedComment = Comment(it)
|
||||
updatedComment.setExpanded(true)
|
||||
|
||||
val updatedComment = Comment(it)
|
||||
updatedComment.setExpanded(true)
|
||||
val newList = ArrayList<Comment>()
|
||||
expandComment(it.children, newList)
|
||||
|
||||
val updatedComments = ArrayList(comments)
|
||||
updatedComments[position] = updatedComment
|
||||
val updatedComments = ArrayList(comments)
|
||||
updatedComments[position] = updatedComment
|
||||
if (newList.isNotEmpty()) {
|
||||
updatedComments.addAll(position + 1, newList)
|
||||
|
||||
_dataState.value = _dataState.value.copy(
|
||||
comments = updatedComments
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
_dataState.value = _dataState.value.copy(
|
||||
comments = updatedComments
|
||||
)
|
||||
|
||||
return newList.isNotEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1122,6 +1122,9 @@ class ViewPostDetailFragmentViewModelNew(
|
||||
_dataState.value.comments?.let { comments ->
|
||||
val comment = comments.getOrNull(position)
|
||||
comment?.let {
|
||||
val updatedComment = Comment(it)
|
||||
updatedComment.setExpanded(false)
|
||||
|
||||
val depth: Int = it.depth
|
||||
var allChildrenSize = 0
|
||||
for (i in position + 1..<comments.size) {
|
||||
@ -1132,20 +1135,18 @@ class ViewPostDetailFragmentViewModelNew(
|
||||
}
|
||||
}
|
||||
|
||||
val updatedComments = ArrayList(comments)
|
||||
updatedComments[position] = updatedComment
|
||||
|
||||
if (allChildrenSize > 0) {
|
||||
val updatedComment = Comment(it)
|
||||
updatedComment.setExpanded(false)
|
||||
|
||||
val updatedComments = ArrayList(comments)
|
||||
updatedComments[position] = updatedComment
|
||||
updatedComments.subList(position + 1, position + 1 + allChildrenSize).clear()
|
||||
|
||||
_dataState.value = _dataState.value.copy(
|
||||
comments = updatedComments
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
_dataState.value = _dataState.value.copy(
|
||||
comments = updatedComments
|
||||
)
|
||||
|
||||
return allChildrenSize > 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user