From 2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 18 Apr 2020 14:00:37 +0800 Subject: Show the number of awards in PostRecyclerView instead. --- .../Adapter/PostRecyclerViewAdapter.java | 12 ++++--- .../infinityforreddit/ParsePost.java | 41 ++++++++++++---------- .../infinityforreddit/Post/Post.java | 16 +++++++-- app/src/main/res/layout/item_post.xml | 25 ++++++------- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/values/styles.xml | 4 +-- 6 files changed, 58 insertions(+), 42 deletions(-) (limited to 'app') 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 ca001e85..fd9b8f44 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Adapter; import android.content.Intent; import android.content.res.ColorStateList; +import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -242,7 +243,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { @@ -451,9 +452,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0) { ((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); - Utils.setHTMLWithImageToTextView(((PostViewHolder) holder).awardsTextView, awards); + ((PostViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, nAwards)); } switch (voteType) { @@ -1604,7 +1605,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 4) { String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY); @@ -131,16 +133,16 @@ public class ParsePost { Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight, - score, voteType, nComments, flair, awardingsBuilder.toString(), hidden, spoiler, - nsfw, stickied, archived, locked, saved, true); + score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, true); post.setCrosspostParentId(crosspostParent.getId()); return post; } else { return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight, - score, voteType, nComments, flair, awardingsBuilder.toString(), hidden, spoiler, - nsfw, stickied, archived, locked, saved, false); + score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, false); } } @@ -150,8 +152,9 @@ public class ParsePost { long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, int previewWidth, int previewHeight, 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 { + String awards, int nAwards, boolean hidden, boolean spoiler, + boolean nsfw, boolean stickied, boolean archived, boolean locked, + boolean saved, boolean isCrosspost) throws JSONException { Post post; boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY); @@ -163,7 +166,7 @@ public class ParsePost { int postType = Post.TEXT_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, - title, permalink, score, postType, voteType, nComments, flair, awards, + title, permalink, score, postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -189,7 +192,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score, postType, voteType, - nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, + nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); @@ -200,7 +203,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, - voteType, nComments, flair, awards, hidden, spoiler, nsfw, stickied, + voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -225,7 +228,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType, - nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, locked, + nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); @@ -244,7 +247,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType, - nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, + nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -258,8 +261,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score, postType, - voteType, nComments, flair, awards, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost); + voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, + stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -269,7 +272,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, score, - postType, voteType, nComments, flair, awards, hidden, spoiler, + postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); @@ -283,8 +286,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, permalink, score, postType, voteType, nComments, flair, - awards, hidden, spoiler, nsfw, stickied, archived, locked, saved, - isCrosspost); + awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, + saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -312,7 +315,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, score, - postType, voteType, nComments, flair, awards, hidden, spoiler, + postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -333,7 +336,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, - voteType, nComments, flair, awards, hidden, spoiler, nsfw, stickied, + voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviewWidth(previewWidth); post.setPreviewHeight(previewHeight); @@ -344,7 +347,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score, postType, voteType, - nComments, flair, awards, hidden, spoiler, nsfw, stickied, archived, + nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); } } 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 d16a19a1..d8b98ad8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java @@ -51,6 +51,7 @@ public class Post implements Parcelable { private String permalink; private String flair; private String awards; + private int nAwards; private long postTimeMillis; private int score; private int postType; @@ -72,7 +73,7 @@ public class Post implements Parcelable { String author, String authorFlair, String authorFlairHTML, String postTime, long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, String permalink, int score, int postType, int voteType, int nComments, String flair, - String awards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, + String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) { this.id = id; this.fullName = fullName; @@ -94,6 +95,7 @@ public class Post implements Parcelable { this.nComments = nComments; this.flair = flair; this.awards = awards; + this.nAwards = nAwards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -108,7 +110,7 @@ public class Post implements Parcelable { String author, String authorFlair, String authorFlairHTML, String postTime, long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl, String url, String permalink, int score, int postType, int voteType, int nComments, - String flair, String awards, boolean hidden, boolean spoiler, boolean nsfw, + String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) { this.id = id; this.fullName = fullName; @@ -131,6 +133,7 @@ public class Post implements Parcelable { this.nComments = nComments; this.flair = flair; this.awards = awards; + this.nAwards = nAwards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -144,7 +147,7 @@ public class Post implements Parcelable { public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String authorFlair, String authorFlairHTML, String postTime, long postTimeMillis, String title, String permalink, int score, int postType, - int voteType, int nComments, String flair, String awards, boolean hidden, + int voteType, int nComments, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) { this.id = id; @@ -165,6 +168,7 @@ public class Post implements Parcelable { this.nComments = nComments; this.flair = flair; this.awards = awards; + this.nAwards = nAwards; this.hidden = hidden; this.spoiler = spoiler; this.nsfw = nsfw; @@ -200,6 +204,7 @@ public class Post implements Parcelable { permalink = in.readString(); flair = in.readString(); awards = in.readString(); + nAwards = in.readInt(); score = in.readInt(); postType = in.readInt(); voteType = in.readInt(); @@ -349,6 +354,10 @@ public class Post implements Parcelable { return awards; } + public int getnAwards() { + return nAwards; + } + public int getScore() { return score; } @@ -480,6 +489,7 @@ public class Post implements Parcelable { parcel.writeString(permalink); parcel.writeString(flair); parcel.writeString(awards); + parcel.writeInt(nAwards); parcel.writeInt(score); parcel.writeInt(postType); parcel.writeInt(voteType); diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index b2030d63..5f2b0d15 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -94,8 +94,7 @@ android:layout_height="wrap_content" android:paddingStart="16dp" android:paddingEnd="16dp" - android:textSize="?attr/title_font_18" - android:textColor="?attr/primaryTextColor" /> + android:textSize="?attr/title_font_18" /> @@ -135,7 +133,6 @@ android:layout_gravity="center" android:text="@string/spoiler" android:textSize="?attr/font_12" - android:textColor="@android:color/white" android:padding="4dp" android:visibility="gone" app:lib_setRadius="3dp" @@ -149,7 +146,6 @@ android:padding="4dp" android:text="@string/nsfw" android:textSize="?attr/font_12" - android:textColor="@android:color/white" android:visibility="gone" app:lib_setRadius="3dp" app:lib_setRoundedView="true" @@ -161,13 +157,24 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="?attr/font_12" - android:textColor="@android:color/white" android:padding="4dp" android:visibility="gone" app:lib_setRadius="3dp" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> + + - - Edit Multireddit Delete Multireddit + %1$d Awards + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 68f78baa..47efff57 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -38,9 +38,7 @@ true - +