diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-04-18 06:00:37 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-04-18 06:00:37 +0000 |
commit | 2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2 (patch) | |
tree | 4ab15042351e701cfd5eead28a494f2215ec11e9 /app | |
parent | bde2220d91774337fba60cfdcc4324005b878736 (diff) | |
download | infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar.gz infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar.bz2 infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar.lz infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar.xz infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.tar.zst infinity-for-reddit-2f72e654eb9b3f92fc03a5b877a4ebcacbdcdab2.zip |
Show the number of awards in PostRecyclerView instead.
Diffstat (limited to '')
6 files changed, 58 insertions, 42 deletions
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<Post, RecyclerView boolean nsfw = post.isNSFW(); boolean spoiler = post.isSpoiler(); String flair = post.getFlair(); - String awards = post.getAwards(); + int nAwards = post.getnAwards(); boolean isArchived = post.isArchived(); ((PostViewHolder) holder).cardView.setOnClickListener(view -> { @@ -451,9 +452,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostViewHolder) holder).flairTextView.setText(flairHTML); } - if (awards != null && !awards.equals("")) { + if (nAwards > 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<Post, RecyclerView @BindView(R.id.flair_custom_text_view_item_post) CustomTextView flairTextView; @BindView(R.id.awards_text_view_item_post) - TextView awardsTextView; + CustomTextView awardsTextView; @BindView(R.id.link_text_view_item_post) TextView linkTextView; @BindView(R.id.image_view_wrapper_item_post) @@ -1684,7 +1685,8 @@ 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(mSecondaryTextColor); + awardsTextView.setBackgroundColor(Color.parseColor("#EEAB02")); + awardsTextView.setTextColor(Color.parseColor("#FFFFFF")); 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 b8cd4977..3a4845e1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -79,9 +79,11 @@ public class ParsePost { String flair = postFlairHTMLBuilder.toString(); StringBuilder awardingsBuilder = new StringBuilder(); JSONArray awardingsArray = data.getJSONArray(JSONUtils.ALL_AWARDINGS_KEY); + int nAwards = 0; for (int i = 0; i < awardingsArray.length(); i++) { JSONObject award = awardingsArray.getJSONObject(i); int count = award.getInt(JSONUtils.COUNT_KEY); + nAwards += count; JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY); if (icons.length() > 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" /> <TextView android:id="@+id/content_text_view_item_post" @@ -123,7 +122,6 @@ android:layout_height="wrap_content" android:padding="4dp" android:textSize="?attr/font_12" - android:textColor="@android:color/white" app:lib_setRadius="3dp" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -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" /> + <com.libRG.CustomTextView + android:id="@+id/awards_text_view_item_post" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:textSize="?attr/font_12" + android:textColor="#EEAB02" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + <ImageView android:id="@+id/archived_image_view_item_post" android:layout_width="24dp" @@ -189,12 +196,6 @@ android:src="@drawable/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/values/strings.xml b/app/src/main/res/values/strings.xml index 38a1ab79..80a32a3f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -687,4 +687,6 @@ <string name="edit_multi_reddit">Edit Multireddit</string> <string name="delete_multi_reddit">Delete Multireddit</string> + <string name="n_awards">%1$d Awards</string> + </resources> 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 @@ <item name="android:windowTranslucentNavigation">true</item> </style> - <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar"> - <!--<item name="android:textColorPrimary">?attr/toolbarPrimaryTextAndIconColor</item>--> - </style> + <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" /> |