Search in sources :

Example 1 with BeamDeviceAdapter

use of butter.droid.base.manager.internal.beaming.BeamDeviceAdapter 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

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 ConnectableDevice (com.connectsdk.device.ConnectableDevice)1 DaggerAppCompatDialogFragment (dagger.android.support.DaggerAppCompatDialogFragment)1 Inject (javax.inject.Inject)1