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