mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: move activity out of BTScanModel
This commit is contained in:
parent
b7d91224e4
commit
7fedc2b0e1
3 changed files with 159 additions and 190 deletions
|
|
@ -644,6 +644,20 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
scanModel.changeDeviceAddress.observe(this) { newAddr ->
|
||||
newAddr?.let {
|
||||
try {
|
||||
model.meshService?.let { service ->
|
||||
MeshService.changeDeviceAddress(this, service, newAddr)
|
||||
}
|
||||
scanModel.changeSelectedAddress(newAddr) // if it throws the change will be discarded
|
||||
} catch (ex: RemoteException) {
|
||||
errormsg("changeDeviceSelection failed, probably it is shutting down $ex.message")
|
||||
// ignore the failure and the GUI won't be updating anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bluetoothViewModel.enabled.observe(this) { enabled ->
|
||||
if (!enabled && !requestedEnable && scanModel.selectedBluetooth) {
|
||||
requestedEnable = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue