設定ファイルの更新頻度を下げる

This commit is contained in:
tateisu 2020-01-31 17:15:41 +09:00
parent 806b74f369
commit 5a2dd5d715
1 changed files with 5 additions and 6 deletions

View File

@ -502,8 +502,8 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
}
SettingType.CheckBox -> {
val bp = item.pref.cast<BooleanPref>() ?: error("$name has no boolean pref")
if(bp(pref) == bp.defVal) pref.edit().remove(bp).apply()
val bp :BooleanPref = item.pref.cast() ?: error("$name has no boolean pref")
if(pref.contains(bp.key) && bp(pref) == bp.defVal) pref.edit().remove(bp).apply()
checkBox.vg(false) // skip animation
checkBox.text = name
checkBox.isEnabled = item.enabled
@ -512,14 +512,13 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
}
SettingType.Switch -> {
val bp = item.pref.cast<BooleanPref>() ?: error("$name has no boolean pref")
if(bp(pref) == bp.defVal) pref.edit().remove(bp).apply()
val bp :BooleanPref = item.pref.cast() ?: error("$name has no boolean pref")
if(pref.contains(bp.key) && bp(pref) == bp.defVal) pref.edit().remove(bp).apply()
showCaption(name)
swSwitch.vg(false) // skip animation
App1.setSwitchColor1(activity, pref, swSwitch)
swSwitch.isEnabled = item.enabled
swSwitch.isChecked = bp(pref)
App1.setSwitchColor1(activity, pref, swSwitch)
swSwitch.vg(true)
}