From 9db90a04317dcdcc5cce6b0954371b62084153a8 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Mon, 20 Feb 2023 12:01:54 -0500 Subject: Fix https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/736 --- .../adapters/CommentsRecyclerViewAdapter.java | 3 +- .../fragments/ViewPostDetailFragment.java | 28 +++++++++++---- .../infinityforreddit/post/ParsePost.java | 40 +++++++++++----------- .../infinityforreddit/post/Post.java | 13 +++++-- .../infinityforreddit/utils/JSONUtils.java | 1 + 5 files changed, 55 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 74c0ef53..de67008f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -22,7 +22,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.content.res.AppCompatResources; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import androidx.recyclerview.widget.ItemTouchHelper; @@ -1908,7 +1907,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter previews = new ArrayList<>(); private ArrayList gallery = new ArrayList<>(); @@ -86,7 +87,7 @@ public class Post implements Parcelable { String title, String permalink, int score, int postType, int voteType, int nComments, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean isCrosspost, String distinguished) { + boolean isCrosspost, String distinguished, String suggestedSort) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -115,6 +116,7 @@ public class Post implements Parcelable { this.saved = saved; this.isCrosspost = isCrosspost; this.distinguished = distinguished; + this.suggestedSort = suggestedSort; isRead = false; } @@ -123,7 +125,7 @@ public class Post implements Parcelable { String url, String permalink, int score, int postType, int voteType, int nComments, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean isCrosspost, String distinguished) { + boolean isCrosspost, String distinguished, String suggestedSort) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -153,6 +155,7 @@ public class Post implements Parcelable { this.saved = saved; this.isCrosspost = isCrosspost; this.distinguished = distinguished; + this.suggestedSort = suggestedSort; isRead = false; } @@ -202,6 +205,7 @@ public class Post implements Parcelable { isRead = in.readByte() != 0; crosspostParentId = in.readString(); distinguished = in.readString(); + suggestedSort = in.readString(); in.readTypedList(previews, Preview.CREATOR); in.readTypedList(gallery, Gallery.CREATOR); } @@ -399,6 +403,10 @@ public class Post implements Parcelable { return distinguished != null && distinguished.equals("admin"); } + public String getSuggestedSort() { + return suggestedSort; + } + public String getAwards() { return awards; } @@ -587,6 +595,7 @@ public class Post implements Parcelable { parcel.writeByte((byte) (isRead ? 1 : 0)); parcel.writeString(crosspostParentId); parcel.writeString(distinguished); + parcel.writeString(suggestedSort); parcel.writeTypedList(previews); parcel.writeTypedList(gallery); } 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 968dcbae..2726311a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -180,4 +180,5 @@ public class JSONUtils { public static final String STATUS_KEY = "status"; public static final String URLS_KEY = "urls"; public static final String HD_KEY = "hd"; + public static final String SUGGESTED_SORT_KEY = "suggested_sort"; } -- cgit v1.2.3