Chargeprice: prevent same value for start and end state of charge

This commit is contained in:
Johan von Forstner
2021-07-31 20:05:41 +02:00
parent 748212189f
commit 20c4274c55

View File

@@ -92,7 +92,14 @@ class ChargepriceViewModel(application: Application, chargepriceApiKey: String)
MutableLiveData<List<Float>>().apply {
value = prefs.chargepriceBatteryRange
observeForever {
prefs.chargepriceBatteryRange = it
if (it[0] == it[1]) {
value = if (it[0] < 1.0) {
listOf(it[0], it[1] + 1)
} else {
listOf(it[0] - 1, it[1])
}
}
prefs.chargepriceBatteryRange = value!!
}
}
}