Merge branch 'master' into dev
This commit is contained in:
@@ -156,21 +156,19 @@ private class DetailGeneratorImpl(
|
||||
}
|
||||
|
||||
if (artist.implicitAlbums.isNotEmpty()) {
|
||||
// groupByTo normally returns a mapping to a MutableList mapping. Since MutableList
|
||||
// inherits list, we can cast upwards and save a copy by directly inserting the
|
||||
// implicit album list into the mapping.
|
||||
L.d("Implicit albums present, adding to list")
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(grouping as MutableMap<DetailSection.Albums.Category, Collection<Album>>)[
|
||||
DetailSection.Albums.Category.APPEARANCES] = artist.implicitAlbums
|
||||
grouping[DetailSection.Albums.Category.APPEARANCES] =
|
||||
artist.implicitAlbums.toMutableList()
|
||||
}
|
||||
|
||||
val sections =
|
||||
grouping.mapTo(mutableListOf<DetailSection>()) { (category, albums) ->
|
||||
DetailSection.Albums(category, ARTIST_ALBUM_SORT.albums(albums))
|
||||
}
|
||||
val songs = DetailSection.Songs(listSettings.artistSongSort.songs(artist.songs))
|
||||
sections.add(songs)
|
||||
if (artist.songs.isNotEmpty()) {
|
||||
val songs = DetailSection.Songs(listSettings.artistSongSort.songs(artist.songs))
|
||||
sections.add(songs)
|
||||
}
|
||||
return Detail(artist, sections)
|
||||
}
|
||||
|
||||
@@ -183,8 +181,11 @@ private class DetailGeneratorImpl(
|
||||
|
||||
override fun playlist(uid: Music.UID): Detail<Playlist>? {
|
||||
val playlist = musicRepository.userLibrary?.findPlaylist(uid) ?: return null
|
||||
val songs = DetailSection.Songs(playlist.songs)
|
||||
return Detail(playlist, listOf(songs))
|
||||
if (playlist.songs.isNotEmpty()) {
|
||||
val songs = DetailSection.Songs(playlist.songs)
|
||||
return Detail(playlist, listOf(songs))
|
||||
}
|
||||
return Detail(playlist, listOf())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
@@ -90,7 +90,7 @@ private class HomeGeneratorImpl(
|
||||
// Changes in the hide collaborator setting will change the artist contents
|
||||
// of the library, consider it a library update.
|
||||
L.d("Collaborator setting changed, forwarding update")
|
||||
onMusicChanges(MusicRepository.Changes(deviceLibrary = true, userLibrary = false))
|
||||
invalidator.invalidateMusic(MusicType.ARTISTS, UpdateInstructions.Diff)
|
||||
}
|
||||
|
||||
override fun onSongSortChanged() {
|
||||
@@ -151,7 +151,14 @@ private class HomeGeneratorImpl(
|
||||
?: emptyList()
|
||||
|
||||
override fun artists() =
|
||||
musicRepository.deviceLibrary?.let { listSettings.artistSort.artists(it.artists) }
|
||||
musicRepository.deviceLibrary?.let { deviceLibrary ->
|
||||
val sorted = listSettings.artistSort.artists(deviceLibrary.artists)
|
||||
if (homeSettings.shouldHideCollaborators) {
|
||||
sorted.filter { it.explicitAlbums.isNotEmpty() }
|
||||
} else {
|
||||
sorted
|
||||
}
|
||||
}
|
||||
?: emptyList()
|
||||
|
||||
override fun genres() =
|
||||
|
||||
@@ -87,20 +87,22 @@ class ExoPlaybackStateHolder(
|
||||
private set
|
||||
|
||||
fun attach() {
|
||||
imageSettings.registerListener(this)
|
||||
player.addListener(this)
|
||||
playbackManager.registerStateHolder(this)
|
||||
playbackSettings.registerListener(this)
|
||||
musicRepository.addUpdateListener(this)
|
||||
player.addListener(this)
|
||||
replayGainProcessor.attach()
|
||||
playbackSettings.registerListener(this)
|
||||
imageSettings.registerListener(this)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
saveJob.cancel()
|
||||
player.removeListener(this)
|
||||
playbackManager.unregisterStateHolder(this)
|
||||
musicRepository.removeUpdateListener(this)
|
||||
player.removeListener(this)
|
||||
replayGainProcessor.release()
|
||||
imageSettings.unregisterListener(this)
|
||||
playbackSettings.unregisterListener(this)
|
||||
player.release()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user