diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-06-26 04:36:39 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-06-26 04:36:39 +0000 |
commit | cfe0b357df14d57264dd28047bc5a362fc3c5fe6 (patch) | |
tree | 1c56913dca18b3f161d5e8db71b62f5db501ef1c /app | |
parent | a22b491a30a3ced7953883f0f0dfc3b783eef281 (diff) | |
download | infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar.gz infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar.bz2 infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar.lz infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar.xz infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.tar.zst infinity-for-reddit-cfe0b357df14d57264dd28047bc5a362fc3c5fe6.zip |
Fixed wrong width of the vertical block of the load more comment placeholder.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java | 33 | ||||
-rw-r--r-- | app/src/main/res/layout/item_load_more_comments_placeholder.xml | 2 |
2 files changed, 16 insertions, 19 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java index b357e35a..65f385d7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java @@ -320,17 +320,12 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH break; } } else if(holder.getItemViewType() == VIEW_TYPE_COMMENT) { - CommentData commentItem; - if(isInitiallyLoading || isInitiallyLoadingFailed) { - commentItem = mVisibleComments.get(holder.getAdapterPosition() - 2); - } else { - commentItem = mVisibleComments.get(holder.getAdapterPosition() - 1); - } + CommentData comment = mVisibleComments.get(holder.getAdapterPosition() - 1); - String authorPrefixed = "u/" + commentItem.getAuthor(); + String authorPrefixed = "u/" + comment.getAuthor(); ((CommentViewHolder) holder).authorTextView.setText(authorPrefixed); - ((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime()); + ((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime()); SpannableConfiguration spannableConfiguration = SpannableConfiguration.builder(mActivity).linkResolver((view, link) -> { if (link.startsWith("/u/") || link.startsWith("u/")) { @@ -351,13 +346,15 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH } }).build(); - ((CommentViewHolder) holder).commentMarkdownView.setMarkdown(spannableConfiguration, commentItem.getCommentContent()); - ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore())); + ((CommentViewHolder) holder).commentMarkdownView.setMarkdown(spannableConfiguration, comment.getCommentContent()); + ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore())); - ((CommentViewHolder) holder).verticalBlock.getLayoutParams().width = commentItem.getDepth() * 16; + ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams(); + params.width = comment.getDepth() * 16; + ((CommentViewHolder) holder).verticalBlock.setLayoutParams(params); - if (commentItem.hasReply()) { - if(commentItem.isExpanded()) { + if (comment.hasReply()) { + if(comment.isExpanded()) { ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp); } else { ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp); @@ -365,7 +362,7 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH ((CommentViewHolder) holder).expandButton.setVisibility(View.VISIBLE); } - switch (commentItem.getVoteType()) { + switch (comment.getVoteType()) { case 1: ((CommentViewHolder) holder).upvoteButton .setColorFilter(ContextCompat.getColor(mActivity, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); @@ -379,7 +376,10 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH CommentData placeholder; placeholder = mVisibleComments.get(holder.getAdapterPosition() - 1); - ((LoadMoreCommentViewHolder) holder).verticalBlock.getLayoutParams().width = placeholder.getDepth() * 16; + ViewGroup.LayoutParams params = ((LoadMoreCommentViewHolder) holder).verticalBlock.getLayoutParams(); + params.width = placeholder.getDepth() * 16; + ((LoadMoreCommentViewHolder) holder).verticalBlock.setLayoutParams(params); + if(placeholder.isLoadingMoreChildren()) { ((LoadMoreCommentViewHolder) holder).placeholderTextView.setText(R.string.loading); } else if(placeholder.isLoadMoreChildrenFailed()) { @@ -467,9 +467,6 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH children.get(i).setExpanded(false); } mVisibleComments.addAll(position + 1, children); - /*for(int i = position + 1; i <= position + children.size(); i++) { - mVisibleComments.get(i).setExpanded(false); - }*/ notifyItemRangeInserted(position + 2, children.size()); } } diff --git a/app/src/main/res/layout/item_load_more_comments_placeholder.xml b/app/src/main/res/layout/item_load_more_comments_placeholder.xml index 601a30d6..5a006ff5 100644 --- a/app/src/main/res/layout/item_load_more_comments_placeholder.xml +++ b/app/src/main/res/layout/item_load_more_comments_placeholder.xml @@ -9,7 +9,7 @@ <View android:id="@+id/vertical_block_item_load_more_comments" - android:layout_width="0dp" + android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@color/textColorPrimaryDark" /> |