mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Fix marking posts as read on scroll.
This commit is contained in:
parent
474b3cf32f
commit
d6c3bfddd7
@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -449,6 +450,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if (holder instanceof PostBaseViewHolder) {
|
if (holder instanceof PostBaseViewHolder) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
|
((PostBaseViewHolder) holder).currentPosition = position;
|
||||||
if (post.isRead()) {
|
if (post.isRead()) {
|
||||||
if (((PostBaseViewHolder) holder).itemViewIsNotCardView) {
|
if (((PostBaseViewHolder) holder).itemViewIsNotCardView) {
|
||||||
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
||||||
@ -936,6 +938,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
} else if (holder instanceof PostCompactBaseViewHolder) {
|
} else if (holder instanceof PostCompactBaseViewHolder) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
|
((PostCompactBaseViewHolder) holder).currentPosition = position;
|
||||||
if (post.isRead()) {
|
if (post.isRead()) {
|
||||||
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
||||||
((PostCompactBaseViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
((PostCompactBaseViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
||||||
@ -1258,6 +1261,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
} else if (holder instanceof PostGalleryViewHolder) {
|
} else if (holder instanceof PostGalleryViewHolder) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
|
((PostGalleryViewHolder) holder).currentPosition = position;
|
||||||
if (post.isRead()) {
|
if (post.isRead()) {
|
||||||
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
||||||
((PostGalleryViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
((PostGalleryViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
||||||
@ -1764,8 +1768,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
super.onViewRecycled(holder);
|
super.onViewRecycled(holder);
|
||||||
if (holder instanceof PostBaseViewHolder) {
|
if (holder instanceof PostBaseViewHolder) {
|
||||||
if (mMarkPostsAsReadOnScroll) {
|
if (mMarkPostsAsReadOnScroll) {
|
||||||
int position = holder.getBindingAdapterPosition();
|
int position = ((PostBaseViewHolder) holder).currentPosition;
|
||||||
if (position < super.getItemCount() && position >= 0) {
|
if (position < getItemCount() && position >= 0) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
((PostBaseViewHolder) holder).markPostRead(post, false);
|
((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);
|
((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
} else if (holder instanceof PostCompactBaseViewHolder) {
|
} else if (holder instanceof PostCompactBaseViewHolder) {
|
||||||
if (mMarkPostsAsReadOnScroll) {
|
if (mMarkPostsAsReadOnScroll) {
|
||||||
int position = holder.getBindingAdapterPosition();
|
int position = ((PostCompactBaseViewHolder) holder).currentPosition;
|
||||||
if (position < super.getItemCount() && position >= 0) {
|
if (position < getItemCount() && position >= 0) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
((PostCompactBaseViewHolder) holder).markPostRead(post, false);
|
((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);
|
((PostCompactBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
} else if (holder instanceof PostGalleryViewHolder) {
|
} else if (holder instanceof PostGalleryViewHolder) {
|
||||||
if (mMarkPostsAsReadOnScroll) {
|
if (mMarkPostsAsReadOnScroll) {
|
||||||
int position = holder.getBindingAdapterPosition();
|
int position = ((PostGalleryViewHolder) holder).currentPosition;
|
||||||
if (position < super.getItemCount() && position >= 0) {
|
if (position < super.getItemCount() && position >= 0) {
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
((PostGalleryViewHolder) holder).markPostRead(post, false);
|
((PostGalleryViewHolder) holder).markPostRead(post, false);
|
||||||
@ -2035,6 +2039,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
ImageView shareButton;
|
ImageView shareButton;
|
||||||
|
|
||||||
boolean itemViewIsNotCardView = false;
|
boolean itemViewIsNotCardView = false;
|
||||||
|
int currentPosition;
|
||||||
|
|
||||||
PostBaseViewHolder(@NonNull View itemView) {
|
PostBaseViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -3051,6 +3056,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
ImageView shareButton;
|
ImageView shareButton;
|
||||||
View divider;
|
View divider;
|
||||||
|
|
||||||
|
int currentPosition;
|
||||||
|
|
||||||
PostCompactBaseViewHolder(View itemView) {
|
PostCompactBaseViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
@ -3726,6 +3733,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
@BindView(R.id.title_text_view_item_post_gallery)
|
@BindView(R.id.title_text_view_item_post_gallery)
|
||||||
TextView titleTextView;
|
TextView titleTextView;
|
||||||
|
|
||||||
|
int currentPosition;
|
||||||
|
|
||||||
public PostGalleryViewHolder(@NonNull View itemView) {
|
public PostGalleryViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
|
Loading…
Reference in New Issue
Block a user