Disable SortButton when theres one item
Disable the SortButton when theres only one item in the RecyclerView.
This commit is contained in:
parent
35814c5b40
commit
2a6fd45b8b
4 changed files with 26 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package org.oxycblt.auxio.detail
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
|
@ -16,6 +17,7 @@ import org.oxycblt.auxio.music.MusicViewModel
|
|||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.SortMode
|
||||
import org.oxycblt.auxio.theme.applyDivider
|
||||
import org.oxycblt.auxio.theme.toColor
|
||||
|
||||
class AlbumDetailFragment : Fragment() {
|
||||
|
||||
|
@ -73,6 +75,7 @@ class AlbumDetailFragment : Fragment() {
|
|||
binding.artistName.setBackgroundResource(R.drawable.ripple)
|
||||
}
|
||||
|
||||
// Set up sort modes
|
||||
detailModel.albumSortMode.observe(viewLifecycleOwner) { mode ->
|
||||
// Update the current sort icon
|
||||
binding.sortButton.setImageResource(mode.iconRes)
|
||||
|
@ -90,6 +93,15 @@ class AlbumDetailFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
|
||||
// Dont enable the sort button if theres only one song [or less]
|
||||
if (detailModel.currentAlbum!!.numSongs < 2) {
|
||||
binding.sortButton.imageTintList = ColorStateList.valueOf(
|
||||
R.color.inactive_color.toColor(requireContext())
|
||||
)
|
||||
|
||||
binding.sortButton.isEnabled = false
|
||||
}
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.oxycblt.auxio.detail
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
|
@ -9,6 +10,7 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentArtistDetailBinding
|
||||
import org.oxycblt.auxio.detail.adapters.DetailAlbumAdapter
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
|
@ -16,6 +18,7 @@ import org.oxycblt.auxio.music.models.Album
|
|||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.SortMode
|
||||
import org.oxycblt.auxio.theme.applyDivider
|
||||
import org.oxycblt.auxio.theme.toColor
|
||||
|
||||
class ArtistDetailFragment : Fragment() {
|
||||
|
||||
|
@ -69,6 +72,15 @@ class ArtistDetailFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
|
||||
// Dont enable the sort button if there is only one album [Or less]
|
||||
if (detailModel.currentArtist!!.numAlbums < 2) {
|
||||
binding.sortButton.imageTintList = ColorStateList.valueOf(
|
||||
R.color.inactive_color.toColor(requireContext())
|
||||
)
|
||||
|
||||
binding.sortButton.isEnabled = false
|
||||
}
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<color name="background">#151515</color>
|
||||
<color name="divider_color">#323232</color>
|
||||
<color name="selection_color">#484848</color>
|
||||
<color name="inactive_color">#404040</color>
|
||||
|
||||
<!--
|
||||
Base color set derived from Music Player GO.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<color name="background">#fafafa</color>
|
||||
<color name="divider_color">#cbcbcb</color>
|
||||
<color name="selection_color">#cbcbcb</color>
|
||||
<color name="inactive_color">#c4c4c4</color>
|
||||
|
||||
<!--
|
||||
Base color set derived from Music Player GO.
|
||||
|
|
Loading…
Reference in a new issue