detail: show list of artists in genre UI

Show a list of artists that contain songs from a particular genre in
the genre UI.

This used to be in really early Auxio versions, but was intertwined
with some really stupid genre functionality that would include songs
from an entire artist for some reason. Since now albums can be shown
in several artist entires, it makes no sense now what artists can't
be given the same treatment.
This commit is contained in:
Alexander Capehart
2022-11-13 18:43:42 -07:00
parent 459e71b941
commit 3a236bdaf4
4 changed files with 10 additions and 0 deletions
@@ -277,6 +277,8 @@ class DetailViewModel(application: Application) :
private fun refreshGenreData(genre: Genre) {
logD("Refreshing genre data")
val data = mutableListOf<Item>(genre)
data.add(Header(R.string.lbl_artists))
data.addAll(genre.artists)
data.add(SortHeader(R.string.lbl_songs))
data.addAll(genreSort.songs(genre.songs))
_genreData.value = data
@@ -35,6 +35,7 @@ import org.oxycblt.auxio.ui.recycler.MenuItemListener
import org.oxycblt.auxio.ui.recycler.SimpleItemCallback
import org.oxycblt.auxio.util.context
import org.oxycblt.auxio.util.inflater
import org.oxycblt.auxio.util.logD
abstract class DetailAdapter<L : DetailAdapter.Listener>(
private val listener: L,
@@ -24,9 +24,12 @@ import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemDetailBinding
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.formatDurationMs
import org.oxycblt.auxio.ui.recycler.ArtistViewHolder
import org.oxycblt.auxio.ui.recycler.Header
import org.oxycblt.auxio.ui.recycler.Item
import org.oxycblt.auxio.ui.recycler.SimpleItemCallback
import org.oxycblt.auxio.ui.recycler.SongViewHolder
@@ -43,6 +46,7 @@ class GenreDetailAdapter(private val listener: Listener) :
override fun getItemViewType(position: Int) =
when (differ.currentList[position]) {
is Genre -> GenreDetailViewHolder.VIEW_TYPE
is Artist -> ArtistViewHolder.VIEW_TYPE
is Song -> SongViewHolder.VIEW_TYPE
else -> super.getItemViewType(position)
}
@@ -50,6 +54,7 @@ class GenreDetailAdapter(private val listener: Listener) :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
when (viewType) {
GenreDetailViewHolder.VIEW_TYPE -> GenreDetailViewHolder.new(parent)
ArtistViewHolder.VIEW_TYPE -> ArtistViewHolder.new(parent)
SongViewHolder.VIEW_TYPE -> SongViewHolder.new(parent)
else -> super.onCreateViewHolder(parent, viewType)
}
@@ -64,6 +69,7 @@ class GenreDetailAdapter(private val listener: Listener) :
if (payloads.isEmpty()) {
when (val item = differ.currentList[position]) {
is Genre -> (holder as GenreDetailViewHolder).bind(item, listener)
is Artist -> (holder as ArtistViewHolder).bind(item, listener)
is Song -> (holder as SongViewHolder).bind(item, listener)
}
}