aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-03-06 16:00:13 -0800
committerScott Jackson <daneren2005@gmail.com>2014-03-06 16:00:13 -0800
commit556f043b68b6b19091fe3057cfd42b13dc961365 (patch)
treebbefe94c599376084f80e52f0d147facbe547af4
parent9976233989bba521ef26b5b605db60c69566eeb5 (diff)
downloaddsub-556f043b68b6b19091fe3057cfd42b13dc961365.tar.gz
dsub-556f043b68b6b19091fe3057cfd42b13dc961365.tar.bz2
dsub-556f043b68b6b19091fe3057cfd42b13dc961365.zip
#168 Get rid of check thread, instead cover all cases that might need to update
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java8
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java18
2 files changed, 7 insertions, 19 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index a5d687ee..79094024 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -165,7 +165,6 @@ public class DownloadService extends Service {
}
});
audioSessionId = mediaPlayer.getAudioSessionId();
- Log.d(TAG, "id: " + audioSessionId);
try {
Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
@@ -520,6 +519,7 @@ public class DownloadService extends Service {
public synchronized void setOnline(boolean online) {
if(online) {
mediaRouter.addOfflineProviders();
+ checkDownloads();
} else {
mediaRouter.removeOfflineProviders();
clearIncomplete();
@@ -781,6 +781,7 @@ public class DownloadService extends Service {
proxy.stop();
proxy = null;
}
+ checkDownloads();
}
/** Plays or resumes the playback, depending on the current player state. */
@@ -1169,6 +1170,10 @@ public class DownloadService extends Service {
Util.hidePlayingNotification(this, this, handler);
}
+ if(remoteState == RemoteControlState.LOCAL) {
+ checkDownloads();
+ }
+
if(routeId != null) {
handler.post(new Runnable() {
@Override
@@ -1402,6 +1407,7 @@ public class DownloadService extends Service {
bufferTask.start();
}
}
+ checkDownloads();
}
}
});
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 0194de82..37eaae62 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -21,8 +21,6 @@ package github.daneren2005.dsub.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -57,7 +55,6 @@ public class DownloadServiceLifecycleSupport {
private final DownloadService downloadService;
private Looper eventLooper;
private Handler eventHandler;
- private ScheduledExecutorService executorService;
private BroadcastReceiver headsetEventReceiver;
private BroadcastReceiver ejectEventReceiver;
private PhoneStateListener phoneStateListener;
@@ -102,20 +99,6 @@ public class DownloadServiceLifecycleSupport {
}
public void onCreate() {
- Runnable downloadChecker = new Runnable() {
- @Override
- public void run() {
- try {
- downloadService.checkDownloads();
- } catch (Throwable x) {
- Log.e(TAG, "checkDownloads() failed.", x);
- }
- }
- };
-
- executorService = Executors.newSingleThreadScheduledExecutor();
- executorService.scheduleWithFixedDelay(downloadChecker, 5, 5, TimeUnit.SECONDS);
-
new Thread(new Runnable() {
@Override
public void run() {
@@ -225,7 +208,6 @@ public class DownloadServiceLifecycleSupport {
}
public void onDestroy() {
- executorService.shutdown();
eventLooper.quit();
serializeDownloadQueueNow();
downloadService.unregisterReceiver(ejectEventReceiver);