mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Fix wrong vote and save info in CommentsListingRecyclerViewAdapter.
This commit is contained in:
parent
f25f75b3d0
commit
a4232a54bd
@ -576,20 +576,27 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
|
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);
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
comment.getScore() + comment.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -636,19 +643,26 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, 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);
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
if (currentPosition == position) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
comment.getScore() + comment.getVoteType()));
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -663,7 +677,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Comment comment = getItem(getAdapterPosition());
|
Comment comment = getItem(position);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
@ -671,14 +685,18 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
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(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
if (getAdapterPosition() == position) {
|
||||||
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -688,14 +706,18 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
if (getAdapterPosition() == position) {
|
||||||
|
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
|
}
|
||||||
Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(false);
|
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(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user