diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-12-12 15:56:26 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-12-12 15:56:26 -0800 |
commit | 26873c657849a1351618950a1533fd59b3422ba8 (patch) | |
tree | 556fd6d5bca70969db4a0f7693d8057162e5fdbe /app/src/main/java | |
parent | 5d5b110ca0f8d7d5e599a401a7931a5cd78e9ffc (diff) | |
download | dsub-26873c657849a1351618950a1533fd59b3422ba8.tar.gz dsub-26873c657849a1351618950a1533fd59b3422ba8.tar.bz2 dsub-26873c657849a1351618950a1533fd59b3422ba8.zip |
Speed up addSongsImpl enough we can load for playlists as well
Diffstat (limited to 'app/src/main/java')
-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) { |