mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Fix wrong vote info showing in posts and comments.
This commit is contained in:
parent
42957a1aa2
commit
f25f75b3d0
@ -3487,21 +3487,28 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
|
|
||||||
|
int position = getAdapterPosition();
|
||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
@ -3509,6 +3516,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingFail(int position) {
|
public void onVoteThingFail(int position) {
|
||||||
@ -3557,21 +3565,28 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
|
|
||||||
|
int position = getAdapterPosition();
|
||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
@ -3579,6 +3594,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingFail(int position1) {
|
public void onVoteThingFail(int position1) {
|
||||||
@ -3590,20 +3606,25 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
saveButton.setOnClickListener(view -> {
|
saveButton.setOnClickListener(view -> {
|
||||||
Comment comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
|
int position = getAdapterPosition();
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3613,14 +3634,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1677,19 +1677,25 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
upvoteButton
|
if (currentPosition == position) {
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1698,10 +1704,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
public void onVoteThingFail(int position1) {
|
public void onVoteThingFail(int position1) {
|
||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
post.setVoteType(previousVoteType);
|
post.setVoteType(previousVoteType);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
||||||
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
scoreTextView.setTextColor(previousScoreTextViewColor);
|
scoreTextView.setTextColor(previousScoreTextViewColor);
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
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() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
downvoteButton
|
if (currentPosition == position) {
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1776,10 +1790,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
public void onVoteThingFail(int position1) {
|
public void onVoteThingFail(int position1) {
|
||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
post.setVoteType(previousVoteType);
|
post.setVoteType(previousVoteType);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
||||||
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
scoreTextView.setTextColor(previousScoreTextViewColor);
|
scoreTextView.setTextColor(previousScoreTextViewColor);
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1806,7 +1822,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
post.setSaved(false);
|
post.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1814,7 +1832,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
post.setSaved(true);
|
post.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1826,7 +1846,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
post.setSaved(true);
|
post.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -1834,7 +1856,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
post.setSaved(false);
|
post.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
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() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
upvoteButton
|
if (currentPosition == position) {
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2726,10 +2756,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
public void onVoteThingFail(int position1) {
|
public void onVoteThingFail(int position1) {
|
||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
post.setVoteType(previousVoteType);
|
post.setVoteType(previousVoteType);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
||||||
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
scoreTextView.setTextColor(previousScoreTextViewColor);
|
scoreTextView.setTextColor(previousScoreTextViewColor);
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
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() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
int currentPosition = getAdapterPosition();
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
downvoteButton
|
if (currentPosition == position) {
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2804,10 +2843,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
public void onVoteThingFail(int position1) {
|
public void onVoteThingFail(int position1) {
|
||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
post.setVoteType(previousVoteType);
|
post.setVoteType(previousVoteType);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
|
||||||
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
scoreTextView.setTextColor(previousScoreTextViewColor);
|
scoreTextView.setTextColor(previousScoreTextViewColor);
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2834,7 +2875,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
post.setSaved(false);
|
post.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2842,7 +2885,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
post.setSaved(true);
|
post.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2854,7 +2899,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
post.setSaved(true);
|
post.setSaved(true);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
@ -2862,7 +2909,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
post.setSaved(false);
|
post.setSaved(false);
|
||||||
|
if (getAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user