diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java | 3 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java | 21 |
2 files changed, 15 insertions, 9 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java index e188f97f..c0851009 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java @@ -258,8 +258,7 @@ public class CachedMusicService implements MusicService { } if(dir == null) { dir = musicService.getPlaylist(refresh, id, name, context, progressListener); - // With large playlists this takes too long - // updateAllSongs(context, dir); + updateAllSongs(context, dir); FileUtil.serialize(context, dir, getCacheName(context, "playlist", id)); File playlistFile = FileUtil.getPlaylistFile(context, Util.getServerName(context, musicService.getInstance(context)), dir.getName()); diff --git a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java index eb52de9c..08f6f461 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java +++ b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java @@ -113,14 +113,21 @@ public class SongDBHandler extends SQLiteOpenHelper { addSongsImpl(db, Util.getRestUrlHash(context, instance), entries); } protected synchronized void addSongsImpl(SQLiteDatabase db, int serverKey, List<Pair<String, String>> entries) { - for(Pair<String, String> entry: entries) { - ContentValues values = new ContentValues(); - values.put(SONGS_SERVER_KEY, serverKey); - values.put(SONGS_SERVER_ID, entry.getFirst()); - values.put(SONGS_COMPLETE_PATH, entry.getSecond()); + db.beginTransaction(); + try { + for (Pair<String, String> entry : entries) { + ContentValues values = new ContentValues(); + values.put(SONGS_SERVER_KEY, serverKey); + values.put(SONGS_SERVER_ID, entry.getFirst()); + values.put(SONGS_COMPLETE_PATH, entry.getSecond()); - db.insertWithOnConflict(TABLE_SONGS, null, values, SQLiteDatabase.CONFLICT_IGNORE); - } + db.insertWithOnConflict(TABLE_SONGS, null, values, SQLiteDatabase.CONFLICT_IGNORE); + } + + db.setTransactionSuccessful(); + } catch(Exception e) {} + + db.endTransaction(); } public synchronized void setSongPlayed(DownloadFile downloadFile, boolean submission) { |