/** Opens a door if the user has a valid permission. */ public void openDoor(Master master, Slave slave) { Permission permission = getValidPermission(master, slave); if (permission == null) { mPermissionsListener.error(BluetoothClient.DONT_HAVE_PERMISSION); return; } mBluetoothClient = BluetoothClient.getInstance(mContext, this); if (!mBluetoothClient.isSupported()) { mBluetoothListener.bluetoothNotSupported(); return; } else if (!mBluetoothClient.isEnabled()) { mBluetoothListener.enableBluetooth(); return; } mMasterListener.doorOpening(); mBluetoothClient.executeOpenDoor(permission, master.getId(), slave.getId()); }
@Override public void error(int code) { mMasterListener.error(code); }
@Override public void doorOpened(int state) { mMasterListener.doorOpened(state); }
@Override public void slavesFound(Master master, ArrayList<Slave> slaves) { mMasterListener.slavesFound(master, slaves); }
@Override public void masterWithNoSlaves() { mMasterListener.masterWithNoSlaves(); }