Annotations added

This commit is contained in:
Aleksander Nowakowski
2018-11-12 14:07:50 +01:00
parent 7168b7d067
commit ce8bcdf495
2 changed files with 17 additions and 13 deletions

View File

@@ -139,7 +139,7 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements
} }
@Override @Override
public void onDeviceDisconnected(final BluetoothDevice device) { public void onDeviceDisconnected(@NonNull final BluetoothDevice device) {
super.onDeviceDisconnected(device); super.onDeviceDisconnected(device);
setOperationInProgress(false); setOperationInProgress(false);
runOnUiThread(() -> mBatteryLevelView.setText(R.string.not_available)); runOnUiThread(() -> mBatteryLevelView.setText(R.string.not_available));

View File

@@ -50,6 +50,7 @@ import no.nordicsemi.android.nrftoolbox.app.ExpandableListActivity;
import no.nordicsemi.android.nrftoolbox.scanner.ScannerFragment; import no.nordicsemi.android.nrftoolbox.scanner.ScannerFragment;
import no.nordicsemi.android.nrftoolbox.utility.DebugLogger; import no.nordicsemi.android.nrftoolbox.utility.DebugLogger;
@SuppressWarnings("unused")
public abstract class BleProfileExpandableListActivity extends ExpandableListActivity implements BleManagerCallbacks, ScannerFragment.OnDeviceSelectedListener { public abstract class BleProfileExpandableListActivity extends ExpandableListActivity implements BleManagerCallbacks, ScannerFragment.OnDeviceSelectedListener {
private static final String TAG = "BaseProfileActivity"; private static final String TAG = "BaseProfileActivity";
@@ -100,6 +101,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
/** /**
* You may do some initialization here. This method is called from {@link #onCreate(Bundle)} before the view was created. * You may do some initialization here. This method is called from {@link #onCreate(Bundle)} before the view was created.
*/ */
@SuppressWarnings("unused")
protected void onInitialize(final Bundle savedInstanceState) { protected void onInitialize(final Bundle savedInstanceState) {
// empty default implementation // empty default implementation
} }
@@ -119,6 +121,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
* @param savedInstanceState contains the data it most recently supplied in {@link #onSaveInstanceState(Bundle)}. * @param savedInstanceState contains the data it most recently supplied in {@link #onSaveInstanceState(Bundle)}.
* Note: <b>Otherwise it is null</b>. * Note: <b>Otherwise it is null</b>.
*/ */
@SuppressWarnings("unused")
protected void onViewCreated(final Bundle savedInstanceState) { protected void onViewCreated(final Bundle savedInstanceState) {
// empty default implementation // empty default implementation
} }
@@ -171,6 +174,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
* @param itemId the menu item id * @param itemId the menu item id
* @return <code>true</code> if action has been handled * @return <code>true</code> if action has been handled
*/ */
@SuppressWarnings("unused")
protected boolean onOptionsItemSelected(final int itemId) { protected boolean onOptionsItemSelected(final int itemId) {
// Overwrite when using menu other than R.menu.help // Overwrite when using menu other than R.menu.help
return false; return false;
@@ -260,7 +264,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
} }
@Override @Override
public void onDeviceConnecting(final BluetoothDevice device) { public void onDeviceConnecting(@NonNull final BluetoothDevice device) {
runOnUiThread(() -> { runOnUiThread(() -> {
mDeviceNameView.setText(mDeviceName != null ? mDeviceName : getString(R.string.not_available)); mDeviceNameView.setText(mDeviceName != null ? mDeviceName : getString(R.string.not_available));
mConnectButton.setText(R.string.action_connecting); mConnectButton.setText(R.string.action_connecting);
@@ -268,18 +272,18 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
} }
@Override @Override
public void onDeviceConnected(final BluetoothDevice device) { public void onDeviceConnected(@NonNull final BluetoothDevice device) {
mDeviceConnected = true; mDeviceConnected = true;
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnect)); runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnect));
} }
@Override @Override
public void onDeviceDisconnecting(final BluetoothDevice device) { public void onDeviceDisconnecting(@NonNull final BluetoothDevice device) {
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnecting)); runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnecting));
} }
@Override @Override
public void onDeviceDisconnected(final BluetoothDevice device) { public void onDeviceDisconnected(@NonNull final BluetoothDevice device) {
mDeviceConnected = false; mDeviceConnected = false;
mBleManager.close(); mBleManager.close();
runOnUiThread(() -> { runOnUiThread(() -> {
@@ -289,43 +293,43 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
} }
@Override @Override
public void onLinkLossOccurred(final BluetoothDevice device) { public void onLinkLossOccurred(@NonNull final BluetoothDevice device) {
mDeviceConnected = false; mDeviceConnected = false;
} }
@Override @Override
public void onServicesDiscovered(final BluetoothDevice device, boolean optionalServicesFound) { public void onServicesDiscovered(@NonNull final BluetoothDevice device, boolean optionalServicesFound) {
// this may notify user or show some views // this may notify user or show some views
} }
@Override @Override
public void onDeviceReady(final BluetoothDevice device) { public void onDeviceReady(@NonNull final BluetoothDevice device) {
// empty default implementation // empty default implementation
} }
@Override @Override
public void onBondingRequired(final BluetoothDevice device) { public void onBondingRequired(@NonNull final BluetoothDevice device) {
showToast(R.string.bonding); showToast(R.string.bonding);
} }
@Override @Override
public void onBonded(final BluetoothDevice device) { public void onBonded(@NonNull final BluetoothDevice device) {
showToast(R.string.bonded); showToast(R.string.bonded);
} }
@Override @Override
public void onBondingFailed(final BluetoothDevice device) { public void onBondingFailed(@NonNull final BluetoothDevice device) {
showToast(R.string.bonding_failed); showToast(R.string.bonding_failed);
} }
@Override @Override
public void onError(final BluetoothDevice device, final String message, final int errorCode) { public void onError(@NonNull final BluetoothDevice device, @NonNull final String message, final int errorCode) {
DebugLogger.e(TAG, "Error occurred: " + message + ", error code: " + errorCode); DebugLogger.e(TAG, "Error occurred: " + message + ", error code: " + errorCode);
showToast(message + " (" + errorCode + ")"); showToast(message + " (" + errorCode + ")");
} }
@Override @Override
public void onDeviceNotSupported(final BluetoothDevice device) { public void onDeviceNotSupported(@NonNull final BluetoothDevice device) {
showToast(R.string.not_supported); showToast(R.string.not_supported);
} }