From 07cdb62bb7cddcf9cbe499cf3d05e29b4be34644 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 14 Mar 2015 19:56:18 -0700 Subject: Change so final serialization on exit is done in background thread still --- .../daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 8 ++++---- 1 file 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 songs = new ArrayList(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 songs = new ArrayList(downloadService.getSongs()); + public void serializeDownloadQueueNow(List songs) { State state = new State(); for (DownloadFile downloadFile : songs) { state.songs.add(downloadFile.getSong()); -- cgit v1.2.3