From f25f75b3d058ccc5aadc4cd625b28bc22925a727 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 7 Dec 2020 22:11:54 +0800 Subject: Fix wrong vote info showing in posts and comments. --- .../CommentAndPostRecyclerViewAdapter.java | 81 +++++++---- .../adapters/PostRecyclerViewAdapter.java | 153 ++++++++++++++------- 2 files changed, 154 insertions(+), 80 deletions(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java index 942f0a6f..c18b2faa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java @@ -3487,27 +3487,35 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { Comment comment = getCurrentComment(this); if (comment != null) { + int position = getAdapterPosition(); if (comment.isSaved()) { comment.setSaved(false); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { comment.setSaved(false); - saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + if (getAdapterPosition() == position) { + saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + } Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show(); } @Override public void failed() { comment.setSaved(true); - saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + if (getAdapterPosition() == position) { + saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + } Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show(); } }); @@ -3613,14 +3634,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter