diff options
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); |