mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-04-13 18:01:57 +02:00
Use asFlow
from BaseConfig
This commit is contained in:
parent
1e1dacf7be
commit
ee7780f9e7
@ -2,11 +2,7 @@ package com.simplemobiletools.flashlight.helpers
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import com.simplemobiletools.commons.extensions.sharedPreferencesCallback
|
|
||||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
|
||||||
import kotlin.reflect.KProperty0
|
|
||||||
|
|
||||||
class Config(context: Context) : BaseConfig(context) {
|
class Config(context: Context) : BaseConfig(context) {
|
||||||
companion object {
|
companion object {
|
||||||
@ -66,6 +62,4 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var sleepInTS: Long
|
var sleepInTS: Long
|
||||||
get() = prefs.getLong(SLEEP_IN_TS, 0)
|
get() = prefs.getLong(SLEEP_IN_TS, 0)
|
||||||
set(sleepInTS) = prefs.edit().putLong(SLEEP_IN_TS, sleepInTS).apply()
|
set(sleepInTS) = prefs.edit().putLong(SLEEP_IN_TS, sleepInTS).apply()
|
||||||
|
|
||||||
private fun <T> KProperty0<T>.asFlow(): Flow<T> = prefs.run { sharedPreferencesCallback { this@asFlow.get() } }.filterNotNull()
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ androidx-lifecycle = "2.7.0-alpha02"
|
|||||||
#EventBus
|
#EventBus
|
||||||
eventbusVersion = "3.3.1"
|
eventbusVersion = "3.3.1"
|
||||||
#Simple tools
|
#Simple tools
|
||||||
simple-commons = "f87e960171"
|
simple-commons = "13f995cb51"
|
||||||
#Compose
|
#Compose
|
||||||
composeActivity = "1.8.0-rc01"
|
composeActivity = "1.8.0-rc01"
|
||||||
compose = "1.6.0-alpha06"
|
compose = "1.6.0-alpha06"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user