aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-07 16:18:04 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-07 16:18:04 +0000
commit69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23 (patch)
tree6f163560e801fbebafde3545d7010c44150ce507 /app
parenta4232a54bd388032653281ec773de6a582c7583b (diff)
downloadinfinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar.gz
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar.bz2
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar.lz
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar.xz
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.tar.zst
infinity-for-reddit-69af53ddbabfa4d2b3cd6f4e1fb49dc0a697aa23.zip
Prevent inserting read posts into database multiple times when clicking posts.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java30
1 files changed, 17 insertions, 13 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 dfed1b2d..76df281b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1880,14 +1880,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
void markPostRead(Post post) {
- post.markAsRead();
- cardView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
- titleTextView.setTextColor(mReadPostTitleColor);
- if (this instanceof PostTextTypeViewHolder) {
- ((PostTextTypeViewHolder) this).contentTextView.setTextColor(mReadPostContentColor);
- }
- if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
- ((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
+ if (!post.isRead()) {
+ post.markAsRead();
+ cardView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
+ titleTextView.setTextColor(mReadPostTitleColor);
+ if (this instanceof PostTextTypeViewHolder) {
+ ((PostTextTypeViewHolder) this).contentTextView.setTextColor(mReadPostContentColor);
+ }
+ if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
+ ((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
+ }
}
}
}
@@ -2933,11 +2935,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
void markPostRead(Post post) {
- post.markAsRead();
- itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
- titleTextView.setTextColor(mReadPostTitleColor);
- if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
- ((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
+ if (!post.isRead()) {
+ post.markAsRead();
+ itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
+ titleTextView.setTextColor(mReadPostTitleColor);
+ if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
+ ((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
+ }
}
}
}