aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-04-09 20:28:59 -0700
committerScott Jackson <daneren2005@gmail.com>2013-04-09 20:28:59 -0700
commitfd8fe0b59f21763f8335a4750198cb8068d1600e (patch)
tree9eafe1dc2f64fe6bfb0aead55164617841eb44d1 /subsonic-android/src
parent0978853ad47c44e0faed4bc6bbe18b9470295dd2 (diff)
downloaddsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.tar.gz
dsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.tar.bz2
dsub-fd8fe0b59f21763f8335a4750198cb8068d1600e.zip
AsyncTask the deserilization of now playing list
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java30
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;
+ }
+ }
}