use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.
the class RokuService method getDIALService.
public DIALService getDIALService() {
if (dialService == null) {
DiscoveryManager discoveryManager = DiscoveryManager.getInstance();
ConnectableDevice device = discoveryManager.getAllDevices().get(serviceDescription.getIpAddress());
if (device != null) {
DIALService foundService = null;
for (DeviceService service : device.getServices()) {
if (DIALService.class.isAssignableFrom(service.getClass())) {
foundService = (DIALService) service;
break;
}
}
dialService = foundService;
}
}
return dialService;
}
use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.
the class DiscoveryManager method onServiceRemoved.
@Override
public void onServiceRemoved(DiscoveryProvider provider, ServiceDescription serviceDescription) {
if (serviceDescription == null) {
Log.w(Util.T, "onServiceRemoved: unknown service description");
return;
}
Log.d(Util.T, "onServiceRemoved: friendlyName: " + serviceDescription.getFriendlyName());
ConnectableDevice device = allDevices.get(serviceDescription.getIpAddress());
if (device != null) {
device.removeServiceWithId(serviceDescription.getServiceID());
if (device.getServices().isEmpty()) {
allDevices.remove(serviceDescription.getIpAddress());
handleDeviceLoss(device);
} else {
handleDeviceUpdate(device);
}
}
}
use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.
the class DiscoveryManager method onServiceAdded.
@Override
public void onServiceAdded(DiscoveryProvider provider, ServiceDescription serviceDescription) {
Log.d(Util.T, "Service added: " + serviceDescription.getFriendlyName() + " (" + serviceDescription.getServiceID() + ")");
boolean deviceIsNew = !allDevices.containsKey(serviceDescription.getIpAddress());
ConnectableDevice device = null;
if (deviceIsNew) {
if (connectableDeviceStore != null) {
device = connectableDeviceStore.getDevice(serviceDescription.getUUID());
if (device != null) {
allDevices.put(serviceDescription.getIpAddress(), device);
device.setIpAddress(serviceDescription.getIpAddress());
}
}
} else {
device = allDevices.get(serviceDescription.getIpAddress());
}
if (device == null) {
device = new ConnectableDevice(serviceDescription);
device.setIpAddress(serviceDescription.getIpAddress());
allDevices.put(serviceDescription.getIpAddress(), device);
deviceIsNew = true;
}
device.setFriendlyName(serviceDescription.getFriendlyName());
device.setLastDetection(Util.getTime());
device.setLastKnownIPAddress(serviceDescription.getIpAddress());
// TODO: Implement the currentSSID Property in DiscoveryManager
// device.setLastSeenOnWifi(currentSSID);
addServiceDescriptionToDevice(serviceDescription, device);
if (device.getServices().size() == 0) {
// we get here when a non-LG DLNA TV is found
allDevices.remove(serviceDescription.getIpAddress());
return;
}
if (deviceIsNew)
handleDeviceAdd(device);
else
handleDeviceUpdate(device);
}
use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.
the class DiscoveryManager method setCapabilityFilters.
public void setCapabilityFilters(List<CapabilityFilter> capabilityFilters) {
this.capabilityFilters = capabilityFilters;
for (ConnectableDevice device : compatibleDevices.values()) {
handleDeviceLoss(device);
}
compatibleDevices.clear();
for (ConnectableDevice device : allDevices.values()) {
if (deviceIsCompatible(device)) {
compatibleDevices.put(device.getIpAddress(), device);
handleDeviceAdd(device);
}
}
}
use of com.connectsdk.device.ConnectableDevice in project butter-android by butterproject.
the class BeamDeviceSelectorDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder;
if (!beamManager.isConnected()) {
adapter = new BeamDeviceAdapter(getActivity(), beamManager);
builder = new AlertDialog.Builder(getActivity()).setSingleChoiceItems(adapter, -1, (dialog, position) -> {
ConnectableDevice device = adapter.getItem(position);
beamManager.connect(device);
dismiss();
}).setTitle(R.string.select_beaming).setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
return builder.create();
} else if (beamManager.getConnectedDevice() != null) {
builder = new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.connected_to) + " " + beamManager.getConnectedDevice().getFriendlyName()).setNeutralButton(R.string.disconnect, (dialog, which) -> beamManager.disconnect());
return builder.create();
} else {
return super.onCreateDialog(savedInstanceState);
}
}
Aggregations