diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-02-25 10:55:47 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-02-25 10:55:47 -0800 |
commit | e7b5dbf827faa9b620db8d15e5e15ffe210c2ab1 (patch) | |
tree | 8de47cd834864de05d3b625ccec50478b759dbfc /subsonic-android/src | |
parent | 7989cf0c1399724220a9b9a56009d2a0c82988be (diff) | |
download | dsub-e7b5dbf827faa9b620db8d15e5e15ffe210c2ab1.tar.gz dsub-e7b5dbf827faa9b620db8d15e5e15ffe210c2ab1.tar.bz2 dsub-e7b5dbf827faa9b620db8d15e5e15ffe210c2ab1.zip |
When closing serialize immediately instead of in background task
Diffstat (limited to 'subsonic-android/src')
-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 +} |