diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-01-18 15:37:08 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-01-18 15:37:08 +0000 |
commit | ea837718bf1c005d43ab79795706dd37c8070af5 (patch) | |
tree | 0af8949ac02c0e73fabccc10b70fa9ba5ce71ef4 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | f13d4576e1330f69c868cd0b3d4cf605801edf94 (diff) | |
download | infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar.gz infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar.bz2 infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar.lz infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar.xz infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.tar.zst infinity-for-reddit-ea837718bf1c005d43ab79795706dd37c8070af5.zip |
Don't hide read posts after initial post loading even if Hide Read Posts Automatically is enabled.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
3 files changed, 14 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 8064779f..a830dd53 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -407,7 +407,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post post = getItem(position); if (post != null) { if (post.isRead()) { - if (mHideReadPostsAutomatically || position < mHideReadPostsIndex) { + if ((mHideReadPostsAutomatically && !post.isHiddenManuallyByUser()) || position < mHideReadPostsIndex) { post.hidePostInRecyclerView(); holder.itemView.setVisibility(View.GONE); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams(); @@ -736,7 +736,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView Post post = getItem(position); if (post != null) { if (post.isRead()) { - if (mHideReadPostsAutomatically || position < mHideReadPostsIndex) { + if ((mHideReadPostsAutomatically && !post.isHiddenManuallyByUser()) || position < mHideReadPostsIndex) { post.hidePostInRecyclerView(); holder.itemView.setVisibility(View.GONE); ViewGroup.LayoutParams params = holder.itemView.getLayoutParams(); @@ -1980,7 +1980,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView void markPostRead(Post post, boolean changePostItemColor) { if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) { - post.markAsRead(); + post.markAsRead(true); if (changePostItemColor) { cardView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor)); titleTextView.setTextColor(mReadPostTitleColor); @@ -3033,7 +3033,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView void markPostRead(Post post, boolean changePostItemColor) { if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) { - post.markAsRead(); + post.markAsRead(true); if (changePostItemColor) { itemView.setBackgroundColor(mReadPostCardViewBackgroundColor); titleTextView.setTextColor(mReadPostTitleColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index d6bced34..809f0806 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -565,7 +565,7 @@ public class ParsePost { JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); Post post = parseBasicData(data); if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) { - post.markAsRead(); + post.markAsRead(false); } if (PostFilter.isPostAllowed(post, postFilter)) { newPosts.add(post); 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 9449b050..c55d3840 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -73,6 +73,7 @@ public class Post implements Parcelable { private boolean isCrosspost; private boolean isRead; private boolean isHiddenInRecyclerView = false; + private boolean isHiddenManuallyByUser = false; private String crosspostParentId; private ArrayList<Preview> previews = new ArrayList<>(); private ArrayList<Gallery> gallery = new ArrayList<>(); @@ -189,6 +190,7 @@ public class Post implements Parcelable { isCrosspost = in.readByte() != 0; isRead = in.readByte() != 0; isHiddenInRecyclerView = in.readByte() != 0; + isHiddenManuallyByUser = in.readByte() != 0; crosspostParentId = in.readString(); in.readTypedList(previews, Preview.CREATOR); in.readTypedList(gallery, Gallery.CREATOR); @@ -452,8 +454,9 @@ public class Post implements Parcelable { return isCrosspost; } - public void markAsRead() { + public void markAsRead(boolean isHiddenManuallyByUser) { isRead = true; + this.isHiddenManuallyByUser = isHiddenManuallyByUser; } public boolean isRead() { @@ -468,6 +471,10 @@ public class Post implements Parcelable { isHiddenInRecyclerView = true; } + public boolean isHiddenManuallyByUser() { + return isHiddenManuallyByUser; + } + public String getCrosspostParentId() { return crosspostParentId; } @@ -534,6 +541,7 @@ public class Post implements Parcelable { parcel.writeByte((byte) (isCrosspost ? 1 : 0)); parcel.writeByte((byte) (isRead ? 1 : 0)); parcel.writeByte((byte) (isHiddenInRecyclerView ? 1 : 0)); + parcel.writeByte((byte) (isHiddenManuallyByUser ? 1 : 0)); parcel.writeString(crosspostParentId); parcel.writeTypedList(previews); parcel.writeTypedList(gallery); |