diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-03-11 17:57:32 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-03-11 17:57:32 -0700 |
commit | 28f7bdeede8609b365219caf6e998f3e31905d5f (patch) | |
tree | fbe4c364a6e543ecf57c6f50a2ad1ce1050a0c75 /src/github | |
parent | d29f9f7073c4a74c072cf7894b8314e793cea9ac (diff) | |
download | dsub-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
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/provider/DLNARouteProvider.java | 25 |
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); } } |