diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/ScannerFragment.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/ScannerFragment.java index c5e5366d..f301540d 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/ScannerFragment.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/ScannerFragment.java @@ -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 null, 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"); } } diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTLogFragment.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTLogFragment.java index ce5e16c4..a8bb7bb0 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTLogFragment.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTLogFragment.java @@ -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; } } };