Display spoiler and flair info in posts.

This commit is contained in:
Alex Ning 2019-07-17 21:33:16 +08:00
parent ebf542161e
commit 42497bb247
11 changed files with 223 additions and 65 deletions

View File

@ -32,6 +32,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.libRG.CustomTextView;
import com.santalu.aspectratioimageview.AspectRatioImageView; import com.santalu.aspectratioimageview.AspectRatioImageView;
import java.util.ArrayList; import java.util.ArrayList;
@ -271,6 +272,23 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
((PostDetailViewHolder) holder).mGildedNumberTextView.setText(gildedNumber); ((PostDetailViewHolder) holder).mGildedNumberTextView.setText(gildedNumber);
} }
if(mPost.isSpoiler() || mPost.getFlair() != null) {
((PostDetailViewHolder) holder).spoilerFlairlinearLayout.setVisibility(View.VISIBLE);
}
if(mPost.isSpoiler()) {
((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
((PostDetailViewHolder) holder).spoilerTextView
.setBackgroundColor(mActivity.getResources().getColor(R.color.backgroundColorPrimaryDark));
}
if(mPost.getFlair() != null) {
((PostDetailViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
((PostDetailViewHolder) holder).flairTextView.setText(mPost.getFlair());
((PostDetailViewHolder) holder).flairTextView
.setBackgroundColor(mActivity.getResources().getColor(R.color.backgroundColorPrimaryDark));
}
if(mPost.isNSFW()) { if(mPost.isNSFW()) {
((PostDetailViewHolder) holder).mNSFWChip.setVisibility(View.VISIBLE); ((PostDetailViewHolder) holder).mNSFWChip.setVisibility(View.VISIBLE);
} else { } else {
@ -677,6 +695,9 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@BindView(R.id.gilded_number_text_view_item_post_detail) TextView mGildedNumberTextView; @BindView(R.id.gilded_number_text_view_item_post_detail) TextView mGildedNumberTextView;
@BindView(R.id.crosspost_image_view_item_post_detail) ImageView mCrosspostImageView; @BindView(R.id.crosspost_image_view_item_post_detail) ImageView mCrosspostImageView;
@BindView(R.id.nsfw_text_view_item_post_detail) Chip mNSFWChip; @BindView(R.id.nsfw_text_view_item_post_detail) Chip mNSFWChip;
@BindView(R.id.spoiler_flair_linear_layout_item_post_detail) LinearLayout spoilerFlairlinearLayout;
@BindView(R.id.spoiler_custom_text_view_item_post_detail) CustomTextView spoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post_detail) CustomTextView flairTextView;
@BindView(R.id.link_text_view_item_post_detail) TextView linkTextView; @BindView(R.id.link_text_view_item_post_detail) TextView linkTextView;
@BindView(R.id.image_view_wrapper_item_post_detail) RelativeLayout mRelativeLayout; @BindView(R.id.image_view_wrapper_item_post_detail) RelativeLayout mRelativeLayout;
@BindView(R.id.load_wrapper_item_post_detail) RelativeLayout mLoadWrapper; @BindView(R.id.load_wrapper_item_post_detail) RelativeLayout mLoadWrapper;

View File

@ -75,4 +75,5 @@ public class JSONUtils {
static final String FIELDS_KEY = "fields"; static final String FIELDS_KEY = "fields";
static final String VALUE_KEY = "value"; static final String VALUE_KEY = "value";
static final String TEXT_KEY = "text"; static final String TEXT_KEY = "text";
static final String SPOILER_KEY = "spoiler";
} }

View File

@ -152,8 +152,13 @@ class ParsePost {
int score = data.getInt(JSONUtils.SCORE_KEY); int score = data.getInt(JSONUtils.SCORE_KEY);
int voteType; int voteType;
int gilded = data.getInt(JSONUtils.GILDED_KEY); int gilded = data.getInt(JSONUtils.GILDED_KEY);
boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY);
boolean nsfw = data.getBoolean(JSONUtils.NSFW_KEY); boolean nsfw = data.getBoolean(JSONUtils.NSFW_KEY);
boolean stickied = data.getBoolean(JSONUtils.STICKIED_KEY); boolean stickied = data.getBoolean(JSONUtils.STICKIED_KEY);
String flair = null;
if(!data.isNull(JSONUtils.LINK_FLAIR_TEXT_KEY)) {
flair = data.getString(JSONUtils.LINK_FLAIR_TEXT_KEY);
}
if(data.isNull(JSONUtils.LIKES_KEY)) { if(data.isNull(JSONUtils.LIKES_KEY)) {
voteType = 0; voteType = 0;
@ -184,19 +189,19 @@ class ParsePost {
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0); data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
return parseData(data, permalink, id, fullName, subredditNamePrefixed, return parseData(data, permalink, id, fullName, subredditNamePrefixed,
author, formattedPostTime, title, previewUrl, previewWidth, previewHeight, author, formattedPostTime, title, previewUrl, previewWidth, previewHeight,
score, voteType, gilded, nsfw, stickied, true, i); score, voteType, gilded, flair, spoiler, nsfw, stickied, true, i);
} else { } else {
return parseData(data, permalink, id, fullName, subredditNamePrefixed, return parseData(data, permalink, id, fullName, subredditNamePrefixed,
author, formattedPostTime, title, previewUrl, previewWidth, previewHeight, author, formattedPostTime, title, previewUrl, previewWidth, previewHeight,
score, voteType, gilded, nsfw, stickied, false, i); score, voteType, gilded, flair, spoiler, nsfw, stickied, false, i);
} }
} }
private static Post parseData(JSONObject data, String permalink, String id, String fullName, private static Post parseData(JSONObject data, String permalink, String id, String fullName,
String subredditNamePrefixed, String author, String formattedPostTime, String subredditNamePrefixed, String author, String formattedPostTime,
String title, String previewUrl, int previewWidth, int previewHeight, String title, String previewUrl, int previewWidth, int previewHeight,
int score, int voteType, int gilded, boolean nsfw, boolean stickied, int score, int voteType, int gilded, String flair, boolean spoiler,
boolean isCrosspost, int i) throws JSONException { boolean nsfw, boolean stickied, boolean isCrosspost, int i) throws JSONException {
Post post; Post post;
boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY); boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY);
@ -208,7 +213,8 @@ class ParsePost {
Log.i("text", Integer.toString(i)); Log.i("text", Integer.toString(i));
int postType = Post.TEXT_TYPE; int postType = Post.TEXT_TYPE;
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); title, permalink, score, postType, voteType, gilded, flair, spoiler, nsfw,
stickied, isCrosspost);
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -220,7 +226,7 @@ class ParsePost {
int postType = Post.NO_PREVIEW_LINK_TYPE; int postType = Post.NO_PREVIEW_LINK_TYPE;
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, previewUrl, url, permalink, score, postType, title, previewUrl, url, permalink, score, postType,
voteType, gilded, nsfw, stickied, isCrosspost); voteType, gilded, flair, spoiler, nsfw, stickied, isCrosspost);
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -242,7 +248,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, previewUrl, permalink, score, postType, voteType, title, previewUrl, permalink, score, postType, voteType,
gilded, nsfw, stickied, isCrosspost, true); gilded, flair, spoiler, nsfw, stickied, isCrosspost, true);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -259,7 +265,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title,
previewUrl, permalink, score, postType, voteType, previewUrl, permalink, score, postType, voteType,
gilded, nsfw, stickied, isCrosspost, false); gilded, flair, spoiler, nsfw, stickied, isCrosspost, false);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
post.setVideoUrl(videoUrl); post.setVideoUrl(videoUrl);
@ -274,7 +280,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title,
previewUrl, permalink, score, postType, voteType, previewUrl, permalink, score, postType, voteType,
gilded, nsfw, stickied, isCrosspost, true); gilded, flair, spoiler, nsfw, stickied, isCrosspost, true);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
post.setVideoUrl(videoUrl); post.setVideoUrl(videoUrl);
@ -287,7 +293,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, url, url, permalink, score, postType, title, url, url, permalink, score, postType,
voteType, gilded, nsfw, stickied, isCrosspost); voteType, gilded, flair, spoiler, nsfw, stickied, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -298,7 +304,8 @@ class ParsePost {
int postType = Post.TEXT_TYPE; int postType = Post.TEXT_TYPE;
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); title, permalink, score, postType, voteType, gilded, flair, spoiler,
nsfw, stickied, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -315,7 +322,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, previewUrl, url, permalink, score, title, previewUrl, url, permalink, score,
postType, voteType, gilded, nsfw, stickied, isCrosspost); postType, voteType, gilded, flair, spoiler, nsfw, stickied, isCrosspost);
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -335,7 +342,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime,
title, previewUrl, url, permalink, score, postType, title, previewUrl, url, permalink, score, postType,
voteType, gilded, nsfw, stickied, isCrosspost); voteType, gilded, flair, spoiler, nsfw, stickied, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
} else { } else {
@ -345,7 +352,7 @@ class ParsePost {
post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title, post = new Post(id, fullName, subredditNamePrefixed, author, formattedPostTime, title,
url, url, permalink, score, postType, voteType, url, url, permalink, score, postType, voteType,
gilded, nsfw, stickied, isCrosspost); gilded, flair, spoiler, nsfw, stickied, isCrosspost);
} }
} }
} }

View File

@ -29,12 +29,14 @@ class Post implements Parcelable {
private String videoUrl; private String videoUrl;
private String gifOrVideoDownloadUrl; private String gifOrVideoDownloadUrl;
private String permalink; private String permalink;
private String flair;
private int score; private int score;
private int postType; private int postType;
private int voteType; private int voteType;
private int gilded; private int gilded;
private int previewWidth; private int previewWidth;
private int previewHeight; private int previewHeight;
private boolean spoiler;
private boolean nsfw; private boolean nsfw;
private boolean stickied; private boolean stickied;
private boolean isCrosspost; private boolean isCrosspost;
@ -44,7 +46,7 @@ class Post implements Parcelable {
Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime, Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime,
String title, String previewUrl, String permalink, int score, int postType, int voteType, String title, String previewUrl, String permalink, int score, int postType, int voteType,
int gilded, boolean nsfw, boolean stickied, boolean isCrosspost, boolean isDashVideo) { int gilded, String flair, boolean spoiler, boolean nsfw, boolean stickied, boolean isCrosspost, boolean isDashVideo) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -57,6 +59,8 @@ class Post implements Parcelable {
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded; this.gilded = gilded;
this.flair = flair;
this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost = isCrosspost; this.isCrosspost = isCrosspost;
@ -65,7 +69,8 @@ class Post implements Parcelable {
Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime, Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime,
String title, String previewUrl, String url, String permalink, int score, int postType, String title, String previewUrl, String url, String permalink, int score, int postType,
int voteType, int gilded, boolean nsfw, boolean stickied, boolean isCrosspost) { int voteType, int gilded, String flair, boolean spoiler, boolean nsfw, boolean stickied,
boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -79,14 +84,16 @@ class Post implements Parcelable {
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded; this.gilded = gilded;
this.flair = flair;
this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost = isCrosspost; this.isCrosspost = isCrosspost;
} }
Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime, Post(String id, String fullName, String subredditNamePrefixed, String author, String postTime,
String title, String permalink, int score, int postType, int voteType, int gilded, boolean nsfw, String title, String permalink, int score, int postType, int voteType, int gilded, String flair,
boolean stickied, boolean isCrosspost) { boolean spoiler, boolean nsfw, boolean stickied, boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -98,6 +105,8 @@ class Post implements Parcelable {
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded; this.gilded = gilded;
this.flair = flair;
this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost= isCrosspost; this.isCrosspost= isCrosspost;
@ -118,12 +127,14 @@ class Post implements Parcelable {
videoUrl = in.readString(); videoUrl = in.readString();
gifOrVideoDownloadUrl = in.readString(); gifOrVideoDownloadUrl = in.readString();
permalink = in.readString(); permalink = in.readString();
flair = in.readString();
score = in.readInt(); score = in.readInt();
postType = in.readInt(); postType = in.readInt();
voteType = in.readInt(); voteType = in.readInt();
gilded = in.readInt(); gilded = in.readInt();
previewWidth = in.readInt(); previewWidth = in.readInt();
previewHeight = in.readInt(); previewHeight = in.readInt();
spoiler = in.readByte() != 0;
nsfw = in.readByte() != 0; nsfw = in.readByte() != 0;
stickied = in.readByte() != 0; stickied = in.readByte() != 0;
isCrosspost = in.readByte() != 0; isCrosspost = in.readByte() != 0;
@ -147,35 +158,35 @@ class Post implements Parcelable {
return id; return id;
} }
public String getFullName() { String getFullName() {
return fullName; return fullName;
} }
public String getSubredditNamePrefixed() { String getSubredditNamePrefixed() {
return subredditNamePrefixed; return subredditNamePrefixed;
} }
public String getSubredditIconUrl() { String getSubredditIconUrl() {
return subredditIconUrl; return subredditIconUrl;
} }
public void setSubredditIconUrl(String subredditIconUrl) { void setSubredditIconUrl(String subredditIconUrl) {
this.subredditIconUrl = subredditIconUrl; this.subredditIconUrl = subredditIconUrl;
} }
public String getAuthor() { String getAuthor() {
return author; return author;
} }
public String getAuthorIconUrl() { String getAuthorIconUrl() {
return authorIconUrl; return authorIconUrl;
} }
public void setAuthorIconUrl(String authorIconUrl) { void setAuthorIconUrl(String authorIconUrl) {
this.authorIconUrl = authorIconUrl; this.authorIconUrl = authorIconUrl;
} }
public String getPostTime() { String getPostTime() {
return postTime; return postTime;
} }
@ -187,63 +198,67 @@ class Post implements Parcelable {
return title; return title;
} }
public void setSelfText(String selfText) { void setSelfText(String selfText) {
this.selfText = selfText; this.selfText = selfText;
} }
public String getSelfText() { String getSelfText() {
return selfText; return selfText;
} }
public String getPreviewUrl() { String getPreviewUrl() {
return previewUrl; return previewUrl;
} }
public String getUrl() { String getUrl() {
return url; return url;
} }
public void setVideoUrl(String videoUrl) { void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl; this.videoUrl = videoUrl;
} }
public String getVideoUrl() { String getVideoUrl() {
return videoUrl; return videoUrl;
} }
public String getGifOrVideoDownloadUrl() { String getGifOrVideoDownloadUrl() {
return gifOrVideoDownloadUrl; return gifOrVideoDownloadUrl;
} }
public void setGifOrVideoDownloadUrl(String gifOrVideoDownloadUrl) { void setGifOrVideoDownloadUrl(String gifOrVideoDownloadUrl) {
this.gifOrVideoDownloadUrl = gifOrVideoDownloadUrl; this.gifOrVideoDownloadUrl = gifOrVideoDownloadUrl;
} }
public String getPermalink() { String getPermalink() {
return permalink; return permalink;
} }
public void setScore(int score) { public String getFlair() {
return flair;
}
void setScore(int score) {
this.score = score; this.score = score;
} }
public int getScore() { int getScore() {
return score; return score;
} }
public int getPostType() { int getPostType() {
return postType; return postType;
} }
public void setVoteType(int voteType) { void setVoteType(int voteType) {
this.voteType = voteType; this.voteType = voteType;
} }
public int getVoteType() { int getVoteType() {
return voteType; return voteType;
} }
public int getGilded() { int getGilded() {
return gilded; return gilded;
} }
@ -263,7 +278,11 @@ class Post implements Parcelable {
return previewHeight; return previewHeight;
} }
public boolean isNSFW() { boolean isSpoiler() {
return spoiler;
}
boolean isNSFW() {
return nsfw; return nsfw;
} }
@ -272,23 +291,23 @@ class Post implements Parcelable {
return 0; return 0;
} }
public boolean isDashVideo() { boolean isDashVideo() {
return isDashVideo; return isDashVideo;
} }
public void setDownloadableGifOrVideo(boolean isDownloadableGifOrVideo) { void setDownloadableGifOrVideo(boolean isDownloadableGifOrVideo) {
this.isDownloadableGifOrVideo = isDownloadableGifOrVideo; this.isDownloadableGifOrVideo = isDownloadableGifOrVideo;
} }
public boolean isDownloadableGifOrVideo() { boolean isDownloadableGifOrVideo() {
return isDownloadableGifOrVideo; return isDownloadableGifOrVideo;
} }
public boolean isStickied() { boolean isStickied() {
return stickied; return stickied;
} }
public boolean isCrosspost() { boolean isCrosspost() {
return isCrosspost; return isCrosspost;
} }
@ -308,12 +327,14 @@ class Post implements Parcelable {
parcel.writeString(videoUrl); parcel.writeString(videoUrl);
parcel.writeString(gifOrVideoDownloadUrl); parcel.writeString(gifOrVideoDownloadUrl);
parcel.writeString(permalink); parcel.writeString(permalink);
parcel.writeString(flair);
parcel.writeInt(score); parcel.writeInt(score);
parcel.writeInt(postType); parcel.writeInt(postType);
parcel.writeInt(voteType); parcel.writeInt(voteType);
parcel.writeInt(gilded); parcel.writeInt(gilded);
parcel.writeInt(previewWidth); parcel.writeInt(previewWidth);
parcel.writeInt(previewHeight); parcel.writeInt(previewHeight);
parcel.writeByte((byte) (spoiler ? 1 : 0));
parcel.writeByte((byte) (nsfw ? 1 : 0)); parcel.writeByte((byte) (nsfw ? 1 : 0));
parcel.writeByte((byte) (stickied ? 1 : 0)); parcel.writeByte((byte) (stickied ? 1 : 0));
parcel.writeByte((byte) (isCrosspost ? 1 : 0)); parcel.writeByte((byte) (isCrosspost ? 1 : 0));

View File

@ -149,10 +149,10 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
if(flair != null) { if(flair != null) {
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isSpoiler) { if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isNSFW) { if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
@ -195,7 +195,7 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) { if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
@ -428,7 +428,7 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
public void flairSelected(String flair) { public void flairSelected(String flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss(); flairSelectionBottomSheetFragment.dismiss();
} }
} }

View File

@ -119,10 +119,10 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
if(flair != null) { if(flair != null) {
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isSpoiler) { if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isNSFW) { if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
@ -166,7 +166,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) { if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
@ -306,7 +306,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
public void flairSelected(String flair) { public void flairSelected(String flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss(); flairSelectionBottomSheetFragment.dismiss();
} }
} }

View File

@ -37,6 +37,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.google.android.material.card.MaterialCardView; import com.google.android.material.card.MaterialCardView;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -139,6 +140,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
int voteType = post.getVoteType(); int voteType = post.getVoteType();
int gilded = post.getGilded(); int gilded = post.getGilded();
boolean nsfw = post.isNSFW(); boolean nsfw = post.isNSFW();
boolean spoiler = post.isSpoiler();
String flair = post.getFlair();
((DataViewHolder) holder).cardView.setOnClickListener(view -> { ((DataViewHolder) holder).cardView.setOnClickListener(view -> {
if(canStartActivity) { if(canStartActivity) {
@ -300,6 +303,21 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
((DataViewHolder) holder).nsfwChip.setVisibility(View.VISIBLE); ((DataViewHolder) holder).nsfwChip.setVisibility(View.VISIBLE);
} }
if(spoiler || flair != null) {
((DataViewHolder) holder).spoilerFlairLinearLayout.setVisibility(View.VISIBLE);
}
if(spoiler) {
((DataViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
((DataViewHolder) holder).spoilerTextView.setBackgroundColor(mContext.getResources().getColor(R.color.backgroundColorPrimaryDark));
}
if(flair != null) {
((DataViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
((DataViewHolder) holder).flairTextView.setText(flair);
((DataViewHolder) holder).flairTextView.setBackgroundColor(mContext.getResources().getColor(R.color.backgroundColorPrimaryDark));
}
switch (voteType) { switch (voteType) {
case 1: case 1:
//Upvote //Upvote
@ -620,6 +638,9 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
@BindView(R.id.gilded_number_text_view_item_post) TextView gildedNumberTextView; @BindView(R.id.gilded_number_text_view_item_post) TextView gildedNumberTextView;
@BindView(R.id.crosspost_image_view_item_post) ImageView crosspostImageView; @BindView(R.id.crosspost_image_view_item_post) ImageView crosspostImageView;
@BindView(R.id.nsfw_text_view_item_post) Chip nsfwChip; @BindView(R.id.nsfw_text_view_item_post) Chip nsfwChip;
@BindView(R.id.spoiler_flair_linear_layout_item_post) LinearLayout spoilerFlairLinearLayout;
@BindView(R.id.spoiler_custom_text_view_item_post) CustomTextView spoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post) CustomTextView flairTextView;
@BindView(R.id.link_text_view_item_post) TextView linkTextView; @BindView(R.id.link_text_view_item_post) TextView linkTextView;
@BindView(R.id.image_view_wrapper_item_post) RelativeLayout relativeLayout; @BindView(R.id.image_view_wrapper_item_post) RelativeLayout relativeLayout;
@BindView(R.id.progress_bar_item_post) ProgressBar progressBar; @BindView(R.id.progress_bar_item_post) ProgressBar progressBar;
@ -670,6 +691,9 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
((DataViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE); ((DataViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE);
((DataViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((DataViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
((DataViewHolder) holder).nsfwChip.setVisibility(View.GONE); ((DataViewHolder) holder).nsfwChip.setVisibility(View.GONE);
((DataViewHolder) holder).spoilerFlairLinearLayout.setVisibility(View.GONE);
((DataViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
((DataViewHolder) holder).flairTextView.setVisibility(View.GONE);
((DataViewHolder) holder).linkTextView.setVisibility(View.GONE); ((DataViewHolder) holder).linkTextView.setVisibility(View.GONE);
((DataViewHolder) holder).progressBar.setVisibility(View.GONE); ((DataViewHolder) holder).progressBar.setVisibility(View.GONE);
((DataViewHolder) holder).imageView.setVisibility(View.GONE); ((DataViewHolder) holder).imageView.setVisibility(View.GONE);

View File

@ -119,10 +119,10 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
if(flair != null) { if(flair != null) {
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isSpoiler) { if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isNSFW) { if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
@ -171,7 +171,7 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) { if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
@ -311,7 +311,7 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
public void flairSelected(String flair) { public void flairSelected(String flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss(); flairSelectionBottomSheetFragment.dismiss();
} }
} }

View File

@ -154,10 +154,10 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
if(flair != null) { if(flair != null) {
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isSpoiler) { if(isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
} }
if(isNSFW) { if(isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
@ -200,7 +200,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if(!isSpoiler) { if(!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
@ -409,7 +409,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
public void flairSelected(String flair) { public void flairSelected(String flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair); flairTextView.setText(flair);
flairTextView.setBackgroundColor(getResources().getColor(R.color.textColorPrimaryDark)); flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark));
flairSelectionBottomSheetFragment.dismiss(); flairSelectionBottomSheetFragment.dismiss();
} }
} }

View File

@ -142,10 +142,53 @@
</RelativeLayout> </RelativeLayout>
<LinearLayout
android:id="@+id/spoiler_flair_linear_layout_item_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:visibility="gone">
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_item_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:text="@string/spoiler"
android:textSize="12sp"
android:textColor="@color/primaryTextColor"
android:padding="4dp"
android:background="@color/textColorPrimaryDark"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_item_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:textSize="12sp"
android:textColor="@color/primaryTextColor"
android:padding="4dp"
android:background="@color/textColorPrimaryDark"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<TextView <TextView
android:id="@+id/link_text_view_item_post" android:id="@+id/link_text_view_item_post"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textSize="12sp" android:textSize="12sp"
@ -155,7 +198,6 @@
android:id="@+id/image_view_wrapper_item_post" android:id="@+id/image_view_wrapper_item_post"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone"> android:visibility="gone">
<ProgressBar <ProgressBar

View File

@ -134,10 +134,53 @@
</RelativeLayout> </RelativeLayout>
<LinearLayout
android:id="@+id/spoiler_flair_linear_layout_item_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:visibility="gone">
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:text="@string/spoiler"
android:textSize="12sp"
android:textColor="@color/primaryTextColor"
android:padding="4dp"
android:background="@color/textColorPrimaryDark"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:textSize="12sp"
android:textColor="@color/primaryTextColor"
android:padding="4dp"
android:background="@color/textColorPrimaryDark"
android:visibility="gone"
app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/textColorPrimaryDark"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
<TextView <TextView
android:id="@+id/link_text_view_item_post_detail" android:id="@+id/link_text_view_item_post_detail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textSize="12sp" android:textSize="12sp"
@ -147,7 +190,6 @@
android:id="@+id/image_view_wrapper_item_post_detail" android:id="@+id/image_view_wrapper_item_post_detail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone"> android:visibility="gone">
<com.santalu.aspectratioimageview.AspectRatioImageView <com.santalu.aspectratioimageview.AspectRatioImageView