mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-24 09:54:20 +01:00
Revert "Clear repository when enter a screen"
This reverts commit 9354dd0b44.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
package no.nordicsemi.android.cgms.repository
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
@@ -105,15 +106,12 @@ class CGMRepository @Inject constructor(
|
||||
_data.value = _data.value.copy(deviceName = device.name)
|
||||
}
|
||||
|
||||
fun clearRecords() {
|
||||
fun clear() {
|
||||
_data.value = _data.value.copy(records = emptyList())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
_data.value = CGMServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = CGMServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ internal class CGMService : NotificationService() {
|
||||
}
|
||||
|
||||
private fun clear() {
|
||||
repository.clearRecords()
|
||||
repository.clear()
|
||||
}
|
||||
|
||||
private suspend fun requestLastRecord() {
|
||||
|
||||
@@ -67,8 +67,6 @@ internal class CGMViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -115,6 +113,6 @@ internal class CGMViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import no.nordicsemi.android.common.core.simpleSharedFlow
|
||||
import no.nordicsemi.android.common.logger.NordicBlekLogger
|
||||
import no.nordicsemi.android.csc.data.CSCServiceData
|
||||
import no.nordicsemi.android.csc.data.SpeedUnit
|
||||
import no.nordicsemi.android.kotlin.ble.core.ServerDevice
|
||||
@@ -104,12 +105,8 @@ class CSCRepository @Inject constructor(
|
||||
_loggerEvent.tryEmit(OpenLoggerEvent())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
_data.value = CSCServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_wheelSize.value = WheelSizes.default
|
||||
_data.value = CSCServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,6 @@ internal class CSCViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -117,7 +115,7 @@ internal class CSCViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
navigationManager.navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,11 +101,8 @@ class HRSRepository @Inject constructor(
|
||||
_loggerEvent.tryEmit(OpenLoggerEvent())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
_data.value = HRSServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = HRSServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,6 @@ internal class HRSViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -114,7 +112,7 @@ internal class HRSViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
navigationManager.navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,12 +98,9 @@ class HTSRepository @Inject constructor(
|
||||
_loggerEvent.tryEmit(OpenLoggerEvent())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
logger = null
|
||||
_data.value = HTSServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = HTSServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,6 @@ internal class HTSViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -110,7 +108,7 @@ internal class HTSViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
navigationManager.navigateUp()
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,9 @@ class PRXRepository @Inject internal constructor(
|
||||
_loggerEvent.tryEmit(OpenLoggerEvent())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
_data.value = PRXServiceData()
|
||||
_remoteAlarmLevel.tryEmit(AlarmLevel.NONE)
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = PRXServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ internal class PRXService : NotificationService() {
|
||||
private fun stopIfDisconnected(connectionState: GattConnectionState, connectionStatus: BleGattConnectionStatus) {
|
||||
if (connectionState == GattConnectionState.STATE_DISCONNECTED && !connectionStatus.isLinkLoss) {
|
||||
server.stopServer()
|
||||
repository.stop()
|
||||
repository.release()
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,6 @@ internal class PRXViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -125,7 +123,7 @@ internal class PRXViewModel @Inject constructor(
|
||||
private fun disconnect() {
|
||||
alarmHandler.pauseAlarm()
|
||||
navigationManager.navigateUp()
|
||||
repository.stop()
|
||||
repository.release()
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
||||
@@ -93,12 +93,9 @@ class RSCSRepository @Inject constructor(
|
||||
_loggerEvent.tryEmit(OpenLoggerEvent())
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
logger = null
|
||||
_data.value = RSCSServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = RSCSServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,6 @@ internal class RSCSViewModel @Inject constructor(
|
||||
val state = repository.data
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -108,7 +106,7 @@ internal class RSCSViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
navigationManager.navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,11 +124,8 @@ class UARTRepository @Inject internal constructor(
|
||||
configurationDataSource.saveConfigurationName(name)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
fun release() {
|
||||
_data.value = UARTServiceData()
|
||||
_stopEvent.tryEmit(DisconnectAndStopEvent())
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
_data.value = UARTServiceData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,6 @@ internal class UARTViewModel @Inject constructor(
|
||||
val state = _state.asStateFlow()
|
||||
|
||||
init {
|
||||
repository.clear()
|
||||
|
||||
viewModelScope.launch {
|
||||
if (repository.isRunning.firstOrNull() == false) {
|
||||
requestBluetoothDevice()
|
||||
@@ -235,7 +233,7 @@ internal class UARTViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
repository.stop()
|
||||
repository.release()
|
||||
navigationManager.navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user