diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-08-21 16:30:11 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-08-21 16:30:11 -0700 |
commit | 1f32f067295d0aff56c373e9bc9069e2e712c21e (patch) | |
tree | 53cb6f7ea07dd24c76bad4b76e07b67a2f31dfda | |
parent | aba8713d49d5f7ce7acde8d8714230dfb2df9eac (diff) | |
download | dsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.tar.gz dsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.tar.bz2 dsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.zip |
Background thread key event handling
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 93eefeeb..fa21f9f0 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -164,9 +164,22 @@ public class DownloadServiceLifecycleSupport { public void onStart(Intent intent) { if (intent != null && intent.getExtras() != null) { - KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); + final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (event != null) { - handleKeyEvent(event); + new Thread(new Runnable(){ + @Override + public void run() { + try { + // Make sure everything is ready to go before handling event + if(!setup.get()) { + lock.lock(); + } + handleKeyEvent(event); + } finally { + lock.unlock(); + } + } + }); } } } |