aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-15 14:58:43 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-15 14:58:43 -0800
commit9ecd346b924dea54fe48c7b7686d833cc2ede09f (patch)
tree44bcd605aa787c4fe2aacb04b028d6e1222e7c67
parent5126e69994f260bfd5676a79240074734f5566cc (diff)
downloaddsub-9ecd346b924dea54fe48c7b7686d833cc2ede09f.tar.gz
dsub-9ecd346b924dea54fe48c7b7686d833cc2ede09f.tar.bz2
dsub-9ecd346b924dea54fe48c7b7686d833cc2ede09f.zip
Fix multiple Jukebox providers after using Exit
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java1
-rw-r--r--src/github/daneren2005/dsub/util/MediaRouteManager.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index e83be019..7fec5707 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -273,6 +273,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
remoteController.stop();
remoteController.shutdown();
}
+ mediaRouter.destroy();
Util.hidePlayingNotification(this, this, handler);
Util.hideDownloadingNotification(this);
}
diff --git a/src/github/daneren2005/dsub/util/MediaRouteManager.java b/src/github/daneren2005/dsub/util/MediaRouteManager.java
index 7c0d33e6..9d68f014 100644
--- a/src/github/daneren2005/dsub/util/MediaRouteManager.java
+++ b/src/github/daneren2005/dsub/util/MediaRouteManager.java
@@ -16,10 +16,14 @@
package github.daneren2005.dsub.util;
import android.support.v7.media.MediaControlIntent;
+import android.support.v7.media.MediaRouteProvider;
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;
import android.util.Log;
+import java.util.ArrayList;
+import java.util.List;
+
import github.daneren2005.dsub.domain.RemoteControlState;
import github.daneren2005.dsub.provider.JukeboxRouteProvider;
import github.daneren2005.dsub.service.DownloadServiceImpl;
@@ -36,6 +40,7 @@ public class MediaRouteManager extends MediaRouter.Callback {
private DownloadServiceImpl downloadService;
private MediaRouter router;
private MediaRouteSelector selector;
+ private List<MediaRouteProvider> providers = new ArrayList<MediaRouteProvider>();
static {
try {
@@ -53,6 +58,12 @@ public class MediaRouteManager extends MediaRouter.Callback {
buildSelector();
}
+ public void destroy() {
+ for(MediaRouteProvider provider: providers) {
+ router.removeProvider(provider);
+ }
+ }
+
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo info) {
if(castAvailable) {
@@ -81,6 +92,7 @@ public class MediaRouteManager extends MediaRouter.Callback {
private void addProviders() {
JukeboxRouteProvider routeProvider = new JukeboxRouteProvider(downloadService);
router.addProvider(routeProvider);
+ providers.add(routeProvider);
}
private void buildSelector() {
MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder();