Fix playlist reload
This commit is contained in:
parent
54f95dbd92
commit
e5f6e83dd4
5 changed files with 90 additions and 52 deletions
|
@ -68,17 +68,8 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
) { _, _ ->
|
||||
val playlistName = playlistView.text.toString()
|
||||
if (!TextUtils.isEmpty(playlistName)) {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
if (libraryViewModel.checkPlaylistExists(playlistName).isEmpty()) {
|
||||
val playlistId: Long =
|
||||
libraryViewModel.createPlaylist(PlaylistEntity(playlistName = playlistName))
|
||||
libraryViewModel.insertSongs(songs.map { it.toSongEntity(playlistId) })
|
||||
libraryViewModel.forceReload(Playlists)
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Playlist exists", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
libraryViewModel.addToPlaylist(playlistName, songs)
|
||||
|
||||
} else {
|
||||
playlistContainer.error = "Playlist is can't be empty"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue