diff options
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index e04fc00c..6c9a84ad 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -167,7 +167,7 @@ public class DownloadServiceLifecycleSupport { public void onDestroy() { executorService.shutdown(); - serializeDownloadQueue(); + serializeDownloadQueueNow(); downloadService.clear(false); downloadService.unregisterReceiver(ejectEventReceiver); downloadService.unregisterReceiver(headsetEventReceiver); @@ -184,6 +184,19 @@ public class DownloadServiceLifecycleSupport { public void serializeDownloadQueue() { new SerializeTask().execute(); } + + 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(); + + Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); + FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); + } private void deserializeDownloadQueue() { State state = FileUtil.deserialize(downloadService, FILENAME_DOWNLOADS_SER); @@ -274,18 +287,8 @@ public class DownloadServiceLifecycleSupport { private class SerializeTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { - 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(); - - Log.i(TAG, "Serialized currentPlayingIndex: " + state.currentPlayingIndex + ", currentPlayingPosition: " + state.currentPlayingPosition); - FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); - + serializeDownloadQueueNow(); return null; } } -}
\ No newline at end of file +} |