Show all post awards.

This commit is contained in:
Alex Ning 2020-04-16 16:10:07 +08:00
parent 4260c6c14e
commit 9cbe542c85
8 changed files with 127 additions and 86 deletions

View File

@ -545,12 +545,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime()); ((PostDetailViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime());
} }
if (mPost.getGilded() > 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()) { if (mPost.isArchived()) {
((PostDetailViewHolder) holder).mArchivedImageView.setVisibility(View.VISIBLE); ((PostDetailViewHolder) holder).mArchivedImageView.setVisibility(View.VISIBLE);
} }
@ -575,6 +569,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailViewHolder) holder).mFlairTextView.setText(flairHTML); ((PostDetailViewHolder) holder).mFlairTextView.setText(flairHTML);
} }
if (mPost.getAwards() != null && !mPost.getAwards().equals("")) {
((PostDetailViewHolder) holder).mAwardsTextView.setVisibility(View.VISIBLE);
Spannable awardsHTML;
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostDetailViewHolder) holder).mAwardsTextView);
if (android.os.Build.VERSION.SDK_INT >= 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()) { if (mPost.isNSFW()) {
((PostDetailViewHolder) holder).mNSFWTextView.setOnClickListener(view -> { ((PostDetailViewHolder) holder).mNSFWTextView.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, FilteredThingActivity.class); Intent intent = new Intent(mActivity, FilteredThingActivity.class);
@ -1809,8 +1815,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
RecyclerView mContentMarkdownView; RecyclerView mContentMarkdownView;
@BindView(R.id.type_text_view_item_post_detail) @BindView(R.id.type_text_view_item_post_detail)
CustomTextView mTypeTextView; CustomTextView mTypeTextView;
@BindView(R.id.gilded_number_text_view_item_post_detail)
TextView mGildedNumberTextView;
@BindView(R.id.crosspost_image_view_item_post_detail) @BindView(R.id.crosspost_image_view_item_post_detail)
ImageView mCrosspostImageView; ImageView mCrosspostImageView;
@BindView(R.id.archived_image_view_item_post_detail) @BindView(R.id.archived_image_view_item_post_detail)
@ -1823,6 +1827,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
CustomTextView mSpoilerTextView; CustomTextView mSpoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post_detail) @BindView(R.id.flair_custom_text_view_item_post_detail)
CustomTextView mFlairTextView; CustomTextView mFlairTextView;
@BindView(R.id.awards_text_view_item_post_detail)
TextView mAwardsTextView;
@BindView(R.id.link_text_view_item_post_detail) @BindView(R.id.link_text_view_item_post_detail)
TextView mLinkTextView; TextView mLinkTextView;
@BindView(R.id.image_view_wrapper_item_post_detail) @BindView(R.id.image_view_wrapper_item_post_detail)
@ -2087,6 +2093,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mArchivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN); mArchivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN);
mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN); mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN);
mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN); mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN);
mAwardsTextView.setTextColor(mPostTitleColor);
mLinkTextView.setTextColor(mSecondaryTextColor); mLinkTextView.setTextColor(mSecondaryTextColor);
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
mNoPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); mNoPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);

View File

@ -239,10 +239,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final String postTime = post.getPostTime(); final String postTime = post.getPostTime();
final String title = post.getTitle(); final String title = post.getTitle();
int voteType = post.getVoteType(); int voteType = post.getVoteType();
int gilded = post.getGilded();
boolean nsfw = post.isNSFW(); boolean nsfw = post.isNSFW();
boolean spoiler = post.isSpoiler(); boolean spoiler = post.isSpoiler();
String flair = post.getFlair(); String flair = post.getFlair();
String awards = post.getAwards();
boolean isArchived = post.isArchived(); boolean isArchived = post.isArchived();
((PostViewHolder) holder).cardView.setOnClickListener(view -> { ((PostViewHolder) holder).cardView.setOnClickListener(view -> {
@ -418,12 +418,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).titleTextView.setText(title); ((PostViewHolder) holder).titleTextView.setText(title);
((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
if (gilded > 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()) { if (post.isLocked()) {
((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); ((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
} }
@ -457,6 +451,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).flairTextView.setText(flairHTML); ((PostViewHolder) holder).flairTextView.setText(flairHTML);
} }
if (awards != null && !awards.equals("")) {
((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
Spannable awardsHTML;
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostViewHolder) holder).awardsTextView);
if (android.os.Build.VERSION.SDK_INT >= 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) { switch (voteType) {
case 1: case 1:
//Upvoted //Upvoted
@ -810,10 +816,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
final String postTime = post.getPostTime(); final String postTime = post.getPostTime();
final String title = post.getTitle(); final String title = post.getTitle();
int voteType = post.getVoteType(); int voteType = post.getVoteType();
int gilded = post.getGilded();
boolean nsfw = post.isNSFW(); boolean nsfw = post.isNSFW();
boolean spoiler = post.isSpoiler(); boolean spoiler = post.isSpoiler();
String flair = post.getFlair(); String flair = post.getFlair();
String awards = post.getAwards();
boolean isArchived = post.isArchived(); boolean isArchived = post.isArchived();
((PostCompactViewHolder) holder).itemView.setOnClickListener(view -> { ((PostCompactViewHolder) holder).itemView.setOnClickListener(view -> {
@ -983,12 +989,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).titleTextView.setText(title); ((PostCompactViewHolder) holder).titleTextView.setText(title);
((PostCompactViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); ((PostCompactViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
if (gilded > 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()) { if (post.isLocked()) {
((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); ((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
} }
@ -1022,6 +1022,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).flairTextView.setText(flairHTML); ((PostCompactViewHolder) holder).flairTextView.setText(flairHTML);
} }
if (awards != null && !awards.equals("")) {
((PostCompactViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
Spannable awardsHTML;
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostCompactViewHolder) holder).awardsTextView);
if (android.os.Build.VERSION.SDK_INT >= 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) { switch (voteType) {
case 1: case 1:
//Upvoted //Upvoted
@ -1517,13 +1529,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mGlide.clear(((PostViewHolder) holder).iconGifImageView); mGlide.clear(((PostViewHolder) holder).iconGifImageView);
((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
((PostViewHolder) holder).relativeLayout.setVisibility(View.GONE); ((PostViewHolder) holder).relativeLayout.setVisibility(View.GONE);
((PostViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE);
((PostViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((PostViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
((PostViewHolder) holder).archivedImageView.setVisibility(View.GONE); ((PostViewHolder) holder).archivedImageView.setVisibility(View.GONE);
((PostViewHolder) holder).lockedImageView.setVisibility(View.GONE); ((PostViewHolder) holder).lockedImageView.setVisibility(View.GONE);
((PostViewHolder) holder).nsfwTextView.setVisibility(View.GONE); ((PostViewHolder) holder).nsfwTextView.setVisibility(View.GONE);
((PostViewHolder) holder).spoilerTextView.setVisibility(View.GONE); ((PostViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
((PostViewHolder) holder).flairTextView.setVisibility(View.GONE); ((PostViewHolder) holder).flairTextView.setVisibility(View.GONE);
((PostViewHolder) holder).flairTextView.setText("");
((PostViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((PostViewHolder) holder).awardsTextView.setText("");
((PostViewHolder) holder).linkTextView.setVisibility(View.GONE); ((PostViewHolder) holder).linkTextView.setVisibility(View.GONE);
((PostViewHolder) holder).progressBar.setVisibility(View.GONE); ((PostViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START); ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
@ -1541,13 +1555,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mGlide.clear(((PostCompactViewHolder) holder).iconGifImageView); mGlide.clear(((PostCompactViewHolder) holder).iconGifImageView);
((PostCompactViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).relativeLayout.setVisibility(View.GONE); ((PostCompactViewHolder) holder).relativeLayout.setVisibility(View.GONE);
((PostCompactViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).archivedImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).archivedImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).nsfwTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).nsfwTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).spoilerTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).flairTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).flairTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).flairTextView.setText("");
((PostCompactViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).awardsTextView.setText("");
((PostCompactViewHolder) holder).linkTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).linkTextView.setVisibility(View.GONE);
((PostCompactViewHolder) holder).progressBar.setVisibility(View.GONE); ((PostCompactViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCompactViewHolder) holder).imageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).imageView.setVisibility(View.GONE);
@ -1582,8 +1598,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
TextView titleTextView; TextView titleTextView;
@BindView(R.id.type_text_view_item_post) @BindView(R.id.type_text_view_item_post)
CustomTextView typeTextView; CustomTextView typeTextView;
@BindView(R.id.gilded_number_text_view_item_post)
TextView gildedNumberTextView;
@BindView(R.id.archived_image_view_item_post) @BindView(R.id.archived_image_view_item_post)
ImageView archivedImageView; ImageView archivedImageView;
@BindView(R.id.locked_image_view_item_post) @BindView(R.id.locked_image_view_item_post)
@ -1596,6 +1610,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
CustomTextView spoilerTextView; CustomTextView spoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post) @BindView(R.id.flair_custom_text_view_item_post)
CustomTextView flairTextView; CustomTextView flairTextView;
@BindView(R.id.awards_text_view_item_post)
TextView awardsTextView;
@BindView(R.id.link_text_view_item_post) @BindView(R.id.link_text_view_item_post)
TextView linkTextView; TextView linkTextView;
@BindView(R.id.image_view_wrapper_item_post) @BindView(R.id.image_view_wrapper_item_post)
@ -1675,6 +1691,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN); archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN);
lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN); lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN);
crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN);
awardsTextView.setTextColor(mPostTitleColor);
linkTextView.setTextColor(mSecondaryTextColor); linkTextView.setTextColor(mSecondaryTextColor);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
@ -1701,8 +1718,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
TextView titleTextView; TextView titleTextView;
@BindView(R.id.type_text_view_item_post_compact) @BindView(R.id.type_text_view_item_post_compact)
CustomTextView typeTextView; CustomTextView typeTextView;
@BindView(R.id.gilded_number_text_view_item_post_compact)
TextView gildedNumberTextView;
@BindView(R.id.archived_image_view_item_post_compact) @BindView(R.id.archived_image_view_item_post_compact)
ImageView archivedImageView; ImageView archivedImageView;
@BindView(R.id.locked_image_view_item_post_compact) @BindView(R.id.locked_image_view_item_post_compact)
@ -1715,6 +1730,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
CustomTextView spoilerTextView; CustomTextView spoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post_compact) @BindView(R.id.flair_custom_text_view_item_post_compact)
CustomTextView flairTextView; CustomTextView flairTextView;
@BindView(R.id.awards_text_view_item_post_compact)
TextView awardsTextView;
@BindView(R.id.link_text_view_item_post_compact) @BindView(R.id.link_text_view_item_post_compact)
TextView linkTextView; TextView linkTextView;
@BindView(R.id.image_view_wrapper_item_post_compact) @BindView(R.id.image_view_wrapper_item_post_compact)
@ -1789,6 +1806,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN); archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN);
lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN); lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN);
crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN);
awardsTextView.setTextColor(mPostTitleColor);
linkTextView.setTextColor(mSecondaryTextColor); linkTextView.setTextColor(mSecondaryTextColor);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);

View File

@ -41,7 +41,6 @@ public class ParsePost {
String title = data.getString(JSONUtils.TITLE_KEY); String title = data.getString(JSONUtils.TITLE_KEY);
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 nComments = data.getInt(JSONUtils.NUM_COMMENTS_KEY); int nComments = data.getInt(JSONUtils.NUM_COMMENTS_KEY);
boolean hidden = data.getBoolean(JSONUtils.HIDDEN_KEY); boolean hidden = data.getBoolean(JSONUtils.HIDDEN_KEY);
boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY); boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY);
@ -64,6 +63,20 @@ public class ParsePost {
} }
} }
String flair = postFlairHTMLBuilder.toString(); String flair = postFlairHTMLBuilder.toString();
StringBuilder awardingsBuilder = new StringBuilder();
JSONArray awardingsArray = data.getJSONArray(JSONUtils.ALL_AWARDINGS_KEY);
for (int i = 0; i < awardingsArray.length(); i++) {
JSONObject award = awardingsArray.getJSONObject(i);
int count = award.getInt(JSONUtils.COUNT_KEY);
JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY);
if (icons.length() > 4) {
String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY);
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\">").append("x").append(count).append(" ");
} else if (icons.length() > 0) {
String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY);
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\">").append("x").append(count).append(" ");
}
}
if (data.isNull(JSONUtils.LIKES_KEY)) { if (data.isNull(JSONUtils.LIKES_KEY)) {
voteType = 0; voteType = 0;
@ -103,15 +116,17 @@ public class ParsePost {
Post crosspostParent = parseBasicData(data, locale); Post crosspostParent = parseBasicData(data, locale);
Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl,
previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, previewWidth, previewHeight, score, voteType, nComments, flair,
nsfw, stickied, archived, locked, saved, true); awardingsBuilder.toString(), hidden, spoiler, nsfw, stickied, archived, locked,
saved, true);
post.setCrosspostParentId(crosspostParent.getId()); post.setCrosspostParentId(crosspostParent.getId());
return post; return post;
} else { } else {
return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl,
previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, previewWidth, previewHeight, score, voteType, nComments, flair,
nsfw, stickied, archived, locked, saved, false); awardingsBuilder.toString(), hidden, spoiler, nsfw, stickied, archived, locked,
saved, false);
} }
} }
@ -119,8 +134,8 @@ public class ParsePost {
String subredditName, String subredditNamePrefixed, String author, String subredditName, String subredditNamePrefixed, String author,
String formattedPostTime, long postTimeMillis, String title, String previewUrl, String formattedPostTime, long postTimeMillis, String title, String previewUrl,
String thumbnailPreviewUrl, int previewWidth, int previewHeight, String thumbnailPreviewUrl, int previewWidth, int previewHeight,
int score, int voteType, int gilded, int nComments, String flair, int score, int voteType, int nComments, String flair,
boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, String awards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
boolean archived, boolean locked, boolean saved, boolean isCrosspost) throws JSONException { boolean archived, boolean locked, boolean saved, boolean isCrosspost) throws JSONException {
Post post; Post post;
@ -132,7 +147,7 @@ public class ParsePost {
//Text post //Text post
int postType = Post.TEXT_TYPE; int postType = Post.TEXT_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
title, permalink, score, postType, voteType, gilded, nComments, flair, title, permalink, score, postType, voteType, nComments, flair, awards,
hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");
@ -157,7 +172,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink,
score, postType, voteType, gilded, nComments, flair, hidden, spoiler, score, postType, voteType, nComments, flair, awards, hidden, spoiler,
nsfw, stickied, archived, locked, saved, isCrosspost); nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
@ -167,7 +182,7 @@ public class ParsePost {
int postType = Post.NO_PREVIEW_LINK_TYPE; int postType = Post.NO_PREVIEW_LINK_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType, title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -190,7 +205,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType, title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -207,7 +222,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, permalink, score, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, permalink, score,
postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw, postType, voteType, nComments, flair, awards, hidden, spoiler, nsfw,
stickied, archived, locked, saved, isCrosspost); stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -220,7 +235,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink,
score, postType, voteType, gilded, nComments, flair, hidden, spoiler, score, postType, voteType, nComments, flair, awards, hidden, spoiler,
nsfw, stickied, archived, locked, saved, isCrosspost); nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
@ -230,7 +245,7 @@ public class ParsePost {
int postType = Post.GIF_TYPE; int postType = Post.GIF_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
score, postType, voteType, gilded, nComments, flair, hidden, spoiler, score, postType, voteType, nComments, flair, awards, hidden, spoiler,
nsfw, stickied, archived, locked, saved, isCrosspost); nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
@ -243,7 +258,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, permalink, score, postType, formattedPostTime, postTimeMillis, title, permalink, score, postType,
voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied, voteType, nComments, flair, awards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
@ -271,7 +286,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
score, postType, voteType, gilded, nComments, flair, hidden, spoiler, score, postType, voteType, nComments, flair, awards, hidden, spoiler,
nsfw, stickied, archived, locked, saved, isCrosspost); nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");
@ -291,7 +306,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
score, postType, voteType, gilded, nComments, flair, hidden, spoiler, score, postType, voteType, nComments, flair, awards, hidden, spoiler,
nsfw, stickied, archived, locked, saved, isCrosspost); nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth); post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight); post.setPreviewHeight(previewHeight);
@ -301,7 +316,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score,
postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied, postType, voteType, nComments, flair, awards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost);
} }
} }
@ -402,7 +417,7 @@ public class ParsePost {
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) { if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
Post post = parseBasicData(data, locale); Post post = parseBasicData(data, locale);
if (post != null && !(!nsfw && post.isNSFW())) { if (!(!nsfw && post.isNSFW())) {
if (filter == PostFragment.EXTRA_NO_FILTER) { if (filter == PostFragment.EXTRA_NO_FILTER) {
newPosts.add(post); newPosts.add(post);
} else if (filter == post.getPostType()) { } else if (filter == post.getPostType()) {

View File

@ -48,11 +48,11 @@ public class Post implements Parcelable {
private String videoDownloadUrl; private String videoDownloadUrl;
private String permalink; private String permalink;
private String flair; private String flair;
private String awards;
private long postTimeMillis; private long postTimeMillis;
private int score; private int score;
private int postType; private int postType;
private int voteType; private int voteType;
private int gilded;
private int previewWidth; private int previewWidth;
private int previewHeight; private int previewHeight;
private int nComments; private int nComments;
@ -69,9 +69,9 @@ public class Post implements Parcelable {
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
String author, String postTime, long postTimeMillis, String title, String previewUrl, String author, String postTime, long postTimeMillis, String title, String previewUrl,
String thumbnailPreviewUrl, String permalink, int score, int postType, String thumbnailPreviewUrl, String permalink, int score, int postType,
int voteType, int gilded, int nComments, String flair, boolean hidden, boolean spoiler, int voteType, int nComments, String flair, String awards, boolean hidden,
boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked,
boolean isCrosspost) { boolean saved, boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditName = subredditName; this.subredditName = subredditName;
@ -87,9 +87,9 @@ public class Post implements Parcelable {
this.score = score; this.score = score;
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded;
this.nComments = nComments; this.nComments = nComments;
this.flair = flair; this.flair = flair;
this.awards = awards;
this.hidden = hidden; this.hidden = hidden;
this.spoiler = spoiler; this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
@ -103,9 +103,9 @@ public class Post implements Parcelable {
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
String author, String postTime, long postTimeMillis, String title, String previewUrl, String author, String postTime, long postTimeMillis, String title, String previewUrl,
String thumbnailPreviewUrl, String url, String permalink, int score, String thumbnailPreviewUrl, String url, String permalink, int score,
int postType, int voteType, int gilded, int nComments, String flair, boolean hidden, int postType, int voteType, int nComments, String flair, String awards,
boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived,
boolean saved, boolean isCrosspost) { boolean locked, boolean saved, boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditName = subredditName; this.subredditName = subredditName;
@ -122,9 +122,9 @@ public class Post implements Parcelable {
this.score = score; this.score = score;
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded;
this.nComments = nComments; this.nComments = nComments;
this.flair = flair; this.flair = flair;
this.awards = awards;
this.hidden = hidden; this.hidden = hidden;
this.spoiler = spoiler; this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
@ -135,9 +135,10 @@ public class Post implements Parcelable {
this.isCrosspost = isCrosspost; this.isCrosspost = isCrosspost;
} }
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
String postTime, long postTimeMillis, String title, String permalink, int score, int postType, int voteType, int gilded, String author, String postTime, long postTimeMillis, String title, String permalink,
int nComments, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, int score, int postType, int voteType, int nComments, String flair,
String awards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
boolean archived, boolean locked, boolean saved, boolean isCrosspost) { boolean archived, boolean locked, boolean saved, boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
@ -152,9 +153,9 @@ public class Post implements Parcelable {
this.score = score; this.score = score;
this.postType = postType; this.postType = postType;
this.voteType = voteType; this.voteType = voteType;
this.gilded = gilded;
this.nComments = nComments; this.nComments = nComments;
this.flair = flair; this.flair = flair;
this.awards = awards;
this.hidden = hidden; this.hidden = hidden;
this.spoiler = spoiler; this.spoiler = spoiler;
this.nsfw = nsfw; this.nsfw = nsfw;
@ -187,10 +188,10 @@ public class Post implements Parcelable {
videoDownloadUrl = in.readString(); videoDownloadUrl = in.readString();
permalink = in.readString(); permalink = in.readString();
flair = in.readString(); flair = in.readString();
awards = in.readString();
score = in.readInt(); score = in.readInt();
postType = in.readInt(); postType = in.readInt();
voteType = in.readInt(); voteType = in.readInt();
gilded = in.readInt();
previewWidth = in.readInt(); previewWidth = in.readInt();
previewHeight = in.readInt(); previewHeight = in.readInt();
nComments = in.readInt(); nComments = in.readInt();
@ -325,6 +326,10 @@ public class Post implements Parcelable {
this.flair = flair; this.flair = flair;
} }
public String getAwards() {
return awards;
}
public int getScore() { public int getScore() {
return score; return score;
} }
@ -345,10 +350,6 @@ public class Post implements Parcelable {
this.voteType = voteType; this.voteType = voteType;
} }
public int getGilded() {
return gilded;
}
public int getPreviewWidth() { public int getPreviewWidth() {
return previewWidth; return previewWidth;
} }
@ -457,10 +458,10 @@ public class Post implements Parcelable {
parcel.writeString(videoDownloadUrl); parcel.writeString(videoDownloadUrl);
parcel.writeString(permalink); parcel.writeString(permalink);
parcel.writeString(flair); parcel.writeString(flair);
parcel.writeString(awards);
parcel.writeInt(score); parcel.writeInt(score);
parcel.writeInt(postType); parcel.writeInt(postType);
parcel.writeInt(voteType); parcel.writeInt(voteType);
parcel.writeInt(gilded);
parcel.writeInt(previewWidth); parcel.writeInt(previewWidth);
parcel.writeInt(previewHeight); parcel.writeInt(previewHeight);
parcel.writeInt(nComments); parcel.writeInt(nComments);

View File

@ -103,4 +103,6 @@ public class JSONUtils {
public static final String IS_FAVORITED_KEY = "is_favorited"; public static final String IS_FAVORITED_KEY = "is_favorited";
public static final String SUBREDDITS_KEY = "subreddits"; public static final String SUBREDDITS_KEY = "subreddits";
public static final String PATH_KEY = "path"; public static final String PATH_KEY = "path";
public static final String ALL_AWARDINGS_KEY = "all_awardings";
public static final String RESIZED_ICONS_KEY = "resized_icons";
} }

View File

@ -179,16 +179,6 @@
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
<TextView
android:id="@+id/gilded_number_text_view_item_post"
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 <ImageView
android:id="@+id/archived_image_view_item_post" android:id="@+id/archived_image_view_item_post"
android:layout_width="24dp" android:layout_width="24dp"
@ -213,6 +203,12 @@
android:tint="?attr/crosspost" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
<TextView
android:id="@+id/awards_text_view_item_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>
<TextView <TextView

View File

@ -166,16 +166,6 @@
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
<TextView
android:id="@+id/gilded_number_text_view_item_post_compact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/gold"
android:drawablePadding="4dp"
android:textColor="@color/gold"
android:textSize="?attr/font_default"
android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/archived_image_view_item_post_compact" android:id="@+id/archived_image_view_item_post_compact"
android:layout_width="24dp" android:layout_width="24dp"
@ -200,6 +190,12 @@
android:tint="?attr/crosspost" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
<TextView
android:id="@+id/awards_text_view_item_post_compact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>
<TextView <TextView

View File

@ -195,6 +195,12 @@
android:tint="?attr/crosspost" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
<TextView
android:id="@+id/awards_text_view_item_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>
<TextView <TextView