From d6c3bfddd713b064e545461238978d3fa6c9941e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 17 Sep 2021 22:07:03 +0800 Subject: Fix marking posts as read on scroll. --- .../adapters/PostRecyclerViewAdapter.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'app/src') 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= 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= 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= 0) { Post post = getItem(position); ((PostGalleryViewHolder) holder).markPostRead(post, false); @@ -2035,6 +2039,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter