diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-04-09 20:28:59 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-04-09 20:28:59 -0700 |
commit | fd8fe0b59f21763f8335a4750198cb8068d1600e (patch) | |
tree | 9eafe1dc2f64fe6bfb0aead55164617841eb44d1 /subsonic-android | |
parent | 0978853ad47c44e0faed4bc6bbe18b9470295dd2 (diff) | |
download | dsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.tar.gz dsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.tar.bz2 dsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.zip |
AsyncTask the deserilization of now playing list
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index de2e40a1..a8600252 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -182,23 +182,26 @@ public class DownloadServiceLifecycleSupport { } public void serializeDownloadQueue() { - new SerializeTask().execute(); + new SerializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public void serializeDownloadQueueNow() { List<DownloadFile> songs = new ArrayList<DownloadFile>(downloadService.getSongs()); - State state = new State(); - for (DownloadFile downloadFile : songs) { - state.songs.add(downloadFile.getSong()); - } - state.currentPlayingIndex = downloadService.getCurrentPlayingIndex(); - state.currentPlayingPosition = downloadService.getPlayerPosition(); + State state = new State(); + for (DownloadFile downloadFile : songs) { + state.songs.add(downloadFile.getSong()); + } + state.currentPlayingIndex = downloadService.getCurrentPlayingIndex(); + state.currentPlayingPosition = downloadService.getPlayerPosition(); - Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); - FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); + Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); + FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); } - private void deserializeDownloadQueue() { + private void deserializeDownloadQueue() { + new DeserializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + private void deserializeDownloadQueueNow() { State state = FileUtil.deserialize(downloadService, FILENAME_DOWNLOADS_SER); if (state == null) { return; @@ -293,4 +296,11 @@ public class DownloadServiceLifecycleSupport { return null; } } + private class DeserializeTask extends AsyncTask<Void, Void, Void> { + @Override + protected Void doInBackground(Void... params) { + deserializeDownloadQueueNow(); + return null; + } + } } |