mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Show author flair (not richtext) for comments.
This commit is contained in:
parent
9cbe542c85
commit
f0125edd23
@ -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()) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -161,16 +161,6 @@
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gilded_number_text_view_item_post_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/gold"
|
||||
android:textSize="?attr/font_default"
|
||||
android:drawableStart="@drawable/gold"
|
||||
android:drawablePadding="4dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/archived_image_view_item_post_detail"
|
||||
android:layout_width="20dp"
|
||||
|
Loading…
Reference in New Issue
Block a user