Glimpse: Simplify favorite button drawable handling

Change-Id: I1cabdd7c0596f3046ebbb0d28547a232c6192c4f
This commit is contained in:
LuK1337 2023-08-05 21:39:15 +02:00
parent 824b8856c9
commit c73a85fd29
3 changed files with 12 additions and 16 deletions

View File

@ -140,14 +140,7 @@ class MediaViewerFragment : Fragment(
dateTextView.text = dateFormatter.format(media.dateAdded)
timeTextView.text = timeFormatter.format(media.dateAdded)
favoriteButton.setImageResource(
if (media.isFavorite) {
R.drawable.ic_star
} else {
R.drawable.ic_star_border
}
)
favoriteButton.isSelected = media.isFavorite
}
}
@ -180,13 +173,7 @@ class MediaViewerFragment : Fragment(
favoriteButton.setOnClickListener {
mediaViewerAdapter.getMediaFromMediaStore(viewPager.currentItem)?.let {
favoriteButton.setImageResource(
if (!it.isFavorite) {
R.drawable.ic_star
} else {
R.drawable.ic_star_border
}
)
favoriteButton.isSelected = !it.isFavorite
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
noopContract.launch(

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The LineageOS Project
SPDX-License-Identifier: Apache-2.0
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_star_border" android:state_selected="false" />
<item android:drawable="@drawable/ic_star" android:state_selected="true" />
</selector>

View File

@ -78,7 +78,7 @@
<ImageButton
android:id="@+id/favoriteButton"
style="@style/Theme.Glimpse.MediaViewer.BottomSheet.Button"
android:src="@drawable/ic_star_border" />
android:src="@drawable/ic_star_toggle" />
<ImageButton
android:id="@+id/shareButton"