diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-03 08:42:34 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-03 08:42:34 +0000 |
commit | e2173e0c0926659068d4bc6703071aee73851a6d (patch) | |
tree | b8db7bea199d48aabac5852c55e4bff7518b83ba /app/src/main/java | |
parent | b61265e17ae85936271da09e71c3a7c9ee1443fc (diff) | |
download | infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar.gz infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar.bz2 infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar.lz infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar.xz infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.tar.zst infinity-for-reddit-e2173e0c0926659068d4bc6703071aee73851a6d.zip |
Change score color if the post is voted.
Diffstat (limited to '')
3 files changed, 66 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index 7afadce8..b1f756e8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -287,14 +287,17 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie case 1: //Upvote ((PostDetailViewHolder) holder).mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), PorterDuff.Mode.SRC_IN); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); break; case -1: //Downvote ((PostDetailViewHolder) holder).mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), PorterDuff.Mode.SRC_IN); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); break; case 0: ((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter(); ((PostDetailViewHolder) holder).mDownvoteButton.clearColorFilter(); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } if(mPost.getPostType() != Post.TEXT_TYPE && mPost.getPostType() != Post.NO_PREVIEW_LINK_TYPE) { @@ -556,10 +559,12 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie case 1: ((CommentViewHolder) holder).upVoteButton .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); break; case 2: ((CommentViewHolder) holder).downVoteButton .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); break; } @@ -631,11 +636,13 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_UPVOTE); newVoteType = RedditUtils.DIR_UPVOTE; ((CommentViewHolder) holder).upVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); } else { //Upvoted before mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); newVoteType = RedditUtils.DIR_UNVOTE; ((CommentViewHolder) holder).upVoteButton.clearColorFilter(); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(mVisibleComments.get(commentPosition).getScore() + mVisibleComments.get(commentPosition).getVoteType())); @@ -646,9 +653,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) { mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_UPVOTE); ((CommentViewHolder) holder).upVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); } else { mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((CommentViewHolder) holder).upVoteButton.clearColorFilter(); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } ((CommentViewHolder) holder).downVoteButton.clearColorFilter(); @@ -683,11 +692,13 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); newVoteType = RedditUtils.DIR_DOWNVOTE; ((CommentViewHolder) holder).downVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); } else { //Downvoted before mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); newVoteType = RedditUtils.DIR_UNVOTE; ((CommentViewHolder) holder).downVoteButton.clearColorFilter(); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(mVisibleComments.get(commentPosition).getScore() + mVisibleComments.get(commentPosition).getVoteType())); @@ -698,9 +709,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie if(newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); ((CommentViewHolder) holder).downVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); } else { mVisibleComments.get(commentPosition).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((CommentViewHolder) holder).downVoteButton.clearColorFilter(); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } ((CommentViewHolder) holder).upVoteButton.clearColorFilter(); @@ -973,12 +986,14 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ((CommentViewHolder) holder).moreButton.setVisibility(View.GONE); ((CommentViewHolder) holder).expandButton.setVisibility(View.GONE); ((CommentViewHolder) holder).upVoteButton.clearColorFilter(); + ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); ((CommentViewHolder) holder).downVoteButton.clearColorFilter(); ((CommentViewHolder) holder).replyButton.clearColorFilter(); ((CommentViewHolder) holder).itemView.setBackgroundColor( mActivity.getResources().getColor(R.color.cardViewBackgroundColor)); } else if(holder instanceof PostDetailViewHolder) { ((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter(); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); ((PostDetailViewHolder) holder).mDownvoteButton.clearColorFilter(); ((PostDetailViewHolder) holder).spoilerFlairlinearLayout.setVisibility(View.GONE); ((PostDetailViewHolder) holder).flairTextView.setVisibility(View.GONE); @@ -1083,6 +1098,8 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ColorFilter previousUpvoteButtonColorFilter = mUpvoteButton.getColorFilter(); ColorFilter previousDownvoteButtonColorFilter = mDownvoteButton.getColorFilter(); + int previousScoreTextViewColor = mScoreTextView.getCurrentTextColor(); + int previousVoteType = mPost.getVoteType(); String newVoteType; @@ -1093,11 +1110,13 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mPost.setVoteType(1); newVoteType = RedditUtils.DIR_UPVOTE; mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); } else { //Upvoted before mPost.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; mUpvoteButton.clearColorFilter(); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } mScoreTextView.setText(Integer.toString(mPost.getScore() + mPost.getVoteType())); @@ -1110,9 +1129,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) { mPost.setVoteType(1); mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); } else { mPost.setVoteType(0); mUpvoteButton.clearColorFilter(); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } mDownvoteButton.clearColorFilter(); @@ -1128,6 +1149,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mScoreTextView.setText(Integer.toString(mPost.getScore() + previousVoteType)); mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter); mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + mScoreTextView.setTextColor(previousScoreTextViewColor); mCommentRecyclerViewAdapterCallback.updatePost(mPost); } @@ -1147,6 +1169,8 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie ColorFilter previousUpvoteButtonColorFilter = mUpvoteButton.getColorFilter(); ColorFilter previousDownvoteButtonColorFilter = mDownvoteButton.getColorFilter(); + int previousScoreTextViewColor = mScoreTextView.getCurrentTextColor(); + int previousVoteType = mPost.getVoteType(); String newVoteType; @@ -1157,11 +1181,13 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mPost.setVoteType(-1); newVoteType = RedditUtils.DIR_DOWNVOTE; mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); } else { //Upvoted before mPost.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; mDownvoteButton.clearColorFilter(); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } mScoreTextView.setText(Integer.toString(mPost.getScore() + mPost.getVoteType())); @@ -1174,9 +1200,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie if(newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { mPost.setVoteType(-1); mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); } else { mPost.setVoteType(0); mDownvoteButton.clearColorFilter(); + mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); } mUpvoteButton.clearColorFilter(); @@ -1192,6 +1220,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie mScoreTextView.setText(Integer.toString(mPost.getScore() + previousVoteType)); mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter); mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + mScoreTextView.setTextColor(previousScoreTextViewColor); mCommentRecyclerViewAdapterCallback.updatePost(mPost); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java index 7e121368..e65bc536 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java @@ -139,10 +139,12 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R case 1: ((DataViewHolder) holder).upvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); break; case 2: ((DataViewHolder) holder).downvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); break; } @@ -178,6 +180,15 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R } @Override + public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { + if(holder instanceof DataViewHolder) { + ((DataViewHolder) holder).upvoteButton.clearColorFilter(); + ((DataViewHolder) holder).downvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); + } + } + + @Override public int getItemCount() { if(hasExtraRow()) { return super.getItemCount() + 1; @@ -259,11 +270,13 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_UPVOTE); newVoteType = RedditUtils.DIR_UPVOTE; upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); } else { //Upvoted before getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); newVoteType = RedditUtils.DIR_UNVOTE; upvoteButton.clearColorFilter(); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } scoreTextView.setText(Integer.toString(getItem(getAdapterPosition()).getScore() + getItem(getAdapterPosition()).getVoteType())); @@ -274,9 +287,11 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) { getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_UPVOTE); upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); } else { getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); upvoteButton.clearColorFilter(); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } downvoteButton.clearColorFilter(); @@ -304,11 +319,13 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); newVoteType = RedditUtils.DIR_DOWNVOTE; downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); } else { //Downvoted before getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); newVoteType = RedditUtils.DIR_UNVOTE; downvoteButton.clearColorFilter(); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } scoreTextView.setText(Integer.toString(getItem(getAdapterPosition()).getScore() + getItem(getAdapterPosition()).getVoteType())); @@ -319,9 +336,11 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R if(newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); } else { getItem(getAdapterPosition()).setVoteType(CommentData.VOTE_TYPE_NO_VOTE); downvoteButton.clearColorFilter(); + scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } upvoteButton.clearColorFilter(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index 88d0ad7c..52de6548 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -340,12 +340,14 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo switch (voteType) { case 1: - //Upvote + //Upvoted ((DataViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); break; case -1: - //Downvote + //Downvoted ((DataViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); break; } @@ -497,6 +499,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ColorFilter previousUpvoteButtonColorFilter = ((DataViewHolder) holder).upvoteButton.getColorFilter(); ColorFilter previousDownvoteButtonColorFilter = ((DataViewHolder) holder).downvoteButton.getColorFilter(); + int previousScoreTextViewColor = ((DataViewHolder) holder).scoreTextView.getCurrentTextColor(); + int previousVoteType = post.getVoteType(); String newVoteType; @@ -508,11 +512,13 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo newVoteType = RedditUtils.DIR_UPVOTE; ((DataViewHolder) holder).upvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); } else { //Upvoted before post.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; ((DataViewHolder) holder).upvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } ((DataViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType())); @@ -524,9 +530,11 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo post.setVoteType(1); ((DataViewHolder) holder).upvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); } else { post.setVoteType(0); ((DataViewHolder) holder).upvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } ((DataViewHolder) holder).downvoteButton.clearColorFilter(); @@ -542,6 +550,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ((DataViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType)); ((DataViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); ((DataViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + ((DataViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post.getId(), post.getVoteType())); } @@ -561,6 +570,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ColorFilter previousUpvoteButtonColorFilter = ((DataViewHolder) holder).upvoteButton.getColorFilter(); ColorFilter previousDownvoteButtonColorFilter = ((DataViewHolder) holder).downvoteButton.getColorFilter(); + int previousScoreTextViewColor = ((DataViewHolder) holder).scoreTextView.getCurrentTextColor(); int previousVoteType = post.getVoteType(); String newVoteType; @@ -573,11 +583,13 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo newVoteType = RedditUtils.DIR_DOWNVOTE; ((DataViewHolder) holder).downvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); } else { //Downvoted before post.setVoteType(0); newVoteType = RedditUtils.DIR_UNVOTE; ((DataViewHolder) holder).downvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } ((DataViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType())); @@ -589,9 +601,11 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo post.setVoteType(-1); ((DataViewHolder) holder).downvoteButton .setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); } else { post.setVoteType(0); ((DataViewHolder) holder).downvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); } ((DataViewHolder) holder).upvoteButton.clearColorFilter(); @@ -607,6 +621,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ((DataViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + previousVoteType)); ((DataViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); ((DataViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); + ((DataViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post.getId(), post.getVoteType())); } @@ -775,6 +790,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ((DataViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); ((DataViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE); ((DataViewHolder) holder).upvoteButton.clearColorFilter(); + ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.defaultTextColor)); ((DataViewHolder) holder).downvoteButton.clearColorFilter(); } } |