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()
|
val playlistName = playlistView.text.toString()
|
||||||
if (!TextUtils.isEmpty(playlistName)) {
|
if (!TextUtils.isEmpty(playlistName)) {
|
||||||
libraryViewModel.addToPlaylist(playlistName, songs)
|
libraryViewModel.addToPlaylist(playlistName, songs)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
playlistContainer.error = "Playlist is can't be empty"
|
playlistContainer.error = "Playlist name can't be empty"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.create()
|
.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.DensityUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -357,11 +358,21 @@ class LibraryViewModel(
|
||||||
it.toSongEntity(playListId = playlist.playListId)
|
it.toSongEntity(playListId = playlist.playListId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Toast.makeText(
|
withContext(Main) {
|
||||||
App.getContext(),
|
Toast.makeText(
|
||||||
"Adding songs to $playlistName",
|
App.getContext(),
|
||||||
Toast.LENGTH_SHORT
|
"Playlist already exists",
|
||||||
).show()
|
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