aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-08-21 16:30:11 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-08-21 16:30:11 -0700
commit1f32f067295d0aff56c373e9bc9069e2e712c21e (patch)
tree53cb6f7ea07dd24c76bad4b76e07b67a2f31dfda /src
parentaba8713d49d5f7ce7acde8d8714230dfb2df9eac (diff)
downloaddsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.tar.gz
dsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.tar.bz2
dsub-1f32f067295d0aff56c373e9bc9069e2e712c21e.zip
Background thread key event handling
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java17
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();
+ }
+ }
+ });
}
}
}