diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-05-19 17:24:25 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-05-19 17:24:25 -0700 |
commit | 6946b212e47f8fd956c7f49280ae2beaf8919d48 (patch) | |
tree | 709e17e6d7600a0649c3b2bd5489636c95ca3159 /app/src | |
parent | 7ee9cd9d8466a5870da3c3a2a1e3002038a22f9f (diff) | |
download | dsub-6946b212e47f8fd956c7f49280ae2beaf8919d48.tar.gz dsub-6946b212e47f8fd956c7f49280ae2beaf8919d48.tar.bz2 dsub-6946b212e47f8fd956c7f49280ae2beaf8919d48.zip |
Debounce next/previous so bad devices can't spam it
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index ce2c81f2..78b6c78e 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -56,6 +56,7 @@ import static github.daneren2005.dsub.domain.PlayerState.PREPARING; public class DownloadServiceLifecycleSupport { private static final String TAG = DownloadServiceLifecycleSupport.class.getSimpleName(); public static final String FILENAME_DOWNLOADS_SER = "downloadstate2.ser"; + private static final int DEBOUNCE_TIME = 200; private final DownloadService downloadService; private Looper eventLooper; @@ -413,11 +414,17 @@ public class DownloadServiceLifecycleSupport { break; case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_PREVIOUS: - downloadService.previous(); + if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) { + lastPressTime = System.currentTimeMillis(); + downloadService.previous(); + } break; case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_NEXT: - downloadService.next(); + if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) { + lastPressTime = System.currentTimeMillis(); + downloadService.next(); + } break; case KeyEvent.KEYCODE_MEDIA_REWIND: downloadService.rewind(); |