music: only include explicit albums in count
Only include an artists explicit albums (ones directly linked w/album artist) in their count. This is arguably more appropriate than the prior behavior, given Auxio's collaborator/artist distinction. Resolves #581.
This commit is contained in:
@@ -71,7 +71,11 @@ private constructor(private val binding: ItemDetailHeaderBinding) :
|
||||
binding.detailInfo.text =
|
||||
binding.context.getString(
|
||||
R.string.fmt_two,
|
||||
binding.context.getPlural(R.plurals.fmt_album_count, artist.albums.size),
|
||||
if (artist.explicitAlbums.isNotEmpty()) {
|
||||
binding.context.getPlural(R.plurals.fmt_album_count, artist.explicitAlbums.size)
|
||||
} else {
|
||||
binding.context.getString(R.string.def_album_count)
|
||||
},
|
||||
if (artist.songs.isNotEmpty()) {
|
||||
binding.context.getPlural(R.plurals.fmt_song_count, artist.songs.size)
|
||||
} else {
|
||||
|
||||
@@ -178,7 +178,11 @@ class ArtistMenuDialogFragment : MenuDialogFragment<Menu.ForArtist>() {
|
||||
binding.menuInfo.text =
|
||||
getString(
|
||||
R.string.fmt_two,
|
||||
context.getPlural(R.plurals.fmt_album_count, menu.artist.albums.size),
|
||||
if (menu.artist.explicitAlbums.isNotEmpty()) {
|
||||
context.getPlural(R.plurals.fmt_album_count, menu.artist.explicitAlbums.size)
|
||||
} else {
|
||||
context.getString(R.string.def_album_count)
|
||||
},
|
||||
if (menu.artist.songs.isNotEmpty()) {
|
||||
context.getPlural(R.plurals.fmt_song_count, menu.artist.songs.size)
|
||||
} else {
|
||||
|
||||
@@ -164,7 +164,11 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
|
||||
binding.parentInfo.text =
|
||||
binding.context.getString(
|
||||
R.string.fmt_two,
|
||||
binding.context.getPlural(R.plurals.fmt_album_count, artist.albums.size),
|
||||
if (artist.explicitAlbums.isNotEmpty()) {
|
||||
binding.context.getPlural(R.plurals.fmt_album_count, artist.explicitAlbums.size)
|
||||
} else {
|
||||
binding.context.getString(R.string.def_album_count)
|
||||
},
|
||||
if (artist.songs.isNotEmpty()) {
|
||||
binding.context.getPlural(R.plurals.fmt_song_count, artist.songs.size)
|
||||
} else {
|
||||
@@ -199,7 +203,7 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
|
||||
object : SimpleDiffCallback<Artist>() {
|
||||
override fun areContentsTheSame(oldItem: Artist, newItem: Artist) =
|
||||
oldItem.name == newItem.name &&
|
||||
oldItem.albums.size == newItem.albums.size &&
|
||||
oldItem.explicitAlbums.size == newItem.explicitAlbums.size &&
|
||||
oldItem.songs.size == newItem.songs.size
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ class ArtistImpl(
|
||||
?: Name.Unknown(R.string.def_artist)
|
||||
|
||||
override val songs: Set<Song>
|
||||
override val albums: Set<Album>
|
||||
override val albums: Set<Album> = emptySet()
|
||||
override val explicitAlbums: Set<Album>
|
||||
override val implicitAlbums: Set<Album>
|
||||
override val durationMs: Long?
|
||||
@@ -463,7 +463,7 @@ class ArtistImpl(
|
||||
}
|
||||
|
||||
songs = distinctSongs
|
||||
albums = albumMap.keys
|
||||
val albums = albumMap.keys
|
||||
explicitAlbums = albums.filterTo(mutableSetOf()) { albumMap[it] == true }
|
||||
implicitAlbums = albums.filterNotTo(mutableSetOf()) { albumMap[it] == true }
|
||||
durationMs = songs.sumOf { it.durationMs }.positiveOrNull()
|
||||
@@ -506,7 +506,16 @@ class ArtistImpl(
|
||||
* @return This instance upcasted to [Artist].
|
||||
*/
|
||||
fun finalize(): Artist {
|
||||
check(songs.isNotEmpty() || albums.isNotEmpty()) { "Malformed artist $name: Empty" }
|
||||
// There are valid artist configurations:
|
||||
// 1. No songs, no implicit albums, some explicit albums
|
||||
// 2. Some songs, no implicit albums, some explicit albums
|
||||
// 3. Some songs, some implicit albums, no implicit albums
|
||||
// 4. Some songs, some implicit albums, some explicit albums
|
||||
// I'm pretty sure the latter check could be reduced to just explicitAlbums.isNotEmpty,
|
||||
// but I can't be 100% certain.
|
||||
check(songs.isNotEmpty() || (implicitAlbums.size + explicitAlbums.size) > 0) {
|
||||
"Malformed artist $name: Empty"
|
||||
}
|
||||
genres =
|
||||
Sort(Sort.Mode.ByName, Sort.Direction.ASCENDING)
|
||||
.genres(songs.flatMapTo(mutableSetOf()) { it.genres })
|
||||
|
||||
Reference in New Issue
Block a user