aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-09-17 14:07:03 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-09-17 14:07:03 +0000
commitd6c3bfddd713b064e545461238978d3fa6c9941e (patch)
tree4dcf6ba6cae3c7a7c6d3b3618d705eb5c4987160
parent474b3cf32f53818d5ce430119830052e27f17387 (diff)
downloadinfinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar.gz
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar.bz2
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar.lz
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar.xz
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.tar.zst
infinity-for-reddit-d6c3bfddd713b064e545461238978d3fa6c9941e.zip
Fix marking posts as read on scroll.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java19
1 files changed, 14 insertions, 5 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 e8935f5f..41f06453 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -449,6 +450,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (holder instanceof PostBaseViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) {
if (((PostBaseViewHolder) holder).itemViewIsNotCardView) {
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
@@ -936,6 +938,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostCompactBaseViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostCompactBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) {
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
((PostCompactBaseViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
@@ -1258,6 +1261,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostGalleryViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostGalleryViewHolder) holder).currentPosition = position;
if (post.isRead()) {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
((PostGalleryViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
@@ -1764,8 +1768,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
super.onViewRecycled(holder);
if (holder instanceof PostBaseViewHolder) {
if (mMarkPostsAsReadOnScroll) {
- int position = holder.getBindingAdapterPosition();
- if (position < super.getItemCount() && position >= 0) {
+ int position = ((PostBaseViewHolder) holder).currentPosition;
+ if (position < getItemCount() && position >= 0) {
Post post = getItem(position);
((PostBaseViewHolder) holder).markPostRead(post, false);
}
@@ -1838,8 +1842,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
} else if (holder instanceof PostCompactBaseViewHolder) {
if (mMarkPostsAsReadOnScroll) {
- int position = holder.getBindingAdapterPosition();
- if (position < super.getItemCount() && position >= 0) {
+ int position = ((PostCompactBaseViewHolder) holder).currentPosition;
+ if (position < getItemCount() && position >= 0) {
Post post = getItem(position);
((PostCompactBaseViewHolder) holder).markPostRead(post, false);
}
@@ -1869,7 +1873,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
} else if (holder instanceof PostGalleryViewHolder) {
if (mMarkPostsAsReadOnScroll) {
- int position = holder.getBindingAdapterPosition();
+ int position = ((PostGalleryViewHolder) holder).currentPosition;
if (position < super.getItemCount() && position >= 0) {
Post post = getItem(position);
((PostGalleryViewHolder) holder).markPostRead(post, false);
@@ -2035,6 +2039,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView shareButton;
boolean itemViewIsNotCardView = false;
+ int currentPosition;
PostBaseViewHolder(@NonNull View itemView) {
super(itemView);
@@ -3051,6 +3056,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView shareButton;
View divider;
+ int currentPosition;
+
PostCompactBaseViewHolder(View itemView) {
super(itemView);
}
@@ -3726,6 +3733,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@BindView(R.id.title_text_view_item_post_gallery)
TextView titleTextView;
+ int currentPosition;
+
public PostGalleryViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);