diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-05-18 10:44:40 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-05-18 10:44:40 -0700 |
commit | e4aed348657f717df1968904285f5e93772c5000 (patch) | |
tree | 00f9ed119d8941f923347cf2210e731b09e751b3 | |
parent | f5e8036cda83b5d52092cddf127fb299688e076a (diff) | |
download | dsub-e4aed348657f717df1968904285f5e93772c5000.tar.gz dsub-e4aed348657f717df1968904285f5e93772c5000.tar.bz2 dsub-e4aed348657f717df1968904285f5e93772c5000.zip |
Do synchronized setOnline logic in events thread
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 15 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 6c3b2e24..e1891a6d 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -524,14 +524,23 @@ public class DownloadService extends Service { updateJukeboxPlaylist(); } - public synchronized void setOnline(boolean online) { + public void setOnline(final boolean online) { if(online) { mediaRouter.addOfflineProviders(); - checkDownloads(); } else { mediaRouter.removeOfflineProviders(); - clearIncomplete(); } + + lifecycleSupport.post(new Runnable() { + @Override + public void run() { + if(online) { + checkDownloads(); + } else { + clearIncomplete(); + } + } + }); } public synchronized int size() { diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 5e8b0f8b..db69517c 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -261,6 +261,10 @@ public class DownloadServiceLifecycleSupport { FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); } + public void post(Runnable runnable) { + eventHandler.post(runnable); + } + private void deserializeDownloadQueueNow() { State state = FileUtil.deserialize(downloadService, FILENAME_DOWNLOADS_SER, State.class); if (state == null) { |