mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-21 00:14:24 +01:00
Add HRS service
This commit is contained in:
@@ -2,6 +2,9 @@ package no.nordicsemi.android.utils
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.navigation.NavController
|
||||
|
||||
val <T> T.exhaustive
|
||||
get() = this
|
||||
@@ -14,3 +17,17 @@ fun Context.isServiceRunning(serviceClassName: String): Boolean {
|
||||
val services = activityManager.getRunningServices(Integer.MAX_VALUE)
|
||||
return services.find { it.service.className == serviceClassName } != null
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> NavController.consumeResult(value: String): T? {
|
||||
|
||||
val secondScreenResult = currentBackStackEntry
|
||||
?.savedStateHandle
|
||||
?.getLiveData<T>(value)?.observeAsState()
|
||||
|
||||
return secondScreenResult?.value?.also {
|
||||
currentBackStackEntry
|
||||
?.savedStateHandle
|
||||
?.set(value, null)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user