diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-03-14 19:56:18 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-03-14 19:56:18 -0700 |
commit | 07cdb62bb7cddcf9cbe499cf3d05e29b4be34644 (patch) | |
tree | 403e2edea594f4f3706d9aa242c2eacb9c28e590 /src/github | |
parent | a584c0d6fedb39b6a7c0fdedb5ff62928c9e6f90 (diff) | |
download | dsub-07cdb62bb7cddcf9cbe499cf3d05e29b4be34644.tar.gz dsub-07cdb62bb7cddcf9cbe499cf3d05e29b4be34644.tar.bz2 dsub-07cdb62bb7cddcf9cbe499cf3d05e29b4be34644.zip |
Change so final serialization on exit is done in background thread still
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 278c7e4f..afcea3e5 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -238,8 +238,8 @@ public class DownloadServiceLifecycleSupport { } public void onDestroy() { + serializeDownloadQueue(); eventLooper.quit(); - serializeDownloadQueueNow(); downloadService.unregisterReceiver(ejectEventReceiver); downloadService.unregisterReceiver(intentReceiver); @@ -256,12 +256,13 @@ public class DownloadServiceLifecycleSupport { return; } + final List<DownloadFile> songs = new ArrayList<DownloadFile>(downloadService.getSongs()); eventHandler.post(new Runnable() { @Override public void run() { if(lock.tryLock()) { try { - serializeDownloadQueueNow(); + serializeDownloadQueueNow(songs); } finally { lock.unlock(); } @@ -270,8 +271,7 @@ public class DownloadServiceLifecycleSupport { }); } - public void serializeDownloadQueueNow() { - List<DownloadFile> songs = new ArrayList<DownloadFile>(downloadService.getSongs()); + public void serializeDownloadQueueNow(List<DownloadFile> songs) { State state = new State(); for (DownloadFile downloadFile : songs) { state.songs.add(downloadFile.getSong()); |