Properly set default value for switch pref

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
Pranav Vashi
2022-11-26 22:05:47 +05:30
committed by Joey
parent ec0db0163e
commit 981cdd2b8e

View File

@@ -66,10 +66,8 @@ public abstract class SelfRemovingSwitchPreference extends SwitchPreferenceCompa
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
final boolean checked;
if (!restorePersistedValue || !isPersisted()) {
if (defaultValue == null) {
return;
}
checked = getBoolean(getKey(), (boolean) defaultValue);
boolean defValue = defaultValue == null ? false : (boolean) defaultValue;
checked = getBoolean(getKey(), defValue);
if (shouldPersist()) {
persistBoolean(checked);
}