do not refetch all items at getAllDeviceSongs, just the new ones

This commit is contained in:
tibbi 2018-05-21 21:01:35 +02:00
parent 4f38ea25b1
commit a0e3ea1d4e
2 changed files with 3 additions and 1 deletions

View file

@ -28,7 +28,6 @@ fun Context.sendIntent(action: String) {
val Context.config: Config get() = Config.newInstance(applicationContext)
val Context.playlistDAO: PlaylistsDao get() = getSongsDB().PlaylistsDao()
val Context.songsDAO: SongsDao get() = getSongsDB().SongsDao()

View file

@ -26,6 +26,7 @@ import com.simplemobiletools.musicplayer.activities.MainActivity
import com.simplemobiletools.musicplayer.databases.SongsDatabase
import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.extensions.getPlaylistSongs
import com.simplemobiletools.musicplayer.extensions.songsDAO
import com.simplemobiletools.musicplayer.helpers.*
import com.simplemobiletools.musicplayer.models.Events
import com.simplemobiletools.musicplayer.models.Song
@ -294,6 +295,8 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
cursor?.close()
}
val storedAllSongPaths = songsDAO.getSongsFromPlaylist(ALL_SONGS_PLAYLIST_ID).map { it.path }
paths.removeAll(storedAllSongPaths)
RoomHelper(this).addSongsToPlaylist(paths)
}