diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-09-11 03:09:00 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-09-11 03:09:00 +0000 |
commit | cb1d922ac26f5dc4040a793a0b8c45ccc92d7861 (patch) | |
tree | de6e949ef03db1c63bcbb3e137ecca9a2dd49de1 /app/src | |
parent | 743c16b1bee74c57d56357be4a0ecbb142fecc4b (diff) | |
download | infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar.gz infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar.bz2 infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar.lz infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar.xz infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.tar.zst infinity-for-reddit-cb1d922ac26f5dc4040a793a0b8c45ccc92d7861.zip |
Continue adding Card Layout 3. Start changing vote button icons.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java | 20 | ||||
-rw-r--r-- | app/src/main/res/layout/item_post_card_2_with_preview.xml | 4 |
2 files changed, 22 insertions, 2 deletions
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 5da7bbc4..740349b8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -6110,22 +6110,27 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ColorStateList previousUpvoteButtonColorTintList = upvoteButton.getBackgroundTintList(); ColorStateList previousDownvoteButtonColorTintList = downvoteButton.getBackgroundTintList(); + Drawable previousUpvoteButtonDrawable = upvoteButton.getIcon(); + Drawable previousDownvoteButtonDrawable = downvoteButton.getIcon(); int previousVoteType = post.getVoteType(); String newVoteType; downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_24dp); if (previousVoteType != 1) { //Not upvoted before post.setVoteType(1); newVoteType = APIUtils.DIR_UPVOTE; upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mUpvotedColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp); } else { //Upvoted before post.setVoteType(0); newVoteType = APIUtils.DIR_UNVOTE; upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_24dp); } if (!mHideTheNumberOfVotes) { @@ -6140,16 +6145,19 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie post.setVoteType(1); if (currentPosition == position) { upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mUpvotedColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp); } } else { post.setVoteType(0); if (currentPosition == position) { upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_24dp); } } if (currentPosition == position) { downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_24dp); if (!mHideTheNumberOfVotes) { upvoteButton.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); } @@ -6167,7 +6175,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie upvoteButton.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); } upvoteButton.setBackgroundTintList(previousUpvoteButtonColorTintList); + upvoteButton.setIcon(previousUpvoteButtonDrawable); downvoteButton.setBackgroundTintList(previousDownvoteButtonColorTintList); + downvoteButton.setIcon(previousDownvoteButtonDrawable); } EventBus.getDefault().post(new PostUpdateEventToPostDetailFragment(post)); @@ -6199,22 +6209,27 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ColorStateList previousUpvoteButtonColorFilter = upvoteButton.getBackgroundTintList(); ColorStateList previousDownvoteButtonColorFilter = downvoteButton.getBackgroundTintList(); + Drawable previousUpvoteButtonDrawable = upvoteButton.getIcon(); + Drawable previousDownvoteButtonDrawable = downvoteButton.getIcon(); int previousVoteType = post.getVoteType(); String newVoteType; upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_24dp); if (previousVoteType != -1) { //Not downvoted before post.setVoteType(-1); newVoteType = APIUtils.DIR_DOWNVOTE; downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mDownvotedColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_filled_24dp); } else { //Downvoted before post.setVoteType(0); newVoteType = APIUtils.DIR_UNVOTE; downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_24dp); } if (!mHideTheNumberOfVotes) { @@ -6229,16 +6244,19 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie post.setVoteType(-1); if (currentPosition == position) { downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mDownvotedColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_filled_24dp); } } else { post.setVoteType(0); if (currentPosition == position) { downvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + downvoteButton.setIconResource(R.drawable.ic_downvote_24dp); } } if (currentPosition == position) { upvoteButton.setBackgroundTintList(ColorStateList.valueOf(mPostIconAndInfoColor)); + upvoteButton.setIconResource(R.drawable.ic_upvote_24dp); if (!mHideTheNumberOfVotes) { upvoteButton.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); } @@ -6256,7 +6274,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie upvoteButton.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); } upvoteButton.setBackgroundTintList(previousUpvoteButtonColorFilter); + upvoteButton.setIcon(previousUpvoteButtonDrawable); downvoteButton.setBackgroundTintList(previousDownvoteButtonColorFilter); + downvoteButton.setIcon(previousDownvoteButtonDrawable); } EventBus.getDefault().post(new PostUpdateEventToPostDetailFragment(post)); diff --git a/app/src/main/res/layout/item_post_card_2_with_preview.xml b/app/src/main/res/layout/item_post_card_2_with_preview.xml index 88edcd81..eb67faac 100644 --- a/app/src/main/res/layout/item_post_card_2_with_preview.xml +++ b/app/src/main/res/layout/item_post_card_2_with_preview.xml @@ -235,7 +235,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" - android:src="@drawable/ic_arrow_upward_grey_24dp" + android:src="@drawable/ic_upvote_24dp" android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" @@ -260,7 +260,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" - android:src="@drawable/ic_arrow_downward_grey_24dp" + android:src="@drawable/ic_downvote_24dp" android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" |