aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-03-22 00:47:38 -0700
committerScott Jackson <daneren2005@gmail.com>2014-03-22 00:47:38 -0700
commit678949d6724efe3cafb70008e9d91e28a18bdf46 (patch)
treec1da76ce61ba72f42a31735deedcadc3493df833 /src
parent7494ecafa2ddf835ca71d3bf2f7d76b478b55a49 (diff)
downloaddsub-678949d6724efe3cafb70008e9d91e28a18bdf46.tar.gz
dsub-678949d6724efe3cafb70008e9d91e28a18bdf46.tar.bz2
dsub-678949d6724efe3cafb70008e9d91e28a18bdf46.zip
Try reconnecting on app startup
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 9c7cb459..7cf76e4f 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -1186,7 +1186,7 @@ public class DownloadService extends Service {
}
if(routeId != null) {
- handler.post(new Runnable() {
+ final Runnable delayedReconnect = new Runnable() {
@Override
public void run() {
RouteInfo info = mediaRouter.getRouteForId(routeId);
@@ -1198,6 +1198,23 @@ public class DownloadService extends Service {
setRemoteState(RemoteControlState.CHROMECAST, controller);
}
}
+ mediaRouter.stopScan();
+ }
+ };
+
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ mediaRouter.startScan();
+ RouteInfo info = mediaRouter.getRouteForId(routeId);
+ if(info == null) {
+ handler.postDelayed(delayedReconnect, 2000L);
+ } else if(newState == RemoteControlState.CHROMECAST) {
+ RemoteController controller = mediaRouter.getRemoteController(info);
+ if(controller != null) {
+ setRemoteState(RemoteControlState.CHROMECAST, controller);
+ }
+ }
}
});
}