aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+ }
+ }
}