add scan restarting
This commit is contained in:
parent
d3356f4794
commit
7652ccc135
|
|
@ -13,8 +13,8 @@ android {
|
|||
applicationId "llc.arma.ble"
|
||||
minSdk 26
|
||||
targetSdk 33
|
||||
versionCode 14
|
||||
versionName "1.2.14"
|
||||
versionCode 15
|
||||
versionName "1.2.15"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package llc.arma.ble.app.ui.screen.ble
|
|||
import android.util.Log
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -15,29 +17,40 @@ import javax.inject.Inject
|
|||
|
||||
@HiltViewModel
|
||||
class BleListViewModel @Inject constructor(
|
||||
getBleAroundFlow: GetBleAroundFlow,
|
||||
getConnectedBleDevices: GetConnectedBleDevices,
|
||||
exportToXlsx: ExportToXlsx
|
||||
getBleAroundFlow: GetBleAroundFlow
|
||||
) : BaseViewModel<BleListContract.State, BleListContract.Event, BleListContract.Effect>() {
|
||||
|
||||
init {
|
||||
|
||||
getBleAroundFlow().onEach {
|
||||
it.fold(
|
||||
onSuccess = {
|
||||
setState {
|
||||
copy(
|
||||
connectedBleList = emptyList(),
|
||||
bleList = it
|
||||
)
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
viewModelScope.launch {
|
||||
|
||||
}
|
||||
)
|
||||
var job: Job? = null
|
||||
|
||||
}.launchIn(viewModelScope)
|
||||
while (true) {
|
||||
|
||||
job?.cancel()
|
||||
job = getBleAroundFlow().onEach {
|
||||
it.fold(
|
||||
onSuccess = {
|
||||
setState {
|
||||
copy(
|
||||
connectedBleList = emptyList(),
|
||||
bleList = it
|
||||
)
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
delay(6_000)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,9 +284,9 @@ fun Filter(
|
|||
Column() {
|
||||
|
||||
RangeSlider(
|
||||
value = filter.rssi,
|
||||
value = filter.battery,
|
||||
onValueChange = {
|
||||
onEvent(BleListContract.Event.OnRssiRangeChanged(it))
|
||||
onEvent(BleListContract.Event.OnBatteryRangeChanged(it))
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 99,
|
||||
|
|
|
|||
Loading…
Reference in New Issue