aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-04-16 14:22:29 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-04-16 14:22:29 +0000
commit58efcce3a09f23b01dbd199fc422f44a0ba79dbc (patch)
tree25f61dc0d52d9a7f075045197ca2a8b85c3b1657 /app/src/main/java
parent504b005cf7b9d9881b6780ede5f75b7bcf2c6cd2 (diff)
downloadinfinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar.gz
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar.bz2
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar.lz
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar.xz
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.tar.zst
infinity-for-reddit-58efcce3a09f23b01dbd199fc422f44a0ba79dbc.zip
Show author flair for posts.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java19
1 files changed, 19 insertions, 0 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 250d17d3..c003a876 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -492,6 +492,22 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
}
+ if (mPost.getAuthorFlairHTML() != null && !mPost.getAuthorFlairHTML().equals("")) {
+ ((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
+ Spannable flairHTML;
+ GlideImageGetter glideImageGetter = new GlideImageGetter(((PostDetailViewHolder) holder).mAuthorFlairTextView);
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
+ flairHTML = (Spannable) Html.fromHtml(mPost.getAuthorFlairHTML(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
+ } else {
+ flairHTML = (Spannable) Html.fromHtml(mPost.getAuthorFlairHTML(), glideImageGetter, null);
+ }
+ ((PostDetailViewHolder) holder).mAuthorFlairTextView.setText(flairHTML);
+ ((PostDetailViewHolder) holder).mAuthorFlairTextView.setOnClickListener(view -> ((PostDetailViewHolder) holder).mUserTextView.performClick());
+ } else if (mPost.getAuthorFlair() != null && !mPost.getAuthorFlair().equals("")) {
+ ((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
+ ((PostDetailViewHolder) holder).mAuthorFlairTextView.setText(mPost.getAuthorFlair());
+ }
+
switch (mPost.getVoteType()) {
case 1:
//Upvote
@@ -1824,6 +1840,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
TextView mSubredditTextView;
@BindView(R.id.user_text_view_item_post_detail)
TextView mUserTextView;
+ @BindView(R.id.author_flair_text_view_item_post_detail)
+ TextView mAuthorFlairTextView;
@BindView(R.id.post_time_text_view_item_post_detail)
TextView mPostTimeTextView;
@BindView(R.id.title_text_view_item_post_detail)
@@ -2093,6 +2111,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
itemView.setBackgroundColor(mCardViewColor);
mSubredditTextView.setTextColor(mSubredditColor);
mUserTextView.setTextColor(mUsernameColor);
+ mAuthorFlairTextView.setTextColor(mAuthorFlairTextColor);
mPostTimeTextView.setTextColor(mSecondaryTextColor);
mTitleTextView.setTextColor(mPostTitleColor);
mTypeTextView.setBackgroundColor(mPostTypeBackgroundColor);