Chargeprice: store charging range (#86)

This commit is contained in:
johan12345
2021-04-28 22:47:42 +02:00
parent 369b7d9410
commit ee0fd4e8d8
2 changed files with 15 additions and 1 deletions

View File

@@ -128,4 +128,15 @@ class PreferenceDataSource(val context: Context) {
set(value) {
sp.edit().putString("chargeprice_currency", value).apply()
}
var chargepriceBatteryRange: List<Float>
get() = listOf(
sp.getFloat("chargeprice_battery_range_min", 20f),
sp.getFloat("chargeprice_battery_range_max", 80f),
)
set(value) {
sp.edit().putFloat("chargeprice_battery_range_min", value[0])
.putFloat("chargeprice_battery_range_max", value[1])
.apply()
}
}

View File

@@ -67,7 +67,10 @@ class ChargepriceViewModel(application: Application, chargepriceApiKey: String)
val batteryRange: MutableLiveData<List<Float>> by lazy {
MutableLiveData<List<Float>>().apply {
value = listOf(20f, 80f)
value = prefs.chargepriceBatteryRange
observeForever {
prefs.chargepriceBatteryRange = it
}
}
}
val batteryRangeSliderDragging: MutableLiveData<Boolean> by lazy {