mirror of
https://github.com/markusfisch/BinaryEye.git
synced 2024-09-19 19:42:18 +02:00
Set BT results from return values
So the result variables can be immutable. And use simpler terms for their names to make this easier to read and understand.
This commit is contained in:
parent
09f3c8f193
commit
79b3fddcf8
@ -17,19 +17,18 @@ fun Scan.sendBluetoothAsync(
|
||||
callback: (Boolean, Boolean) -> Unit
|
||||
) {
|
||||
CoroutineScope(Dispatchers.IO).launch(Dispatchers.IO) {
|
||||
var connectResponse = true
|
||||
var sendResponse = false
|
||||
|
||||
if (!isConnected) {
|
||||
connectResponse = connect(host)
|
||||
val connected = if (isConnected) {
|
||||
true
|
||||
} else {
|
||||
connect(host)
|
||||
}
|
||||
|
||||
if (connectResponse) {
|
||||
sendResponse = send(content)
|
||||
val sent = if (connected) {
|
||||
send(content)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
callback(connectResponse, sendResponse)
|
||||
callback(connected, sent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user