@Test public void testAddListener() throws Exception { final Boolean[] booleans = { Boolean.FALSE }; mNullPref.addListener(new OnPreferenceChangeListener<Boolean>() { @Override public void onPreferenceChange(final Preference<Boolean> preference) { booleans[0] = preference.get(); } }); assertFalse(booleans[0]); mNullPref.set(Boolean.TRUE); assertTrue(booleans[0]); mNullPref.set(Boolean.FALSE, true); assertFalse(booleans[0]); mNullPref.set((Boolean) null, true); assertNull(booleans[0]); }
@Nullable @Override public Boolean get() { if (contains()) { return readSharedPreferences().getBoolean(getKey(), false); } else { return getDefaultValue(); } }
BooleanPreference extends Preference<Boolean> { @Nullable @Override public Boolean get() { if (contains()) { return readSharedPreferences().getBoolean(getKey(), false); } else { return getDefaultValue(); } } }
BooleanPreference extends Preference<Boolean> { @Nullable @Override public Boolean get() { if (contains()) { return readSharedPreferences().getBoolean(getKey(), false); } else { return getDefaultValue(); } } BooleanPreference(final String name, final String key,
            @Nullable final Boolean defaultValue); }
BooleanPreference extends Preference<Boolean> { @Nullable @Override public Boolean get() { if (contains()) { return readSharedPreferences().getBoolean(getKey(), false); } else { return getDefaultValue(); } } BooleanPreference(final String name, final String key,
            @Nullable final Boolean defaultValue); @Override boolean exists(); @Nullable @Override Boolean get(); void toggle(); }
BooleanPreference extends Preference<Boolean> { @Nullable @Override public Boolean get() { if (contains()) { return readSharedPreferences().getBoolean(getKey(), false); } else { return getDefaultValue(); } } BooleanPreference(final String name, final String key,
            @Nullable final Boolean defaultValue); @Override boolean exists(); @Nullable @Override Boolean get(); void toggle();  }