diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-04-16 12:04:32 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-04-16 12:04:32 +0000 |
commit | f0125edd233bb433c2d59cc04144be1e4a65bd0e (patch) | |
tree | 9d4be209107c25e1ff811f82a33ec6004679384c /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | 9cbe542c8503c53f9e5a2836ce1e22c499e538bc (diff) | |
download | infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar.gz infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar.bz2 infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar.lz infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar.xz infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.tar.zst infinity-for-reddit-f0125edd233bb433c2d59cc04144be1e4a65bd0e.zip |
Show author flair (not richtext) for comments.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
4 files changed, 23 insertions, 9 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 4338209e..49bc1f3e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -826,17 +826,20 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy String authorPrefixed = "u/" + comment.getAuthor(); ((CommentViewHolder) holder).authorTextView.setText(authorPrefixed); - if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) { + if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) { ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE); Spannable flairHTML; GlideImageGetter glideImageGetter = new GlideImageGetter(((CommentViewHolder) holder).authorFlairTextView); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlair(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); + flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlairHTML(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); } else { - flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlair(), glideImageGetter, null); + flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlairHTML(), glideImageGetter, null); } ((CommentViewHolder) holder).authorFlairTextView.setText(flairHTML); ((CommentViewHolder) holder).authorFlairTextView.setOnClickListener(view -> ((CommentViewHolder) holder).authorTextView.performClick()); + } else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) { + ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE); + ((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair()); } if (comment.isSubmitter()) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java index 2396aa9b..0b37ed83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java @@ -26,6 +26,7 @@ public class CommentData implements Parcelable { private String fullName; private String author; private String authorFlair; + private String authorFlairHTML; private String linkAuthor; private String commentTime; private long commentTimeMillis; @@ -52,15 +53,17 @@ public class CommentData implements Parcelable { private boolean isLoadingMoreChildren; private boolean loadMoreChildrenFailed; - public CommentData(String id, String fullName, String author, String authorFlair, String linkAuthor, - String commentTime, long commentTimeMillis, String commentMarkdown, - String commentRawText, String linkId, String subredditName, String parentId, - int score, int voteType, boolean isSubmitter, String distinguished, String permalink, - int depth, boolean collapsed, boolean hasReply, boolean scoreHidden, boolean saved) { + public CommentData(String id, String fullName, String author, String authorFlair, + String authorFlairHTML, String linkAuthor, String commentTime, + long commentTimeMillis, String commentMarkdown, String commentRawText, + String linkId, String subredditName, String parentId, int score, int voteType, + boolean isSubmitter, String distinguished, String permalink, int depth, + boolean collapsed, boolean hasReply, boolean scoreHidden, boolean saved) { this.id = id; this.fullName = fullName; this.author = author; this.authorFlair = authorFlair; + this.authorFlairHTML = authorFlairHTML; this.linkAuthor = linkAuthor; this.commentTime = commentTime; this.commentTimeMillis = commentTimeMillis; @@ -97,6 +100,7 @@ public class CommentData implements Parcelable { fullName = in.readString(); author = in.readString(); authorFlair = in.readString(); + authorFlairHTML = in.readString(); linkAuthor = in.readString(); commentTime = in.readString(); commentTimeMillis = in.readLong(); @@ -143,6 +147,10 @@ public class CommentData implements Parcelable { return authorFlair; } + public String getAuthorFlairHTML() { + return authorFlairHTML; + } + public String getLinkAuthor() { return linkAuthor; } @@ -337,6 +345,7 @@ public class CommentData implements Parcelable { parcel.writeString(fullName); parcel.writeString(author); parcel.writeString(authorFlair); + parcel.writeString(authorFlairHTML); parcel.writeString(linkAuthor); parcel.writeString(commentTime); parcel.writeLong(commentTimeMillis); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 0891e7f1..fc5b829c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -131,6 +131,7 @@ public class ParseComment { } } } + String authorFlair = singleCommentData.isNull(JSONUtils.AUTHOR_FLAIR_TEXT_KEY) ? "" : singleCommentData.getString(JSONUtils.AUTHOR_FLAIR_TEXT_KEY); String linkAuthor = singleCommentData.has(JSONUtils.LINK_AUTHOR_KEY) ? singleCommentData.getString(JSONUtils.LINK_AUTHOR_KEY) : null; String linkId = singleCommentData.getString(JSONUtils.LINK_ID_KEY).substring(3); String subredditName = singleCommentData.getString(JSONUtils.SUBREDDIT_KEY); @@ -168,7 +169,7 @@ public class ParseComment { boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY); boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String); - return new CommentData(id, fullName, author, authorFlairHTMLBuilder.toString(), linkAuthor, + return new CommentData(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(), linkAuthor, formattedSubmitTime, submitTime, commentMarkdown, commentRawText, linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished, permalink, depth, collapsed, hasReply, scoreHidden, saved); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java index 603717d4..ab3081b9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java @@ -17,6 +17,7 @@ public class JSONUtils { public static final String SELFTEXT_HTML_KEY = "selftext_html"; public static final String AUTHOR_KEY = "author"; public static final String AUTHOR_FLAIR_RICHTEXT_KEY = "author_flair_richtext"; + public static final String AUTHOR_FLAIR_TEXT_KEY = "author_flair_text"; public static final String E_KEY = "e"; public static final String T_KEY = "t"; public static final String U_KEY = "u"; |