Search in sources :

Example 6 with ConnectableDevice

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;
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice) DiscoveryManager(com.connectsdk.discovery.DiscoveryManager)

Example 7 with ConnectableDevice

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);
        }
    }
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Example 8 with ConnectableDevice

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);
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Example 9 with ConnectableDevice

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);
        }
    }
}
Also used : ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Example 10 with ConnectableDevice

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);
    }
}
Also used : AlertDialog(android.app.AlertDialog) BeamDeviceAdapter(butter.droid.base.manager.internal.beaming.BeamDeviceAdapter) AlertDialog(android.app.AlertDialog) Inject(javax.inject.Inject) FragmentManager(android.support.v4.app.FragmentManager) Bundle(android.os.Bundle) DaggerAppCompatDialogFragment(dagger.android.support.DaggerAppCompatDialogFragment) R(butter.droid.R) ConnectableDevice(com.connectsdk.device.ConnectableDevice) Dialog(android.app.Dialog) BeamDeviceAdapter(butter.droid.base.manager.internal.beaming.BeamDeviceAdapter) BeamManager(butter.droid.base.manager.internal.beaming.BeamManager) ConnectableDevice(com.connectsdk.device.ConnectableDevice)

Aggregations

ConnectableDevice (com.connectsdk.device.ConnectableDevice)10 DiscoveryManager (com.connectsdk.discovery.DiscoveryManager)3 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 Bundle (android.os.Bundle)1 FragmentManager (android.support.v4.app.FragmentManager)1 R (butter.droid.R)1 BeamDeviceAdapter (butter.droid.base.manager.internal.beaming.BeamDeviceAdapter)1 BeamManager (butter.droid.base.manager.internal.beaming.BeamManager)1 AirPlayService (com.connectsdk.service.AirPlayService)1 CastService (com.connectsdk.service.CastService)1 DLNAService (com.connectsdk.service.DLNAService)1 DeviceService (com.connectsdk.service.DeviceService)1 NetcastTVService (com.connectsdk.service.NetcastTVService)1 RokuService (com.connectsdk.service.RokuService)1 WebOSTVService (com.connectsdk.service.WebOSTVService)1 DaggerAppCompatDialogFragment (dagger.android.support.DaggerAppCompatDialogFragment)1 ArrayList (java.util.ArrayList)1 Inject (javax.inject.Inject)1