From be9219c4610a31f7a74ba9889a21cc1e0daff2a7 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 22 Feb 2014 11:06:44 -0800 Subject: #285 Add support for offline ChromeCast --- ServerProxy | 2 +- res/menu/nowplaying_offline.xml | 9 +++- .../daneren2005/dsub/fragments/MainFragment.java | 4 ++ .../dsub/service/ChromeCastController.java | 59 +++++++++++++++++++--- .../daneren2005/dsub/service/DownloadService.java | 9 ++++ .../daneren2005/dsub/util/MediaRouteManager.java | 19 +++++-- 6 files changed, 91 insertions(+), 11 deletions(-) diff --git a/ServerProxy b/ServerProxy index 1fab7a86..093db239 160000 --- a/ServerProxy +++ b/ServerProxy @@ -1 +1 @@ -Subproject commit 1fab7a8626616ea7f4df9aa3381a7c0bbf5529d6 +Subproject commit 093db23954f2343d280317dc59d33cd039715bca diff --git a/res/menu/nowplaying_offline.xml b/res/menu/nowplaying_offline.xml index 41d1d5d1..7656bf34 100644 --- a/res/menu/nowplaying_offline.xml +++ b/res/menu/nowplaying_offline.xml @@ -7,12 +7,19 @@ android:icon="?attr/shuffle" android:title="@string/download.menu_shuffle" compat:showAsAction="always|withText"/> + + + compat:showAsAction="ifRoom|withText"/> providers = new ArrayList(); + private List offlineProviders = new ArrayList(); static { try { @@ -116,10 +117,22 @@ public class MediaRouteManager extends MediaRouter.Callback { } } + public void addOfflineProviders() { + JukeboxRouteProvider jukeboxProvider = new JukeboxRouteProvider(downloadService); + router.addProvider(jukeboxProvider); + providers.add(jukeboxProvider); + offlineProviders.add(jukeboxProvider); + } + public void removeOfflineProviders() { + for(MediaRouteProvider provider: offlineProviders) { + router.removeProvider(provider); + } + } + private void addProviders() { - JukeboxRouteProvider routeProvider = new JukeboxRouteProvider(downloadService); - router.addProvider(routeProvider); - providers.add(routeProvider); + if(!Util.isOffline(downloadService)) { + addOfflineProviders(); + } } private void buildSelector() { MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder(); -- cgit v1.2.3