diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 19:39:50 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 19:39:50 -0800 |
commit | 2fbe35585a60b5a15e99c07e13ebfe0405306813 (patch) | |
tree | 4a5aadfb5e330130565da58dfa9ca4c9c20ec287 /subsonic-android/src | |
parent | 8b4bd34030aa5615736684ba5b6e37ed86063df7 (diff) | |
parent | 8d6185dd174219f4058241b94c67451e9dfa29cd (diff) | |
download | dsub-2fbe35585a60b5a15e99c07e13ebfe0405306813.tar.gz dsub-2fbe35585a60b5a15e99c07e13ebfe0405306813.tar.bz2 dsub-2fbe35585a60b5a15e99c07e13ebfe0405306813.zip |
Merge branch 'master' into EditPlaylist
Diffstat (limited to 'subsonic-android/src')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 6ff45dee..e04fc00c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -30,6 +30,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.RemoteControlClient; +import android.os.AsyncTask; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; @@ -181,15 +182,7 @@ public class DownloadServiceLifecycleSupport { } public void serializeDownloadQueue() { - State state = new State(); - for (DownloadFile downloadFile : downloadService.getSongs()) { - 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); + new SerializeTask().execute(); } private void deserializeDownloadQueue() { @@ -277,4 +270,22 @@ public class DownloadServiceLifecycleSupport { private int currentPlayingIndex; private int currentPlayingPosition; } + + 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); + + return null; + } + } }
\ No newline at end of file |