diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-16 12:09:23 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-16 12:09:23 -0800 |
commit | 746dd8e2cf2bcee6cfe4bed23261bf7c2be6020f (patch) | |
tree | e9f65413d54948ecc4fd5e1f1bbb1a6fc1082037 | |
parent | 925517ab46d6dc928fd657bf6d2dde314053912e (diff) | |
download | dsub-746dd8e2cf2bcee6cfe4bed23261bf7c2be6020f.tar.gz dsub-746dd8e2cf2bcee6cfe4bed23261bf7c2be6020f.tar.bz2 dsub-746dd8e2cf2bcee6cfe4bed23261bf7c2be6020f.zip |
Add try/catch block around device add
-rw-r--r-- | src/github/daneren2005/dsub/provider/DLNARouteProvider.java | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java index e2450f1f..34ac182c 100644 --- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java +++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java @@ -211,39 +211,43 @@ public class DLNARouteProvider extends MediaRouteProvider { adding.add(id); if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) { - dlnaService.getControlPoint().execute(new GetVolume(renderingControl) { - @Override - public void received(ActionInvocation actionInvocation, int currentVolume) { - int maxVolume = 100; - StateVariable volume = renderingControl.getStateVariable("Volume"); - if(volume != null) { - StateVariableAllowedValueRange volumeRange = volume.getTypeDetails().getAllowedValueRange(); - maxVolume = (int) volumeRange.getMaximum(); - } - - // Create a new DLNADevice to represent this item - String id = device.getIdentity().getUdn().toString(); - String name = device.getDetails().getFriendlyName(); - String displayName = device.getDisplayString(); - - DLNADevice newDevice = new DLNADevice(device, id, name, displayName, currentVolume, maxVolume); - devices.put(id, newDevice); - downloadService.post(new Runnable() { - @Override - public void run() { - broadcastDescriptors(); + try { + dlnaService.getControlPoint().execute(new GetVolume(renderingControl) { + @Override + public void received(ActionInvocation actionInvocation, int currentVolume) { + int maxVolume = 100; + StateVariable volume = renderingControl.getStateVariable("Volume"); + if (volume != null) { + StateVariableAllowedValueRange volumeRange = volume.getTypeDetails().getAllowedValueRange(); + maxVolume = (int) volumeRange.getMaximum(); } - }); - adding.remove(id); - } - @Override - public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String s) { - Log.w(TAG, "Failed to get default volume for DLNA route"); - Log.w(TAG, "Reason: " + s); - adding.remove(id); - } - }); + // Create a new DLNADevice to represent this item + String id = device.getIdentity().getUdn().toString(); + String name = device.getDetails().getFriendlyName(); + String displayName = device.getDisplayString(); + + DLNADevice newDevice = new DLNADevice(device, id, name, displayName, currentVolume, maxVolume); + devices.put(id, newDevice); + downloadService.post(new Runnable() { + @Override + public void run() { + broadcastDescriptors(); + } + }); + adding.remove(id); + } + + @Override + public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String s) { + Log.w(TAG, "Failed to get default volume for DLNA route"); + Log.w(TAG, "Reason: " + s); + adding.remove(id); + } + }); + } catch(Exception e) { + Log.e(TAG, "Failed to add device", e); + } } else { adding.remove(id); } |