code cleanup
This commit is contained in:
parent
7f3d803ac9
commit
16e765d150
1 changed files with 19 additions and 16 deletions
|
@ -363,13 +363,6 @@ class LibraryViewModel(
|
||||||
createPlaylist(PlaylistEntity(playlistName = playlistName))
|
createPlaylist(PlaylistEntity(playlistName = playlistName))
|
||||||
insertSongs(songs.map { it.toSongEntity(playlistId) })
|
insertSongs(songs.map { it.toSongEntity(playlistId) })
|
||||||
forceReload(Playlists)
|
forceReload(Playlists)
|
||||||
withContext(Main) {
|
|
||||||
Toast.makeText(
|
|
||||||
App.getContext(),
|
|
||||||
"Added ${songs.size} song(s) to $playlistName",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
val playlist = playlists.firstOrNull()
|
val playlist = playlists.firstOrNull()
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
|
@ -377,21 +370,31 @@ class LibraryViewModel(
|
||||||
it.toSongEntity(playListId = playlist.playListId)
|
it.toSongEntity(playListId = playlist.playListId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
|
when {
|
||||||
|
playlists.isEmpty() -> {
|
||||||
|
Toast.makeText(
|
||||||
|
App.getContext(),
|
||||||
|
"$playlistName created successfully",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
checkPlaylistExists(playlistName).isNotEmpty() -> {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
App.getContext(),
|
App.getContext(),
|
||||||
"Playlist already exists",
|
"Playlist already exists",
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
if (songs.isNotEmpty()) {
|
}
|
||||||
|
playlists.isNotEmpty() -> {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
App.getContext(),
|
App.getContext(),
|
||||||
"Adding songs to $playlistName",
|
"Added ${songs.size} song(s) to $playlistName",
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue