aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java81
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java153
2 files changed, 154 insertions, 80 deletions
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<Recy
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType())));
+ int position = getAdapterPosition();
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
- upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mUpvotedColor);
- topScoreTextView.setTextColor(mUpvotedColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ topScoreTextView.setTextColor(mUpvotedColor);
+ }
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mCommentIconAndInfoColor);
- topScoreTextView.setTextColor(mSecondaryTextColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ topScoreTextView.setTextColor(mSecondaryTextColor);
+ }
}
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- topScoreTextView.setText(mActivity.getString(R.string.top_score,
- Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType())));
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(mActivity.getString(R.string.top_score,
+ Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType())));
+ }
}
@Override
@@ -3557,27 +3565,35 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType())));
+ int position = getAdapterPosition();
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
- downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mDownvotedColor);
- topScoreTextView.setTextColor(mDownvotedColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ topScoreTextView.setTextColor(mDownvotedColor);
+ }
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mCommentIconAndInfoColor);
- topScoreTextView.setTextColor(mSecondaryTextColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ topScoreTextView.setTextColor(mSecondaryTextColor);
+ }
}
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- topScoreTextView.setText(mActivity.getString(R.string.top_score,
- Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType())));
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(mActivity.getString(R.string.top_score,
+ Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType())));
+ }
}
@Override
@@ -3590,20 +3606,25 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
saveButton.setOnClickListener(view -> {
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<Recy
@Override
public void success() {
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_saved_success, Toast.LENGTH_SHORT).show();
}
@Override
public void failed() {
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_saved_failed, Toast.LENGTH_SHORT).show();
}
});
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 ab735cb2..dfed1b2d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1677,19 +1677,25 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
post.setVoteType(1);
- upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mUpvotedColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ }
} else {
post.setVoteType(0);
- upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mPostIconAndInfoColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
}
- downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1698,10 +1704,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void onVoteThingFail(int position1) {
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- scoreTextView.setTextColor(previousScoreTextViewColor);
+ if (getAdapterPosition() == position) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1755,19 +1763,25 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1);
- downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mDownvotedColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ }
} else {
post.setVoteType(0);
- downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mPostIconAndInfoColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
}
- upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1776,10 +1790,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void onVoteThingFail(int position1) {
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- scoreTextView.setTextColor(previousScoreTextViewColor);
+ if (getAdapterPosition() == position) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1806,7 +1822,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void success() {
post.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.post_unsaved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1814,7 +1832,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.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.post_unsaved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1826,7 +1846,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void success() {
post.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.post_saved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -1834,7 +1856,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.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.post_saved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2705,19 +2729,25 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
post.setVoteType(1);
- upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mUpvotedColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ }
} else {
post.setVoteType(0);
- upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mPostIconAndInfoColor);
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
}
- downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2726,10 +2756,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void onVoteThingFail(int position1) {
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- scoreTextView.setTextColor(previousScoreTextViewColor);
+ if (getAdapterPosition() == position) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2783,19 +2815,26 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
+ int currentPosition = getAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1);
- downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mDownvotedColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ }
+
} else {
post.setVoteType(0);
- downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setTextColor(mPostIconAndInfoColor);
+ if (currentPosition == position) {
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
}
- upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ if (currentPosition == position) {
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2804,10 +2843,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public void onVoteThingFail(int position1) {
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- scoreTextView.setTextColor(previousScoreTextViewColor);
+ if (getAdapterPosition() == position) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+ }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2834,7 +2875,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void success() {
post.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.post_unsaved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2842,7 +2885,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.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.post_unsaved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2854,7 +2899,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void success() {
post.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.post_saved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -2862,7 +2909,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.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.post_saved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}