diff options
Diffstat (limited to 'src/github')
-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) { |