Commit 27f0e156 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald

Status: more lazyness

parent 6cf77b06
......@@ -94,19 +94,19 @@ data class Status(
}
private fun batteryString() = appContext.getString(if (batteryOptimized) R.string.app_battery_optimizer_on else R.string.app_battery_optimizer_off)
private val batteryString by lazy { appContext.getString(if (batteryOptimized) R.string.app_battery_optimizer_on else R.string.app_battery_optimizer_off) }
private fun powerSavingString() = appContext.getString(if (powerSaving) R.string.battery_saver_on else R.string.battery_saver_off)
private val powerSavingString by lazy { appContext.getString(if (powerSaving) R.string.battery_saver_on else R.string.battery_saver_off) }
private fun dataSavingString() = appContext.getString(if (dataSaving()) R.string.data_saver_is_on else R.string.data_saver_is_off)
private val dataSavingString by lazy { appContext.getString(if (dataSaving()) R.string.data_saver_is_on else R.string.data_saver_is_off) }
private fun deviceIdleString() = appContext.getString(if (deviceIsIdle) R.string.device_is_idle else R.string.device_is_not_idle)
private val deviceIdleString by lazy { appContext.getString(if (deviceIsIdle) R.string.device_is_idle else R.string.device_is_not_idle) }
private fun isLocationEnabledString() = appContext.getString(if (isLocationEnabled) R.string.location_is_enabled else R.string.location_is_disabled)
private val isLocationEnabledString by lazy { appContext.getString(if (isLocationEnabled) R.string.location_is_enabled else R.string.location_is_disabled) }
private fun isPowerConnectedString() = appContext.getString(if (isPowerConnected) R.string.is_power_connected else R.string.is_power_disconnected)
private val isPowerConnectedString by lazy { appContext.getString(if (isPowerConnected) R.string.is_power_connected else R.string.is_power_disconnected) }
private fun isChargingString() = appContext.getString(if (isCharging) R.string.is_charging else R.string.is_discharging)
private val isChargingString by lazy { appContext.getString(if (isCharging) R.string.is_charging else R.string.is_discharging) }
companion object {
......@@ -170,33 +170,33 @@ data class Status(
fun logStatusDiffs(whereFrom: String = "", against: Status = prevStatus) {
val isFirst = against.unknown()
if (isFirst || against.batteryOptimized != batteryOptimized) {
batteryString().apply {
batteryString.apply {
if (batteryOptimized)
logError(whereFrom)
else
logStartStop(whereFrom)
}
}
if (isFirst || against.powerSaving != powerSaving) powerSavingString().logStartStop(whereFrom)
if (isFirst || against.deviceIsIdle != deviceIsIdle) deviceIdleString().logStartStop(whereFrom)
// if (isFirst || against.isForeground != isForeground) isForegroundString().logStartStop(whereFrom)
if (isFirst || against.powerSaving != powerSaving) powerSavingString.logStartStop(whereFrom)
if (isFirst || against.deviceIsIdle != deviceIsIdle) deviceIdleString.logStartStop(whereFrom)
// if (isFirst || against.isForeground != isForeground) isForegroundString.logStartStop(whereFrom)
if (isFirst || against.isLocationEnabled != isLocationEnabled)
isLocationEnabledString().apply {
isLocationEnabledString.apply {
if (isLocationEnabled)
logStartStop(whereFrom)
else
logError(whereFrom)
}
if (isFirst || against.dataSaving() != dataSaving()) {
dataSavingString().apply {
dataSavingString.apply {
if (dataSaving())
logError(whereFrom)
else
logStartStop(whereFrom)
}
}
if (isFirst || against.isCharging != isCharging) isChargingString().logStartStop(whereFrom)
if (isFirst || against.isPowerConnected != isPowerConnected) isPowerConnectedString().logStartStop(whereFrom)
if (isFirst || against.isCharging != isCharging) isChargingString.logStartStop(whereFrom)
if (isFirst || against.isPowerConnected != isPowerConnected) isPowerConnectedString.logStartStop(whereFrom)
if (isFirst) {
if (hasNet())
stateString.logStartStop(whereFrom)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment