From febeaf37c7344e7629f30a72de1488df5129950a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 21 May 2018 21:37:52 +0200 Subject: [PATCH] correcting the song migration --- .../simplemobiletools/musicplayer/activities/MainActivity.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt index 84daaa36..a334bbc5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt @@ -249,11 +249,12 @@ class MainActivity : SimpleActivity(), SongListListener { dbHelper.getAllPlaylists { it.forEach { val playlist = it - val newPlaylistId = playlistDAO.insert(it).toInt() + val newPlaylistId = if (playlist.id == ALL_SONGS_PLAYLIST_ID) ALL_SONGS_PLAYLIST_ID else playlistDAO.insert(playlist.copy(id = 0)).toInt() val playlistSongPaths = songs.filter { it.playListId == newPlaylistId }.map { it.path } as ArrayList - RoomHelper(applicationContext).addSongsToPlaylist(playlistSongPaths, playlist.id) + RoomHelper(applicationContext).addSongsToPlaylist(playlistSongPaths, newPlaylistId) } + playlistChanged(ALL_SONGS_PLAYLIST_ID) config.wereSongsMigrated = true } }