Implement two pane layout in ViewPostDetailFragment to separate post detail and comments. Fix bugs related to separating CommentAndPostRecyclerViewAdapter.

This commit is contained in:
Alex Ning 2021-06-22 13:16:17 +08:00
parent e222fbc5b1
commit 11ec08c12f
6 changed files with 288 additions and 408 deletions

View File

@ -393,9 +393,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Comment comment = getCurrentComment(position); Comment comment = getCurrentComment(position);
if (comment != null) { if (comment != null) {
if (mIsSingleCommentThreadMode && comment.getId().equals(mSingleCommentId)) { if (mIsSingleCommentThreadMode && comment.getId().equals(mSingleCommentId)) {
((CommentViewHolder) holder).itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor); holder.itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor);
} else if (comment.getAwards() != null && !comment.getAwards().equals("")) { } else if (comment.getAwards() != null && !comment.getAwards().equals("")) {
((CommentViewHolder) holder).itemView.setBackgroundColor(mAwardedCommentBackgroundColor); holder.itemView.setBackgroundColor(mAwardedCommentBackgroundColor);
} }
String authorPrefixed = "u/" + comment.getAuthor(); String authorPrefixed = "u/" + comment.getAuthor();
@ -591,9 +591,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.addAll(placeholderPosition, expandedComments); mVisibleComments.addAll(placeholderPosition, expandedComments);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(placeholderPosition + 2, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size()); notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition, expandedComments.size());
} }
} else { } else {
mVisibleComments.get(parentPosition).getChildren() mVisibleComments.get(parentPosition).getChildren()
@ -612,16 +612,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.remove(placeholderPosition); mVisibleComments.remove(placeholderPosition);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRemoved(placeholderPosition + 2);
} else {
notifyItemRemoved(placeholderPosition + 1); notifyItemRemoved(placeholderPosition + 1);
} else {
notifyItemRemoved(placeholderPosition);
} }
mVisibleComments.addAll(placeholderPosition, expandedComments); mVisibleComments.addAll(placeholderPosition, expandedComments);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(placeholderPosition + 2, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size()); notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition, expandedComments.size());
} }
} }
} else { } else {
@ -654,9 +654,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.addAll(placeholderPosition, expandedComments); mVisibleComments.addAll(placeholderPosition, expandedComments);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(placeholderPosition + 2, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size()); notifyItemRangeInserted(placeholderPosition + 1, expandedComments.size());
} else {
notifyItemRangeInserted(placeholderPosition, expandedComments.size());
} }
} }
@ -784,15 +784,15 @@ 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) {
if (mFullyCollapseComment) {
notifyItemChanged(position + 2);
}
notifyItemRangeRemoved(position + 3, allChildrenSize);
} else {
if (mFullyCollapseComment) { if (mFullyCollapseComment) {
notifyItemChanged(position + 1); notifyItemChanged(position + 1);
} }
notifyItemRangeRemoved(position + 2, allChildrenSize); notifyItemRangeRemoved(position + 2, allChildrenSize);
} else {
if (mFullyCollapseComment) {
notifyItemChanged(position);
}
notifyItemRangeRemoved(position + 1, allChildrenSize);
} }
} }
@ -801,32 +801,32 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
isInitiallyLoading = false; isInitiallyLoading = false;
isInitiallyLoadingFailed = false; isInitiallyLoadingFailed = false;
if (comments.size() == 0) { if (comments.size() == 0) {
notifyItemChanged(1); notifyItemChanged(0);
} else { } else {
notifyItemRemoved(1); notifyItemRemoved(0);
} }
} }
int sizeBefore = mVisibleComments.size(); int sizeBefore = mVisibleComments.size();
mVisibleComments.addAll(comments); mVisibleComments.addAll(comments);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(sizeBefore + 2, comments.size());
} else {
notifyItemRangeInserted(sizeBefore + 1, comments.size()); notifyItemRangeInserted(sizeBefore + 1, comments.size());
} else {
notifyItemRangeInserted(sizeBefore, comments.size());
} }
if (mHasMoreComments != hasMoreComments) { if (mHasMoreComments != hasMoreComments) {
if (hasMoreComments) { if (hasMoreComments) {
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemInserted(mVisibleComments.size() + 2);
} else {
notifyItemInserted(mVisibleComments.size() + 1); notifyItemInserted(mVisibleComments.size() + 1);
} else {
notifyItemInserted(mVisibleComments.size());
} }
} else { } else {
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRemoved(mVisibleComments.size() + 2);
} else {
notifyItemRemoved(mVisibleComments.size() + 1); notifyItemRemoved(mVisibleComments.size() + 1);
} else {
notifyItemRemoved(mVisibleComments.size());
} }
} }
} }
@ -865,18 +865,18 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(parentPosition).setExpanded(true); mVisibleComments.get(parentPosition).setExpanded(true);
mVisibleComments.addAll(parentPosition + 1, newList); mVisibleComments.addAll(parentPosition + 1, newList);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemChanged(parentPosition + 2);
notifyItemRangeInserted(parentPosition + 3, newList.size());
} else {
notifyItemChanged(parentPosition + 1); notifyItemChanged(parentPosition + 1);
notifyItemRangeInserted(parentPosition + 2, newList.size()); notifyItemRangeInserted(parentPosition + 2, newList.size());
} else {
notifyItemChanged(parentPosition);
notifyItemRangeInserted(parentPosition + 1, newList.size());
} }
} else { } else {
mVisibleComments.add(parentPosition + 1, comment); mVisibleComments.add(parentPosition + 1, comment);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemInserted(parentPosition + 3);
} else {
notifyItemInserted(parentPosition + 2); notifyItemInserted(parentPosition + 2);
} else {
notifyItemInserted(parentPosition + 1);
} }
} }
} }
@ -895,35 +895,35 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
int previousSize = mVisibleComments.size(); int previousSize = mVisibleComments.size();
mVisibleComments.clear(); mVisibleComments.clear();
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeRemoved(1, previousSize + 1); notifyItemRangeRemoved(0, previousSize + 1);
} else { } else {
notifyItemRangeRemoved(1, previousSize); notifyItemRangeRemoved(0, previousSize);
} }
} }
if (isInitiallyLoading || isInitiallyLoadingFailed || mVisibleComments.size() == 0) { if (isInitiallyLoading || isInitiallyLoadingFailed) {
isInitiallyLoading = true; isInitiallyLoading = true;
isInitiallyLoadingFailed = false; isInitiallyLoadingFailed = false;
notifyItemChanged(1); notifyItemChanged(0);
} else { } else {
isInitiallyLoading = true; isInitiallyLoading = true;
isInitiallyLoadingFailed = false; isInitiallyLoadingFailed = false;
notifyItemInserted(1); notifyItemInserted(0);
} }
} }
public void initiallyLoadCommentsFailed() { public void initiallyLoadCommentsFailed() {
isInitiallyLoading = false; isInitiallyLoading = false;
isInitiallyLoadingFailed = true; isInitiallyLoadingFailed = true;
notifyItemChanged(1); notifyItemChanged(0);
} }
public void loadMoreCommentsFailed() { public void loadMoreCommentsFailed() {
loadMoreCommentsFailed = true; loadMoreCommentsFailed = true;
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemChanged(mVisibleComments.size() + 2);
} else {
notifyItemChanged(mVisibleComments.size() + 1); notifyItemChanged(mVisibleComments.size() + 1);
} else {
notifyItemChanged(mVisibleComments.size());
} }
} }
@ -933,9 +933,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(position).setCommentMarkdown(commentContentMarkdown); mVisibleComments.get(position).setCommentMarkdown(commentContentMarkdown);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemChanged(position + 2);
} else {
notifyItemChanged(position + 1); notifyItemChanged(position + 1);
} else {
notifyItemChanged(position);
} }
} }
@ -945,16 +945,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(position).setAuthor("[deleted]"); mVisibleComments.get(position).setAuthor("[deleted]");
mVisibleComments.get(position).setCommentMarkdown("[deleted]"); mVisibleComments.get(position).setCommentMarkdown("[deleted]");
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemChanged(position + 2);
} else {
notifyItemChanged(position + 1); notifyItemChanged(position + 1);
} else {
notifyItemChanged(position);
} }
} else { } else {
mVisibleComments.remove(position); mVisibleComments.remove(position);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRemoved(position + 2);
} else {
notifyItemRemoved(position + 1); notifyItemRemoved(position + 1);
} else {
notifyItemRemoved(position);
} }
} }
} }
@ -1160,6 +1160,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick()); authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
moreButton.setOnClickListener(view -> { moreButton.setOnClickListener(view -> {
getItemCount();
Comment comment = getCurrentComment(this); Comment comment = getCurrentComment(this);
if (comment != null) { if (comment != null) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -1447,9 +1448,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.addAll(commentPosition + 1, newList); mVisibleComments.addAll(commentPosition + 1, newList);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(commentPosition + 3, newList.size());
} else {
notifyItemRangeInserted(commentPosition + 2, newList.size()); notifyItemRangeInserted(commentPosition + 2, newList.size());
} else {
notifyItemRangeInserted(commentPosition + 1, newList.size());
} }
expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp); expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
} }
@ -1578,11 +1579,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.addAll(commentPosition + 1, newList); mVisibleComments.addAll(commentPosition + 1, newList);
if (mIsSingleCommentThreadMode) { if (mIsSingleCommentThreadMode) {
notifyItemChanged(commentPosition + 2);
notifyItemRangeInserted(commentPosition + 3, newList.size());
} else {
notifyItemChanged(commentPosition + 1); notifyItemChanged(commentPosition + 1);
notifyItemRangeInserted(commentPosition + 2, newList.size()); notifyItemRangeInserted(commentPosition + 2, newList.size());
} else {
notifyItemChanged(commentPosition);
notifyItemRangeInserted(commentPosition + 1, newList.size());
} }
} }
} }

View File

@ -127,15 +127,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6; private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6;
private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7; private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7;
private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8; private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8;
private static final int VIEW_TYPE_FIRST_LOADING = 9;
private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 10;
private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 11;
private static final int VIEW_TYPE_COMMENT = 12;
private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 13;
private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 14;
private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 15;
private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 16;
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17;
private AppCompatActivity mActivity; private AppCompatActivity mActivity;
private ViewPostDetailFragment mFragment; private ViewPostDetailFragment mFragment;
@ -446,91 +437,35 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (position == 0) { switch (mPost.getPostType()) {
switch (mPost.getPostType()) { case Post.VIDEO_TYPE:
case Post.VIDEO_TYPE: if (mAutoplay) {
if (mAutoplay) { if (!mAutoplayNsfwVideos && mPost.isNSFW()) {
if (!mAutoplayNsfwVideos && mPost.isNSFW()) {
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
}
return VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY;
} else {
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
} }
case Post.GIF_TYPE: return VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY;
if (mAutoplay) { } else {
if (!mAutoplayNsfwVideos && mPost.isNSFW()) { return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; }
} case Post.GIF_TYPE:
return VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY; if (mAutoplay) {
} else { if (!mAutoplayNsfwVideos && mPost.isNSFW()) {
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
} }
case Post.IMAGE_TYPE: return VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY;
return VIEW_TYPE_POST_DETAIL_IMAGE;
case Post.LINK_TYPE:
return VIEW_TYPE_POST_DETAIL_LINK;
case Post.NO_PREVIEW_LINK_TYPE:
return VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK;
case Post.GALLERY_TYPE:
return VIEW_TYPE_POST_DETAIL_GALLERY;
default:
return VIEW_TYPE_POST_DETAIL_TEXT_TYPE;
}
}
if (mVisibleComments.size() == 0) {
if (position == 1) {
if (isInitiallyLoading) {
return VIEW_TYPE_FIRST_LOADING;
} else if (isInitiallyLoadingFailed) {
return VIEW_TYPE_FIRST_LOADING_FAILED;
} else { } else {
return VIEW_TYPE_NO_COMMENT_PLACEHOLDER; return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
} }
} case Post.IMAGE_TYPE:
} return VIEW_TYPE_POST_DETAIL_IMAGE;
case Post.LINK_TYPE:
if (mIsSingleCommentThreadMode) { return VIEW_TYPE_POST_DETAIL_LINK;
if (position == 1) { case Post.NO_PREVIEW_LINK_TYPE:
return VIEW_TYPE_VIEW_ALL_COMMENTS; return VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK;
} case Post.GALLERY_TYPE:
return VIEW_TYPE_POST_DETAIL_GALLERY;
if (position == mVisibleComments.size() + 2) { default:
if (mHasMoreComments) { return VIEW_TYPE_POST_DETAIL_TEXT_TYPE;
return VIEW_TYPE_IS_LOADING_MORE_COMMENTS;
} else {
return VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED;
}
}
Comment comment = mVisibleComments.get(position - 2);
if (comment.getPlaceholderType() == Comment.NOT_PLACEHOLDER) {
if (mFullyCollapseComment && !comment.isExpanded() && comment.hasExpandedBefore()) {
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
}
return VIEW_TYPE_COMMENT;
} else {
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
}
} else {
if (position == mVisibleComments.size() + 1) {
if (mHasMoreComments) {
return VIEW_TYPE_IS_LOADING_MORE_COMMENTS;
} else {
return VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED;
}
}
Comment comment = mVisibleComments.get(position - 1);
if (comment.getPlaceholderType() == Comment.NOT_PLACEHOLDER) {
if (mFullyCollapseComment && !comment.isExpanded() && comment.hasExpandedBefore()) {
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
}
return VIEW_TYPE_COMMENT;
} else {
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
}
} }
} }
@ -1065,224 +1000,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
notifyItemChanged(0); notifyItemChanged(0);
} }
private int getParentPosition(int position) {
if (position >= 0 && position < mVisibleComments.size()) {
int childDepth = mVisibleComments.get(position).getDepth();
for (int i = position; i >= 0; i--) {
if (mVisibleComments.get(i).getDepth() < childDepth) {
return i;
}
}
}
return -1;
}
private void expandChildren(ArrayList<Comment> comments, ArrayList<Comment> newList, int position) {
if (comments != null && comments.size() > 0) {
newList.addAll(position, comments);
for (int i = 0; i < comments.size(); i++) {
position++;
if (comments.get(i).getChildren() != null && comments.get(i).getChildren().size() > 0) {
expandChildren(comments.get(i).getChildren(), newList, position);
position = position + comments.get(i).getChildren().size();
}
comments.get(i).setExpanded(true);
}
}
}
private void collapseChildren(int position) {
mVisibleComments.get(position).setExpanded(false);
int depth = mVisibleComments.get(position).getDepth();
int allChildrenSize = 0;
for (int i = position + 1; i < mVisibleComments.size(); i++) {
if (mVisibleComments.get(i).getDepth() > depth) {
allChildrenSize++;
} else {
break;
}
}
if (allChildrenSize > 0) {
mVisibleComments.subList(position + 1, position + 1 + allChildrenSize).clear();
}
if (mIsSingleCommentThreadMode) {
if (mFullyCollapseComment) {
notifyItemChanged(position + 2);
}
notifyItemRangeRemoved(position + 3, allChildrenSize);
} else {
if (mFullyCollapseComment) {
notifyItemChanged(position + 1);
}
notifyItemRangeRemoved(position + 2, allChildrenSize);
}
}
public void addComments(@NonNull ArrayList<Comment> comments, boolean hasMoreComments) {
if (mVisibleComments.size() == 0) {
isInitiallyLoading = false;
isInitiallyLoadingFailed = false;
if (comments.size() == 0) {
notifyItemChanged(1);
} else {
notifyItemRemoved(1);
}
}
int sizeBefore = mVisibleComments.size();
mVisibleComments.addAll(comments);
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(sizeBefore + 2, comments.size());
} else {
notifyItemRangeInserted(sizeBefore + 1, comments.size());
}
if (mHasMoreComments != hasMoreComments) {
if (hasMoreComments) {
if (mIsSingleCommentThreadMode) {
notifyItemInserted(mVisibleComments.size() + 2);
} else {
notifyItemInserted(mVisibleComments.size() + 1);
}
} else {
if (mIsSingleCommentThreadMode) {
notifyItemRemoved(mVisibleComments.size() + 2);
} else {
notifyItemRemoved(mVisibleComments.size() + 1);
}
}
}
mHasMoreComments = hasMoreComments;
}
public void addComment(Comment comment) {
if (mVisibleComments.size() == 0 || isInitiallyLoadingFailed) {
notifyItemRemoved(1);
}
mVisibleComments.add(0, comment);
if (isInitiallyLoading) {
notifyItemInserted(2);
} else {
notifyItemInserted(1);
}
}
public void addChildComment(Comment comment, String parentFullname, int parentPosition) {
if (!parentFullname.equals(mVisibleComments.get(parentPosition).getFullName())) {
for (int i = 0; i < mVisibleComments.size(); i++) {
if (parentFullname.equals(mVisibleComments.get(i).getFullName())) {
parentPosition = i;
break;
}
}
}
mVisibleComments.get(parentPosition).addChild(comment);
mVisibleComments.get(parentPosition).setHasReply(true);
if (!mVisibleComments.get(parentPosition).isExpanded()) {
ArrayList<Comment> newList = new ArrayList<>();
expandChildren(mVisibleComments.get(parentPosition).getChildren(), newList, 0);
mVisibleComments.get(parentPosition).setExpanded(true);
mVisibleComments.addAll(parentPosition + 1, newList);
if (mIsSingleCommentThreadMode) {
notifyItemChanged(parentPosition + 2);
notifyItemRangeInserted(parentPosition + 3, newList.size());
} else {
notifyItemChanged(parentPosition + 1);
notifyItemRangeInserted(parentPosition + 2, newList.size());
}
} else {
mVisibleComments.add(parentPosition + 1, comment);
if (mIsSingleCommentThreadMode) {
notifyItemInserted(parentPosition + 3);
} else {
notifyItemInserted(parentPosition + 2);
}
}
}
public void setSingleComment(String singleCommentId, boolean isSingleCommentThreadMode) {
mSingleCommentId = singleCommentId;
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
}
public ArrayList<Comment> getVisibleComments() {
return mVisibleComments;
}
public void initiallyLoading() {
if (mVisibleComments.size() != 0) {
int previousSize = mVisibleComments.size();
mVisibleComments.clear();
if (mIsSingleCommentThreadMode) {
notifyItemRangeRemoved(1, previousSize + 1);
} else {
notifyItemRangeRemoved(1, previousSize);
}
}
if (isInitiallyLoading || isInitiallyLoadingFailed || mVisibleComments.size() == 0) {
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
notifyItemChanged(1);
} else {
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
notifyItemInserted(1);
}
}
public void initiallyLoadCommentsFailed() {
isInitiallyLoading = false;
isInitiallyLoadingFailed = true;
notifyItemChanged(1);
}
public void loadMoreCommentsFailed() {
loadMoreCommentsFailed = true;
if (mIsSingleCommentThreadMode) {
notifyItemChanged(mVisibleComments.size() + 2);
} else {
notifyItemChanged(mVisibleComments.size() + 1);
}
}
public void editComment(String commentAuthor, String commentContentMarkdown, int position) {
if (commentAuthor != null)
mVisibleComments.get(position).setAuthor(commentAuthor);
mVisibleComments.get(position).setCommentMarkdown(commentContentMarkdown);
if (mIsSingleCommentThreadMode) {
notifyItemChanged(position + 2);
} else {
notifyItemChanged(position + 1);
}
}
public void deleteComment(int position) {
if (mVisibleComments != null && position >= 0 && position < mVisibleComments.size()) {
if (mVisibleComments.get(position).hasReply()) {
mVisibleComments.get(position).setAuthor("[deleted]");
mVisibleComments.get(position).setCommentMarkdown("[deleted]");
if (mIsSingleCommentThreadMode) {
notifyItemChanged(position + 2);
} else {
notifyItemChanged(position + 1);
}
} else {
mVisibleComments.remove(position);
if (mIsSingleCommentThreadMode) {
notifyItemRemoved(position + 2);
} else {
notifyItemRemoved(position + 1);
}
}
}
}
public void setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(boolean needBlurNsfw, boolean doNotBlurNsfwInNsfwSubreddits) { public void setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(boolean needBlurNsfw, boolean doNotBlurNsfwInNsfwSubreddits) {
mNeedBlurNsfw = needBlurNsfw; mNeedBlurNsfw = needBlurNsfw;
mDoNotBlurNsfwInNsfwSubreddits = doNotBlurNsfwInNsfwSubreddits; mDoNotBlurNsfwInNsfwSubreddits = doNotBlurNsfwInNsfwSubreddits;
@ -2044,7 +1761,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override @Override
public int getPlayerOrder() { public int getPlayerOrder() {
return getBindingAdapterPosition(); return 0;
} }
} }

View File

@ -5,6 +5,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -126,8 +127,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@BindView(R.id.swipe_refresh_layout_view_post_detail_fragment) @BindView(R.id.swipe_refresh_layout_view_post_detail_fragment)
SwipeRefreshLayout mSwipeRefreshLayout; SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_view_post_detail_fragment) @BindView(R.id.post_detail_recycler_view_view_post_detail_fragment)
CustomToroContainer mRecyclerView; CustomToroContainer mRecyclerView;
RecyclerView mCommentsRecyclerView;
@BindView(R.id.fetch_post_info_linear_layout_view_post_detail_fragment) @BindView(R.id.fetch_post_info_linear_layout_view_post_detail_fragment)
LinearLayout mFetchPostInfoLinearLayout; LinearLayout mFetchPostInfoLinearLayout;
@BindView(R.id.fetch_post_info_image_view_view_post_detail_fragment) @BindView(R.id.fetch_post_info_image_view_view_post_detail_fragment)
@ -216,7 +218,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private LinearLayoutManager mLinearLayoutManager; private LinearLayoutManager mLinearLayoutManager;
private ConcatAdapter mConcatAdapter; private ConcatAdapter mConcatAdapter;
private PostDetailRecyclerViewAdapter mPostAdapter; private PostDetailRecyclerViewAdapter mPostAdapter;
private CommentsRecyclerViewAdapter mCommentAdapter; private CommentsRecyclerViewAdapter mCommentsAdapter;
private RecyclerView.SmoothScroller mSmoothScroller; private RecyclerView.SmoothScroller mSmoothScroller;
private Drawable mSavedIcon; private Drawable mSavedIcon;
private Drawable mUnsavedIcon; private Drawable mUnsavedIcon;
@ -277,8 +279,15 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mGlide = Glide.with(this); mGlide = Glide.with(this);
mLocale = getResources().getConfiguration().locale; mLocale = getResources().getConfiguration().locale;
mLinearLayoutManager = new LinearLayoutManager(activity); if (getResources().getBoolean(R.bool.isTablet) || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mRecyclerView.setLayoutManager(mLinearLayoutManager); mLinearLayoutManager = new LinearLayoutManager(activity);
mCommentsRecyclerView = rootView.findViewById(R.id.comments_recycler_view_view_post_detail_fragment);
mCommentsRecyclerView.setLayoutManager(mLinearLayoutManager);
mRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
} else {
mLinearLayoutManager = new LinearLayoutManager(activity);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
}
if (children != null && children.size() > 0) { if (children != null && children.size() > 0) {
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@ -391,8 +400,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (touchHelper != null) { if (touchHelper != null) {
touchHelper.attachToRecyclerView(null); touchHelper.attachToRecyclerView(null);
touchHelper.attachToRecyclerView(mRecyclerView); touchHelper.attachToRecyclerView(mRecyclerView);
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.onItemSwipe(viewHolder, direction, swipeLeftAction, swipeRightAction); mCommentsAdapter.onItemSwipe(viewHolder, direction, swipeLeftAction, swipeRightAction);
} }
} }
} }
@ -531,7 +540,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
} }
}); });
mCommentAdapter = new CommentsRecyclerViewAdapter(activity, mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit,
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mSharedPreferences, isSingleCommentThreadMode, mSharedPreferences,
@ -549,8 +558,14 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
fetchMoreComments(); fetchMoreComments();
} }
}); });
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentAdapter); if (mCommentsRecyclerView != null) {
mRecyclerView.setAdapter(mConcatAdapter); mRecyclerView.setAdapter(mPostAdapter);
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
} else {
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
mRecyclerView.setAdapter(mConcatAdapter);
}
if (comments == null) { if (comments == null) {
fetchCommentsRespectRecommendedSort(false); fetchCommentsRespectRecommendedSort(false);
@ -561,7 +576,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else if (isFetchingComments) { } else if (isFetchingComments) {
fetchCommentsRespectRecommendedSort(false); fetchCommentsRespectRecommendedSort(false);
} else { } else {
mCommentAdapter.addComments(comments, hasMoreChildren); mCommentsAdapter.addComments(comments, hasMoreChildren);
if (isLoadingMoreChildren) { if (isLoadingMoreChildren) {
isLoadingMoreChildren = false; isLoadingMoreChildren = false;
fetchMoreComments(); fetchMoreComments();
@ -670,28 +685,28 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
public void addComment(Comment comment) { public void addComment(Comment comment) {
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.addComment(comment); mCommentsAdapter.addComment(comment);
} }
} }
public void addChildComment(Comment comment, String parentFullname, int parentPosition) { public void addChildComment(Comment comment, String parentFullname, int parentPosition) {
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.addChildComment(comment, parentFullname, parentPosition); mCommentsAdapter.addChildComment(comment, parentFullname, parentPosition);
} }
} }
public void editComment(String commentAuthor, String commentContentMarkdown, int position) { public void editComment(String commentAuthor, String commentContentMarkdown, int position) {
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.editComment(commentAuthor, mCommentsAdapter.editComment(commentAuthor,
commentContentMarkdown, commentContentMarkdown,
position); position);
} }
} }
public void awardGiven(String awardsHTML, int awardCount, int position) { public void awardGiven(String awardsHTML, int awardCount, int position) {
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.giveAward(awardsHTML, awardCount, position); mCommentsAdapter.giveAward(awardsHTML, awardCount, position);
} }
} }
@ -743,8 +758,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
public void saveComment(int position, boolean isSaved) { public void saveComment(int position, boolean isSaved) {
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
mCommentAdapter.setSaveComment(position, isSaved); mCommentsAdapter.setSaveComment(position, isSaved);
} }
} }
@ -1009,7 +1024,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (mCommentAdapter != null && mRecyclerView != null) { if (mRecyclerView != null) {
mRecyclerView.onWindowVisibilityChanged(View.VISIBLE); mRecyclerView.onWindowVisibilityChanged(View.VISIBLE);
} }
} }
@ -1017,7 +1032,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
if (mCommentAdapter != null && mRecyclerView != null) { if (mRecyclerView != null) {
mRecyclerView.onWindowVisibilityChanged(View.GONE); mRecyclerView.onWindowVisibilityChanged(View.GONE);
} }
} }
@ -1025,7 +1040,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void onSaveInstanceState(@NonNull Bundle outState) { public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
comments = mCommentAdapter == null ? null : mCommentAdapter.getVisibleComments(); comments = mCommentsAdapter == null ? null : mCommentsAdapter.getVisibleComments();
Bridge.saveInstanceState(this, outState); Bridge.saveInstanceState(this, outState);
} }
@ -1107,7 +1122,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
}); });
mCommentAdapter = new CommentsRecyclerViewAdapter(activity, mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, ViewPostDetailFragment.this, mCustomThemeWrapper, mRetrofit, mOauthRetrofit,
mAccessToken, mAccountName, mPost, mLocale, mAccessToken, mAccountName, mPost, mLocale,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
@ -1125,8 +1140,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
fetchMoreComments(); fetchMoreComments();
} }
}); });
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentAdapter); if (mCommentsRecyclerView != null) {
mRecyclerView.setAdapter(mConcatAdapter); mRecyclerView.setAdapter(mPostAdapter);
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
} else {
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
mRecyclerView.setAdapter(mConcatAdapter);
}
if (mRespectSubredditRecommendedSortType) { if (mRespectSubredditRecommendedSortType) {
fetchCommentsRespectRecommendedSort(false); fetchCommentsRespectRecommendedSort(false);
@ -1138,7 +1158,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
ViewPostDetailFragment.this.children = moreChildrenFullnames; ViewPostDetailFragment.this.children = moreChildrenFullnames;
hasMoreChildren = children.size() != 0; hasMoreChildren = children.size() != 0;
mCommentAdapter.addComments(expandedComments, hasMoreChildren); mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
if (children.size() > 0) { if (children.size() > 0) {
mRecyclerView.clearOnScrollListeners(); mRecyclerView.clearOnScrollListeners();
@ -1189,7 +1209,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void onParseCommentFailed() { public void onParseCommentFailed() {
mCommentAdapter.initiallyLoadCommentsFailed(); mCommentsAdapter.initiallyLoadCommentsFailed();
} }
}); });
} }
@ -1251,8 +1271,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private void fetchComments(boolean changeRefreshState, boolean checkSortState, String sortType) { private void fetchComments(boolean changeRefreshState, boolean checkSortState, String sortType) {
isFetchingComments = true; isFetchingComments = true;
mCommentAdapter.setSingleComment(mSingleCommentId, isSingleCommentThreadMode); mCommentsAdapter.setSingleComment(mSingleCommentId, isSingleCommentThreadMode);
mCommentAdapter.initiallyLoading(); mCommentsAdapter.initiallyLoading();
String commentId = null; String commentId = null;
if (isSingleCommentThreadMode) { if (isSingleCommentThreadMode) {
commentId = mSingleCommentId; commentId = mSingleCommentId;
@ -1276,7 +1296,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
comments = expandedComments; comments = expandedComments;
hasMoreChildren = children.size() != 0; hasMoreChildren = children.size() != 0;
mCommentAdapter.addComments(expandedComments, hasMoreChildren); mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
if (children.size() > 0) { if (children.size() > 0) {
mRecyclerView.clearOnScrollListeners(); mRecyclerView.clearOnScrollListeners();
@ -1341,7 +1361,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
return; return;
} }
mCommentAdapter.initiallyLoadCommentsFailed(); mCommentsAdapter.initiallyLoadCommentsFailed();
if (changeRefreshState) { if (changeRefreshState) {
isRefreshing = false; isRefreshing = false;
} }
@ -1366,7 +1386,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void onFetchMoreCommentSuccess(ArrayList<Comment> expandedComments, int childrenStartingIndex) { public void onFetchMoreCommentSuccess(ArrayList<Comment> expandedComments, int childrenStartingIndex) {
hasMoreChildren = childrenStartingIndex < children.size(); hasMoreChildren = childrenStartingIndex < children.size();
mCommentAdapter.addComments(expandedComments, hasMoreChildren); mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
mChildrenStartingIndex = childrenStartingIndex; mChildrenStartingIndex = childrenStartingIndex;
isLoadingMoreChildren = false; isLoadingMoreChildren = false;
loadMoreChildrenSuccess = true; loadMoreChildrenSuccess = true;
@ -1376,7 +1396,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public void onFetchMoreCommentFailed() { public void onFetchMoreCommentFailed() {
isLoadingMoreChildren = false; isLoadingMoreChildren = false;
loadMoreChildrenSuccess = false; loadMoreChildrenSuccess = false;
mCommentAdapter.loadMoreCommentsFailed(); mCommentsAdapter.loadMoreCommentsFailed();
} }
}); });
} }
@ -1599,7 +1619,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Override @Override
public void deleteSuccess() { public void deleteSuccess() {
Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
mCommentAdapter.deleteComment(position); mCommentsAdapter.deleteComment(position);
} }
@Override @Override
@ -1619,7 +1639,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
new FetchRemovedComment.FetchRemovedCommentListener() { new FetchRemovedComment.FetchRemovedCommentListener() {
@Override @Override
public void fetchSuccess(Comment comment) { public void fetchSuccess(Comment comment) {
mCommentAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position); mCommentsAdapter.editComment(comment.getAuthor(), comment.getCommentMarkdown(), position);
} }
@Override @Override
@ -1639,8 +1659,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public void scrollToNextParentComment() { public void scrollToNextParentComment() {
if (mLinearLayoutManager != null) { if (mLinearLayoutManager != null) {
int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
int nextParentPosition = mCommentAdapter.getNextParentCommentPosition(currentPosition); int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(currentPosition);
if (nextParentPosition < 0) { if (nextParentPosition < 0) {
return; return;
} }
@ -1656,8 +1676,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public void scrollToPreviousParentComment() { public void scrollToPreviousParentComment() {
if (mLinearLayoutManager != null) { if (mLinearLayoutManager != null) {
int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
if (mCommentAdapter != null) { if (mCommentsAdapter != null) {
int nextParentPosition = mCommentAdapter.getPreviousParentCommentPosition(currentPosition); int nextParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(currentPosition);
if (nextParentPosition < 0) { if (nextParentPosition < 0) {
return; return;
} }
@ -1725,7 +1745,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mPostAdapter != null) { if (mPostAdapter != null) {
mPostAdapter.setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(event.needBlurNSFW, event.doNotBlurNsfwInNsfwSubreddits); mPostAdapter.setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(event.needBlurNSFW, event.doNotBlurNsfwInNsfwSubreddits);
} }
refreshAdapter(); if (mCommentsRecyclerView != null) {
refreshAdapter(mRecyclerView, mConcatAdapter);
} else {
refreshAdapter(mRecyclerView, mPostAdapter);
}
} }
@Subscribe @Subscribe
@ -1733,23 +1757,27 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mPostAdapter != null) { if (mPostAdapter != null) {
mPostAdapter.setBlurSpoiler(event.needBlurSpoiler); mPostAdapter.setBlurSpoiler(event.needBlurSpoiler);
} }
refreshAdapter(); if (mCommentsRecyclerView != null) {
refreshAdapter(mRecyclerView, mConcatAdapter);
} else {
refreshAdapter(mRecyclerView, mPostAdapter);
}
} }
private void refreshAdapter() { private void refreshAdapter(RecyclerView recyclerView, RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
int previousPosition = -1; int previousPosition = -1;
if (mLinearLayoutManager != null) { if (recyclerView.getLayoutManager() != null) {
previousPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); previousPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
} }
RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager(); RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
mRecyclerView.setAdapter(null); recyclerView.setAdapter(null);
mRecyclerView.setLayoutManager(null); recyclerView.setLayoutManager(null);
mRecyclerView.setAdapter(mConcatAdapter); recyclerView.setAdapter(adapter);
mRecyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
if (previousPosition > 0) { if (previousPosition > 0) {
mRecyclerView.scrollToPosition(previousPosition); recyclerView.scrollToPosition(previousPosition);
} }
} }
@ -1769,7 +1797,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
if (stateChanged) { if (stateChanged) {
refreshAdapter(); if (mCommentsRecyclerView != null) {
refreshAdapter(mRecyclerView, mConcatAdapter);
} else {
refreshAdapter(mRecyclerView, mPostAdapter);
}
} }
} }
} }

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragments.ViewPostDetailFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<ml.docilealligator.infinityforreddit.customviews.CustomToroContainer
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="144dp"
android:clipToPadding="false" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="144dp"
android:clipToPadding="false" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/fetch_post_info_image_view_view_post_detail_fragment"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fetch_post_info_text_view_view_post_detail_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragments.ViewPostDetailFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<ml.docilealligator.infinityforreddit.customviews.CustomToroContainer
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="144dp"
android:clipToPadding="false" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="144dp"
android:clipToPadding="false" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/fetch_post_info_image_view_view_post_detail_fragment"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fetch_post_info_text_view_view_post_detail_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
</FrameLayout>

View File

@ -13,9 +13,9 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ml.docilealligator.infinityforreddit.customviews.CustomToroContainer <ml.docilealligator.infinityforreddit.customviews.CustomToroContainer
android:id="@+id/recycler_view_view_post_detail_fragment" android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:paddingBottom="144dp" android:paddingBottom="144dp"
android:clipToPadding="false" /> android:clipToPadding="false" />