Small code refactoring in base profile activities classes

This commit is contained in:
Aleksander Nowakowski
2017-11-02 13:55:09 +01:00
parent 392cd5d31f
commit bdf31bd93c
4 changed files with 14 additions and 12 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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>