Glimpse: Simplify favorite button drawable handling
Change-Id: I1cabdd7c0596f3046ebbb0d28547a232c6192c4f
This commit is contained in:
parent
824b8856c9
commit
c73a85fd29
|
@ -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(
|
||||
|
|
|
@ -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>
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue