Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 374be235 authored by Danny Baumann's avatar Danny Baumann Committed by Matt Garnes
Browse files

Factor out preference-in-storage check to overridable method.

Change-Id: I2fff3192802f8a180330fda66388eda394334a5a
parent 2f08c6e5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1365,10 +1365,18 @@ public class Preference implements Comparable<Preference> {
        mDefaultValue = defaultValue;
    }
    
    /**
     * Returns whether the preference can be found in persistent storage
     * @hide
     */
    protected boolean isPersisted() {
        return getSharedPreferences().contains(mKey);
    }

    private void dispatchSetInitialValue() {
        // By now, we know if we are persistent.
        final boolean shouldPersist = shouldPersist();
        if (!shouldPersist || !getSharedPreferences().contains(mKey)) {
        if (!shouldPersist || !isPersisted()) {
            if (mDefaultValue != null) {
                onSetInitialValue(false, mDefaultValue);
            }