diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-04-16 08:10:07 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-04-16 08:10:07 +0000 |
commit | 9cbe542c8503c53f9e5a2836ce1e22c499e538bc (patch) | |
tree | 441f40d84dd1e5b302879f090bb5d4e076ae496e /app/src/main | |
parent | 4260c6c14e0001310da5e9a237e1f9b3da0f79a6 (diff) | |
download | infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar.gz infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar.bz2 infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar.lz infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar.xz infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.tar.zst infinity-for-reddit-9cbe542c8503c53f9e5a2836ce1e22c499e538bc.zip |
Show all post awards.
Diffstat (limited to '')
8 files changed, 127 insertions, 86 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 d103ce96..4338209e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -545,12 +545,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy ((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()) { ((PostDetailViewHolder) holder).mArchivedImageView.setVisibility(View.VISIBLE); } @@ -575,6 +569,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy ((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()) { ((PostDetailViewHolder) holder).mNSFWTextView.setOnClickListener(view -> { Intent intent = new Intent(mActivity, FilteredThingActivity.class); @@ -1809,8 +1815,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy RecyclerView mContentMarkdownView; @BindView(R.id.type_text_view_item_post_detail) CustomTextView mTypeTextView; - @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.archived_image_view_item_post_detail) @@ -1823,6 +1827,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mSpoilerTextView; @BindView(R.id.flair_custom_text_view_item_post_detail) CustomTextView mFlairTextView; + @BindView(R.id.awards_text_view_item_post_detail) + TextView mAwardsTextView; @BindView(R.id.link_text_view_item_post_detail) TextView mLinkTextView; @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); mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN); mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN); + mAwardsTextView.setTextColor(mPostTitleColor); mLinkTextView.setTextColor(mSecondaryTextColor); mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); mNoPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index e8db17ee..27e77146 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -239,10 +239,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView final String postTime = post.getPostTime(); final String title = post.getTitle(); int voteType = post.getVoteType(); - int gilded = post.getGilded(); boolean nsfw = post.isNSFW(); boolean spoiler = post.isSpoiler(); String flair = post.getFlair(); + String awards = post.getAwards(); boolean isArchived = post.isArchived(); ((PostViewHolder) holder).cardView.setOnClickListener(view -> { @@ -418,12 +418,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostViewHolder) holder).titleTextView.setText(title); ((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()) { ((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); } @@ -457,6 +451,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((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) { case 1: //Upvoted @@ -810,10 +816,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView final String postTime = post.getPostTime(); final String title = post.getTitle(); int voteType = post.getVoteType(); - int gilded = post.getGilded(); boolean nsfw = post.isNSFW(); boolean spoiler = post.isSpoiler(); String flair = post.getFlair(); + String awards = post.getAwards(); boolean isArchived = post.isArchived(); ((PostCompactViewHolder) holder).itemView.setOnClickListener(view -> { @@ -983,12 +989,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostCompactViewHolder) holder).titleTextView.setText(title); ((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()) { ((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); } @@ -1022,6 +1022,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((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) { case 1: //Upvoted @@ -1517,13 +1529,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mGlide.clear(((PostViewHolder) holder).iconGifImageView); ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((PostViewHolder) holder).relativeLayout.setVisibility(View.GONE); - ((PostViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE); ((PostViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((PostViewHolder) holder).archivedImageView.setVisibility(View.GONE); ((PostViewHolder) holder).lockedImageView.setVisibility(View.GONE); ((PostViewHolder) holder).nsfwTextView.setVisibility(View.GONE); ((PostViewHolder) holder).spoilerTextView.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).progressBar.setVisibility(View.GONE); ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START); @@ -1541,13 +1555,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mGlide.clear(((PostCompactViewHolder) holder).iconGifImageView); ((PostCompactViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).relativeLayout.setVisibility(View.GONE); - ((PostCompactViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).archivedImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).lockedImageView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).nsfwTextView.setVisibility(View.GONE); ((PostCompactViewHolder) holder).spoilerTextView.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).progressBar.setVisibility(View.GONE); ((PostCompactViewHolder) holder).imageView.setVisibility(View.GONE); @@ -1582,8 +1598,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView TextView titleTextView; @BindView(R.id.type_text_view_item_post) CustomTextView typeTextView; - @BindView(R.id.gilded_number_text_view_item_post) - TextView gildedNumberTextView; @BindView(R.id.archived_image_view_item_post) ImageView archivedImageView; @BindView(R.id.locked_image_view_item_post) @@ -1596,6 +1610,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView CustomTextView spoilerTextView; @BindView(R.id.flair_custom_text_view_item_post) CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post) + TextView awardsTextView; @BindView(R.id.link_text_view_item_post) TextView linkTextView; @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); lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN); + awardsTextView.setTextColor(mPostTitleColor); linkTextView.setTextColor(mSecondaryTextColor); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); @@ -1701,8 +1718,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView TextView titleTextView; @BindView(R.id.type_text_view_item_post_compact) CustomTextView typeTextView; - @BindView(R.id.gilded_number_text_view_item_post_compact) - TextView gildedNumberTextView; @BindView(R.id.archived_image_view_item_post_compact) ImageView archivedImageView; @BindView(R.id.locked_image_view_item_post_compact) @@ -1715,6 +1730,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView CustomTextView spoilerTextView; @BindView(R.id.flair_custom_text_view_item_post_compact) CustomTextView flairTextView; + @BindView(R.id.awards_text_view_item_post_compact) + TextView awardsTextView; @BindView(R.id.link_text_view_item_post_compact) TextView linkTextView; @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); lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN); + awardsTextView.setTextColor(mPostTitleColor); linkTextView.setTextColor(mSecondaryTextColor); progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 0974cbdf..3874de35 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -41,7 +41,6 @@ public class ParsePost { String title = data.getString(JSONUtils.TITLE_KEY); int score = data.getInt(JSONUtils.SCORE_KEY); int voteType; - int gilded = data.getInt(JSONUtils.GILDED_KEY); int nComments = data.getInt(JSONUtils.NUM_COMMENTS_KEY); boolean hidden = data.getBoolean(JSONUtils.HIDDEN_KEY); boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY); @@ -64,6 +63,20 @@ public class ParsePost { } } 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)) { voteType = 0; @@ -103,15 +116,17 @@ public class ParsePost { Post crosspostParent = parseBasicData(data, locale); Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, - previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, - nsfw, stickied, archived, locked, saved, true); + previewWidth, previewHeight, score, voteType, nComments, flair, + awardingsBuilder.toString(), hidden, spoiler, nsfw, stickied, archived, locked, + saved, true); post.setCrosspostParentId(crosspostParent.getId()); return post; } else { return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, - previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, - nsfw, stickied, archived, locked, saved, false); + previewWidth, previewHeight, score, voteType, nComments, flair, + awardingsBuilder.toString(), hidden, spoiler, nsfw, stickied, archived, locked, + saved, false); } } @@ -119,8 +134,8 @@ public class ParsePost { String subredditName, String subredditNamePrefixed, String author, String formattedPostTime, long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, int previewWidth, int previewHeight, - int score, int voteType, int gilded, int nComments, String flair, - boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, + int score, int voteType, int nComments, String flair, + String awards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) throws JSONException { Post post; @@ -132,7 +147,7 @@ public class ParsePost { //Text post int postType = Post.TEXT_TYPE; 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); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -157,7 +172,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); @@ -167,7 +182,7 @@ public class ParsePost { int postType = Post.NO_PREVIEW_LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis, 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)) { post.setSelfText(""); } else { @@ -190,7 +205,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis, 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.setPreviewHeight(previewHeight); @@ -207,7 +222,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -220,7 +235,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); @@ -230,7 +245,7 @@ public class ParsePost { int postType = Post.GIF_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); @@ -243,7 +258,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); @@ -271,7 +286,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -291,7 +306,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -301,7 +316,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, 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); } } @@ -402,7 +417,7 @@ public class ParsePost { if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) { JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); Post post = parseBasicData(data, locale); - if (post != null && !(!nsfw && post.isNSFW())) { + if (!(!nsfw && post.isNSFW())) { if (filter == PostFragment.EXTRA_NO_FILTER) { newPosts.add(post); } else if (filter == post.getPostType()) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java index 8a025c97..a224ee24 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java @@ -48,11 +48,11 @@ public class Post implements Parcelable { private String videoDownloadUrl; private String permalink; private String flair; + private String awards; private long postTimeMillis; private int score; private int postType; private int voteType; - private int gilded; private int previewWidth; private int previewHeight; private int nComments; @@ -69,9 +69,9 @@ public class Post implements Parcelable { public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String postTime, long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, String permalink, int score, int postType, - int voteType, int gilded, int nComments, String flair, boolean hidden, boolean spoiler, - boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean isCrosspost) { + int voteType, int nComments, String flair, String awards, boolean hidden, + boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, + boolean saved, boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -87,9 +87,9 @@ public class Post implements Parcelable { this.score = score; this.postType = postType; this.voteType = voteType; - this.gilded = gilded; this.nComments = nComments; this.flair = flair; + this.awards = awards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -103,9 +103,9 @@ public class Post implements Parcelable { public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String postTime, long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, String url, String permalink, int score, - int postType, int voteType, int gilded, int nComments, String flair, boolean hidden, - boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, - boolean saved, boolean isCrosspost) { + 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) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -122,9 +122,9 @@ public class Post implements Parcelable { this.score = score; this.postType = postType; this.voteType = voteType; - this.gilded = gilded; this.nComments = nComments; this.flair = flair; + this.awards = awards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -135,9 +135,10 @@ public class Post implements Parcelable { this.isCrosspost = isCrosspost; } - public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, - String postTime, long postTimeMillis, String title, String permalink, int score, int postType, int voteType, int gilded, - int nComments, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, + public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, + String author, String postTime, long postTimeMillis, String title, String permalink, + 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) { this.id = id; this.fullName = fullName; @@ -152,9 +153,9 @@ public class Post implements Parcelable { this.score = score; this.postType = postType; this.voteType = voteType; - this.gilded = gilded; this.nComments = nComments; this.flair = flair; + this.awards = awards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -187,10 +188,10 @@ public class Post implements Parcelable { videoDownloadUrl = in.readString(); permalink = in.readString(); flair = in.readString(); + awards = in.readString(); score = in.readInt(); postType = in.readInt(); voteType = in.readInt(); - gilded = in.readInt(); previewWidth = in.readInt(); previewHeight = in.readInt(); nComments = in.readInt(); @@ -325,6 +326,10 @@ public class Post implements Parcelable { this.flair = flair; } + public String getAwards() { + return awards; + } + public int getScore() { return score; } @@ -345,10 +350,6 @@ public class Post implements Parcelable { this.voteType = voteType; } - public int getGilded() { - return gilded; - } - public int getPreviewWidth() { return previewWidth; } @@ -457,10 +458,10 @@ public class Post implements Parcelable { parcel.writeString(videoDownloadUrl); parcel.writeString(permalink); parcel.writeString(flair); + parcel.writeString(awards); parcel.writeInt(score); parcel.writeInt(postType); parcel.writeInt(voteType); - parcel.writeInt(gilded); parcel.writeInt(previewWidth); parcel.writeInt(previewHeight); parcel.writeInt(nComments); 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 b7aae929..603717d4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java @@ -103,4 +103,6 @@ public class JSONUtils { public static final String IS_FAVORITED_KEY = "is_favorited"; public static final String SUBREDDITS_KEY = "subreddits"; 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"; } diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index ad3d1aca..7e1e25cc 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -179,16 +179,6 @@ app:lib_setRoundedView="true" 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 android:id="@+id/archived_image_view_item_post" android:layout_width="24dp" @@ -213,6 +203,12 @@ android:tint="?attr/crosspost" 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> <TextView diff --git a/app/src/main/res/layout/item_post_compact.xml b/app/src/main/res/layout/item_post_compact.xml index 486b0dc8..edf83fd0 100644 --- a/app/src/main/res/layout/item_post_compact.xml +++ b/app/src/main/res/layout/item_post_compact.xml @@ -166,16 +166,6 @@ app:lib_setRoundedView="true" 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 android:id="@+id/archived_image_view_item_post_compact" android:layout_width="24dp" @@ -200,6 +190,12 @@ android:tint="?attr/crosspost" 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> <TextView diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml index 3c08ca6a..15695b23 100644 --- a/app/src/main/res/layout/item_post_detail.xml +++ b/app/src/main/res/layout/item_post_detail.xml @@ -195,6 +195,12 @@ android:tint="?attr/crosspost" 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> <TextView |