mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-03 23:04:20 +01:00
Small code refactoring in base profile activities classes
This commit is contained in:
@@ -238,8 +238,6 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
}
|
||||
mDeviceName = name;
|
||||
mBleManager.setLogger(mLogSession);
|
||||
mDeviceNameView.setText(name != null ? name : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
mBleManager.connect(device);
|
||||
}
|
||||
|
||||
@@ -250,7 +248,10 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
|
||||
@Override
|
||||
public void onDeviceConnecting(final BluetoothDevice device) {
|
||||
// do nothing
|
||||
runOnUiThread(() -> {
|
||||
mDeviceNameView.setText(mDeviceName != null ? mDeviceName : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,7 +262,7 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
|
||||
@Override
|
||||
public void onDeviceDisconnecting(final BluetoothDevice device) {
|
||||
// do nothing
|
||||
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnecting));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -238,8 +238,6 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
}
|
||||
mDeviceName = name;
|
||||
mBleManager.setLogger(mLogSession);
|
||||
mDeviceNameView.setText(name != null ? name : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
mBleManager.connect(device);
|
||||
}
|
||||
|
||||
@@ -250,7 +248,10 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
|
||||
@Override
|
||||
public void onDeviceConnecting(final BluetoothDevice device) {
|
||||
// do nothing
|
||||
runOnUiThread(() -> {
|
||||
mDeviceNameView.setText(mDeviceName != null ? mDeviceName : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,7 +262,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
|
||||
@Override
|
||||
public void onDeviceDisconnecting(final BluetoothDevice device) {
|
||||
// do nothing
|
||||
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnecting));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -464,8 +464,6 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
}
|
||||
mBluetoothDevice = device;
|
||||
mDeviceName = name;
|
||||
mDeviceNameView.setText(name != null ? name : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
|
||||
// The device may not be in the range but the service will try to connect to it if it reach it
|
||||
Logger.d(mLogSession, "Creating service...");
|
||||
@@ -486,7 +484,8 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
|
||||
@Override
|
||||
public void onDeviceConnecting(final BluetoothDevice device) {
|
||||
// empty default implementation
|
||||
mDeviceNameView.setText(mDeviceName != null ? mDeviceName : getString(R.string.not_available));
|
||||
mConnectButton.setText(R.string.action_connecting);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -497,7 +496,7 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
|
||||
@Override
|
||||
public void onDeviceDisconnecting(final BluetoothDevice device) {
|
||||
// empty default implementation
|
||||
mConnectButton.setText(R.string.action_disconnecting);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<string name="action_add_device">ADD DEVICE</string>
|
||||
<string name="action_connecting">CONNECTING…</string>
|
||||
<string name="action_disconnect">DISCONNECT</string>
|
||||
<string name="action_disconnecting">DISCONNECTING…</string>
|
||||
|
||||
<string name="drawer_open">Open</string>
|
||||
<string name="drawer_close">Close</string>
|
||||
|
||||
Reference in New Issue
Block a user