Disable SortButton when theres one item
Disable the SortButton when theres only one item in the RecyclerView.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user