aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-05-02 07:44:14 -0700
committerScott Jackson <daneren2005@gmail.com>2013-05-02 07:44:14 -0700
commitb092a245491349021e1d79c9f884d92a92e5c2b9 (patch)
tree746b22a14d3a4307ab730e7c23a58e5700027a15 /subsonic-android
parent442f5839a79f1c823445921b7e7f8f3c634dfd58 (diff)
downloaddsub-b092a245491349021e1d79c9f884d92a92e5c2b9.tar.gz
dsub-b092a245491349021e1d79c9f884d92a92e5c2b9.tar.bz2
dsub-b092a245491349021e1d79c9f884d92a92e5c2b9.zip
Only use executeOnExecutor for ICS+
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java94
1 files changed, 56 insertions, 38 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index a8600252..68917d9e 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -31,6 +31,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.media.RemoteControlClient;
import android.os.AsyncTask;
+import android.os.Build;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -182,7 +183,11 @@ public class DownloadServiceLifecycleSupport {
}
public void serializeDownloadQueue() {
- new SerializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ new SerializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ } else {
+ new SerializeTask().execute();
+ }
}
public void serializeDownloadQueueNow() {
@@ -199,7 +204,11 @@ public class DownloadServiceLifecycleSupport {
}
private void deserializeDownloadQueue() {
- new DeserializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ new DeserializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ } else {
+ new DeserializeTask().execute();
+ }
}
private void deserializeDownloadQueueNow() {
State state = FileUtil.deserialize(downloadService, FILENAME_DOWNLOADS_SER);
@@ -214,42 +223,51 @@ public class DownloadServiceLifecycleSupport {
}
private void handleKeyEvent(KeyEvent event) {
- if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) {
- return;
- }
-
- switch (event.getKeyCode()) {
- case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- case KeyEvent.KEYCODE_HEADSETHOOK:
- downloadService.togglePlayPause();
- break;
- case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
- case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
- downloadService.previous();
- break;
- case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
- case KeyEvent.KEYCODE_MEDIA_NEXT:
- if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
- downloadService.next();
- }
- break;
- case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
- case KeyEvent.KEYCODE_MEDIA_STOP:
- downloadService.stop();
- break;
- case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
- case KeyEvent.KEYCODE_MEDIA_PLAY:
- if(downloadService.getPlayerState() != PlayerState.STARTED) {
- downloadService.start();
- }
- break;
- case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
- case KeyEvent.KEYCODE_MEDIA_PAUSE:
- downloadService.pause();
- default:
- break;
- }
+ if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) {
+ switch (event.getKeyCode()) {
+ case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
+ case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
+ downloadService.seekTo(downloadService.getPlayerPosition() - 10000);
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
+ case KeyEvent.KEYCODE_MEDIA_NEXT:
+ downloadService.seekTo(downloadService.getPlayerPosition() + 10000);
+ break;
+ }
+ } else if(event.getAction() == KeyEvent.ACTION_UP) {
+ switch (event.getKeyCode()) {
+ case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ case KeyEvent.KEYCODE_HEADSETHOOK:
+ downloadService.togglePlayPause();
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
+ case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
+ downloadService.previous();
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
+ case KeyEvent.KEYCODE_MEDIA_NEXT:
+ if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
+ downloadService.next();
+ }
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
+ case KeyEvent.KEYCODE_MEDIA_STOP:
+ downloadService.stop();
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
+ case KeyEvent.KEYCODE_MEDIA_PLAY:
+ if(downloadService.getPlayerState() != PlayerState.STARTED) {
+ downloadService.start();
+ }
+ break;
+ case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
+ case KeyEvent.KEYCODE_MEDIA_PAUSE:
+ downloadService.pause();
+ default:
+ break;
+ }
+ }
}
/**