Prevent crash when shuffling an empty playlist

This commit is contained in:
Nicolas Pomepuy 2024-10-08 14:52:35 +02:00 committed by Duncan McNamara
parent f499b02e3d
commit 6ea4fafd0f

View File

@ -169,7 +169,7 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
}
binding.btnShuffle.setOnClickListener {
viewModel.playlist?.let { MediaUtils.playTracks(this, it, SecureRandom().nextInt(min(playlist.tracksCount, MEDIALIBRARY_PAGE_SIZE)), true) }
viewModel.playlist?.let { if (it.tracksCount > 0) MediaUtils.playTracks(this, it, SecureRandom().nextInt(min(playlist.tracksCount, MEDIALIBRARY_PAGE_SIZE)), true) }
}
binding.btnAddPlaylist.setOnClickListener {
viewModel.playlist?.let { addToPlaylist(it.tracks.toList()) }