aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-03-11 17:57:32 -0700
committerScott Jackson <daneren2005@gmail.com>2015-03-11 17:57:32 -0700
commit28f7bdeede8609b365219caf6e998f3e31905d5f (patch)
treefbe4c364a6e543ecf57c6f50a2ad1ce1050a0c75
parentd29f9f7073c4a74c072cf7894b8314e793cea9ac (diff)
downloaddsub-28f7bdeede8609b365219caf6e998f3e31905d5f.tar.gz
dsub-28f7bdeede8609b365219caf6e998f3e31905d5f.tar.bz2
dsub-28f7bdeede8609b365219caf6e998f3e31905d5f.zip
Delay 5 seconds to remove DLNA target in case it is just a temporary glitch
-rw-r--r--src/github/daneren2005/dsub/provider/DLNARouteProvider.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
index 8d9c5f45..54c9ffb5 100644
--- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
+++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
@@ -68,6 +68,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
private HashMap<String, DLNADevice> devices = new HashMap<String, DLNADevice>();
private List<String> adding = new ArrayList<String>();
+ private List<String> removing = new ArrayList<String>();
private AndroidUpnpService dlnaService;
private ServiceConnection dlnaServiceConnection;
private boolean searchOnConnect = false;
@@ -215,6 +216,11 @@ public class DLNARouteProvider extends MediaRouteProvider {
if(adding.contains(id)) {
return;
}
+ // Just a temp disconnect, already have it's info
+ if(removing.contains(id)) {
+ removing.remove(id);
+ return;
+ }
adding.add(id);
if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) {
@@ -261,16 +267,21 @@ public class DLNARouteProvider extends MediaRouteProvider {
}
private void deviceRemoved(Device device) {
if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) {
- String id = device.getIdentity().getUdn().toString();
- devices.remove(id);
-
- // Make sure we do this on the main thread
- downloadService.post(new Runnable() {
+ final String id = device.getIdentity().getUdn().toString();
+ removing.add(id);
+
+ // Delay removal for a few seconds to make sure that it isn't just a temp disconnect
+ dlnaService.getControlPoint().search();
+ downloadService.postDelayed(new Runnable() {
@Override
public void run() {
- broadcastDescriptors();
+ if(removing.contains(id)) {
+ devices.remove(id);
+ removing.remove(id);
+ broadcastDescriptors();
+ }
}
- });
+ }, 5000L);
}
}