mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
simplified calls to system services
and fixed some code that assumed BluetoothManager to never be NULL
This commit is contained in:
parent
b98a8ea34b
commit
f97bc21719
4 changed files with 22 additions and 15 deletions
|
|
@ -33,6 +33,8 @@ import com.geeksville.android.isGooglePlayAvailable
|
|||
import com.geeksville.concurrent.handledLaunch
|
||||
import com.geeksville.mesh.MainActivity
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.android.bluetoothManager
|
||||
import com.geeksville.mesh.android.usbManager
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.service.BluetoothInterface
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
|
|
@ -137,11 +139,8 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
|||
debug("BTScanModel cleared")
|
||||
}
|
||||
|
||||
/// Note: may be null on platforms without a bluetooth driver (ie. the emulator)
|
||||
val bluetoothAdapter =
|
||||
(context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter
|
||||
|
||||
private val usbManager = context.getSystemService(Context.USB_SERVICE) as UsbManager
|
||||
val bluetoothAdapter = context.bluetoothManager?.adapter
|
||||
private val usbManager get() = context.usbManager
|
||||
|
||||
var selectedAddress: String? = null
|
||||
val errorText = object : MutableLiveData<String?>(null) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue