From 47efa0e85266bc390513854ac89fca914fe9f93b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 6 Feb 2014 19:31:51 -0800 Subject: Fix cancel button --- .../service/DownloadServiceLifecycleSupport.java | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 65320f84..cd876621 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -92,8 +92,6 @@ public class DownloadServiceLifecycleSupport { } else if (DownloadServiceImpl.CMD_STOP.equals(action)) { downloadService.pause(); downloadService.seekTo(0); - } else if(DownloadServiceImpl.CANCEL_DOWNLOADS.equals(action)) { - downloadService.clearBackground(); } } }); @@ -204,19 +202,26 @@ public class DownloadServiceLifecycleSupport { } public void onStart(Intent intent) { - if (intent != null && intent.getExtras() != null) { - final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); - if (event != null) { - eventHandler.post(new Runnable() { - @Override - public void run() { - if(!setup.get()) { - lock.lock(); - lock.unlock(); + if (intent != null) { + if(intent.getExtras() != null) { + final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); + if (event != null) { + eventHandler.post(new Runnable() { + @Override + public void run() { + if(!setup.get()) { + lock.lock(); + lock.unlock(); + } + handleKeyEvent(event); } - handleKeyEvent(event); - } - }); + }); + } + } else { + String action = intent.getAction(); + if(DownloadServiceImpl.CANCEL_DOWNLOADS.equals(action)) { + downloadService.clearBackground(); + } } } } -- cgit v1.2.3