From 9cbe542c8503c53f9e5a2836ce1e22c499e538bc Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 16 Apr 2020 16:10:07 +0800 Subject: [PATCH] Show all post awards. --- .../CommentAndPostRecyclerViewAdapter.java | 23 +++++--- .../Adapter/PostRecyclerViewAdapter.java | 58 ++++++++++++------- .../infinityforreddit/ParsePost.java | 53 +++++++++++------ .../infinityforreddit/Post/Post.java | 39 +++++++------ .../infinityforreddit/Utils/JSONUtils.java | 2 + app/src/main/res/layout/item_post.xml | 16 ++--- app/src/main/res/layout/item_post_compact.xml | 16 ++--- app/src/main/res/layout/item_post_detail.xml | 6 ++ 8 files changed, 127 insertions(+), 86 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index d103ce96..4338209e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -545,12 +545,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter 0) { - ((PostDetailViewHolder) holder).mGildedNumberTextView.setVisibility(View.VISIBLE); - String gildedNumber = mActivity.getResources().getString(R.string.gilded_count, mPost.getGilded()); - ((PostDetailViewHolder) holder).mGildedNumberTextView.setText(gildedNumber); - } - if (mPost.isArchived()) { ((PostDetailViewHolder) holder).mArchivedImageView.setVisibility(View.VISIBLE); } @@ -575,6 +569,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter= android.os.Build.VERSION_CODES.N) { + awardsHTML = (Spannable) Html.fromHtml(mPost.getAwards(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); + } else { + awardsHTML = (Spannable) Html.fromHtml(mPost.getAwards(), glideImageGetter, null); + } + ((PostDetailViewHolder) holder).mAwardsTextView.setText(awardsHTML); + } + if (mPost.isNSFW()) { ((PostDetailViewHolder) holder).mNSFWTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredThingActivity.class); @@ -1809,8 +1815,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { @@ -418,12 +418,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0) { - ((PostViewHolder) holder).gildedNumberTextView.setVisibility(View.VISIBLE); - String gildedNumber = mActivity.getResources().getString(R.string.gilded_count, gilded); - ((PostViewHolder) holder).gildedNumberTextView.setText(gildedNumber); - } - if (post.isLocked()) { ((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); } @@ -457,6 +451,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter= android.os.Build.VERSION_CODES.N) { + awardsHTML = (Spannable) Html.fromHtml(awards, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); + } else { + awardsHTML = (Spannable) Html.fromHtml(awards, glideImageGetter, null); + } + ((PostViewHolder) holder).awardsTextView.setText(awardsHTML); + } + switch (voteType) { case 1: //Upvoted @@ -810,10 +816,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { @@ -983,12 +989,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0) { - ((PostCompactViewHolder) holder).gildedNumberTextView.setVisibility(View.VISIBLE); - String gildedNumber = mActivity.getResources().getString(R.string.gilded_count, gilded); - ((PostCompactViewHolder) holder).gildedNumberTextView.setText(gildedNumber); - } - if (post.isLocked()) { ((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); } @@ -1022,6 +1022,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter= android.os.Build.VERSION_CODES.N) { + awardsHTML = (Spannable) Html.fromHtml(awards, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); + } else { + awardsHTML = (Spannable) Html.fromHtml(awards, glideImageGetter, null); + } + ((PostCompactViewHolder) holder).awardsTextView.setText(awardsHTML); + } + switch (voteType) { case 1: //Upvoted @@ -1517,13 +1529,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter