Fix playing item highlighting issue
Fix an issue if one plays a song from all songs and then attempts to play a song from its genre/album, the song will not highlight despite it supposely playing.
This commit is contained in:
@@ -112,15 +112,12 @@ class AlbumDetailFragment : DetailFragment() {
|
||||
|
||||
// --- PLAYBACKVIEWMODEL SETUP ---
|
||||
|
||||
playbackModel.song.observe(viewLifecycleOwner) { song ->
|
||||
if (playbackModel.mode.value == PlaybackMode.IN_ALBUM &&
|
||||
playbackModel.parent.value?.id == detailModel.currentAlbum.value!!.id
|
||||
) {
|
||||
detailAdapter.highlightSong(song, binding.detailRecycler)
|
||||
} else {
|
||||
// Clear the viewholders if the mode isn't ALL_SONGS
|
||||
detailAdapter.highlightSong(null, binding.detailRecycler)
|
||||
}
|
||||
playbackModel.song.observe(viewLifecycleOwner) {
|
||||
handlePlayingItem(detailAdapter)
|
||||
}
|
||||
|
||||
playbackModel.mode.observe(viewLifecycleOwner) {
|
||||
handlePlayingItem(detailAdapter)
|
||||
}
|
||||
|
||||
playbackModel.isInUserQueue.observe(viewLifecycleOwner) {
|
||||
@@ -134,6 +131,21 @@ class AlbumDetailFragment : DetailFragment() {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an update to the mode or the song and determine whether to highlight a song
|
||||
* item based off that
|
||||
*/
|
||||
private fun handlePlayingItem(detailAdapter: AlbumDetailAdapter) {
|
||||
if (playbackModel.mode.value == PlaybackMode.IN_ALBUM &&
|
||||
playbackModel.parent.value?.id == detailModel.currentAlbum.value!!.id
|
||||
) {
|
||||
detailAdapter.highlightSong(playbackModel.song.value, binding.detailRecycler)
|
||||
} else {
|
||||
// Clear the viewholders if the mode isn't ALL_SONGS
|
||||
detailAdapter.highlightSong(null, binding.detailRecycler)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll to the currently playing item.
|
||||
*/
|
||||
|
||||
@@ -87,15 +87,12 @@ class GenreDetailFragment : DetailFragment() {
|
||||
|
||||
// --- PLAYBACKVIEWMODEL SETUP ---
|
||||
|
||||
playbackModel.song.observe(viewLifecycleOwner) { song ->
|
||||
if (playbackModel.mode.value == PlaybackMode.IN_GENRE &&
|
||||
playbackModel.parent.value?.id == detailModel.currentGenre.value!!.id
|
||||
) {
|
||||
detailAdapter.highlightSong(song, binding.detailRecycler)
|
||||
} else {
|
||||
// Clear the viewholders if the mode isn't ALL_SONGS
|
||||
detailAdapter.highlightSong(null, binding.detailRecycler)
|
||||
}
|
||||
playbackModel.song.observe(viewLifecycleOwner) {
|
||||
handlePlayingItem(detailAdapter)
|
||||
}
|
||||
|
||||
playbackModel.mode.observe(viewLifecycleOwner) {
|
||||
handlePlayingItem(detailAdapter)
|
||||
}
|
||||
|
||||
playbackModel.isInUserQueue.observe(viewLifecycleOwner) {
|
||||
@@ -108,4 +105,19 @@ class GenreDetailFragment : DetailFragment() {
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an update to the mode or the song and determine whether to highlight a song
|
||||
* item based off that
|
||||
*/
|
||||
private fun handlePlayingItem(detailAdapter: GenreDetailAdapter) {
|
||||
if (playbackModel.mode.value == PlaybackMode.IN_GENRE &&
|
||||
playbackModel.parent.value?.id == detailModel.currentGenre.value!!.id
|
||||
) {
|
||||
detailAdapter.highlightSong(playbackModel.song.value, binding.detailRecycler)
|
||||
} else {
|
||||
// Clear the viewholders if the mode isn't ALL_SONGS
|
||||
detailAdapter.highlightSong(null, binding.detailRecycler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user