mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-24 01:44:23 +01:00
Minor syntax improvements
This commit is contained in:
@@ -95,7 +95,7 @@ public class ScannerFragment extends DialogFragment {
|
||||
/**
|
||||
* Interface required to be implemented by activity.
|
||||
*/
|
||||
public static interface OnDeviceSelectedListener {
|
||||
public interface OnDeviceSelectedListener {
|
||||
/**
|
||||
* Fired when user selected the device.
|
||||
*
|
||||
@@ -105,24 +105,24 @@ public class ScannerFragment extends DialogFragment {
|
||||
* the device name. Unfortunately on some devices {@link BluetoothDevice#getName()} always returns <code>null</code>, f.e. Sony Xperia Z1 (C6903) with Android 4.3. The name has to
|
||||
* be parsed manually form the Advertisement packet.
|
||||
*/
|
||||
public void onDeviceSelected(final BluetoothDevice device, final String name);
|
||||
void onDeviceSelected(final BluetoothDevice device, final String name);
|
||||
|
||||
/**
|
||||
* Fired when scanner dialog has been cancelled without selecting a device.
|
||||
*/
|
||||
public void onDialogCanceled();
|
||||
void onDialogCanceled();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will make sure that {@link OnDeviceSelectedListener} interface is implemented by activity.
|
||||
*/
|
||||
@Override
|
||||
public void onAttach(final Activity activity) {
|
||||
super.onAttach(activity);
|
||||
public void onAttach(final Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
this.mListener = (OnDeviceSelectedListener) activity;
|
||||
this.mListener = (OnDeviceSelectedListener) context;
|
||||
} catch (final ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString() + " must implement OnDeviceSelectedListener");
|
||||
throw new ClassCastException(context.toString() + " must implement OnDeviceSelectedListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,25 +81,23 @@ public class UARTLogFragment extends ListFragment implements LoaderManager.Loade
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
// This receiver listens only for the BleProfileService.BROADCAST_CONNECTION_STATE action, no need to check it.
|
||||
|
||||
final int state = intent.getIntExtra(BleProfileService.EXTRA_CONNECTION_STATE, BleProfileService.STATE_DISCONNECTED);
|
||||
|
||||
switch (state) {
|
||||
case BleProfileService.STATE_CONNECTED: {
|
||||
onDeviceConnected();
|
||||
break;
|
||||
}
|
||||
case BleProfileService.STATE_DISCONNECTED: {
|
||||
onDeviceDisconnected();
|
||||
break;
|
||||
}
|
||||
case BleProfileService.STATE_CONNECTING:
|
||||
case BleProfileService.STATE_DISCONNECTING:
|
||||
// current implementation does nothing in this states
|
||||
default:
|
||||
// there should be no other actions
|
||||
break;
|
||||
|
||||
case BleProfileService.STATE_CONNECTED: {
|
||||
onDeviceConnected();
|
||||
break;
|
||||
}
|
||||
case BleProfileService.STATE_DISCONNECTED: {
|
||||
onDeviceDisconnected();
|
||||
break;
|
||||
}
|
||||
case BleProfileService.STATE_CONNECTING:
|
||||
case BleProfileService.STATE_DISCONNECTING:
|
||||
// current implementation does nothing in this states
|
||||
default:
|
||||
// there should be no other actions
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user