Fixed new playlist crash with same name
This commit is contained in:
parent
01be471576
commit
ac902d0bf0
2 changed files with 17 additions and 7 deletions
|
@ -65,9 +65,8 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
val playlistName = playlistView.text.toString()
|
||||
if (!TextUtils.isEmpty(playlistName)) {
|
||||
libraryViewModel.addToPlaylist(playlistName, songs)
|
||||
|
||||
} else {
|
||||
playlistContainer.error = "Playlist is can't be empty"
|
||||
playlistContainer.error = "Playlist name can't be empty"
|
||||
}
|
||||
}
|
||||
.create()
|
||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.retromusic.repository.RealRepository
|
|||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
@ -357,11 +358,21 @@ class LibraryViewModel(
|
|||
it.toSongEntity(playListId = playlist.playListId)
|
||||
})
|
||||
}
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
"Adding songs to $playlistName",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
withContext(Main) {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
"Playlist already exists",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
if (songs.isNotEmpty()) {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
"Adding songs to $playlistName",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue