|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.solovyev.android.prefs.AbstractPreference<T>
T - type of preferencepublic abstract class AbstractPreference<T>
Base class for Preference implementation. Contains preference key and default value
| Constructor Summary | |
|---|---|
protected |
AbstractPreference(String key,
T defaultValue)
|
| Method Summary | |
|---|---|
T |
getDefaultValue()
|
String |
getKey()
Method returns key of preference used in android: the key with which current preference is saved in persistence |
protected abstract T |
getPersistedValue(android.content.SharedPreferences preferences)
|
T |
getPreference(android.content.SharedPreferences preferences)
NOTE: this method can throw runtime exceptions if errors occurred while extracting preferences values |
T |
getPreferenceNoError(android.content.SharedPreferences preferences)
NOTE: this method SHOULD not throw any runtime exceptions BUT return default value if any error occurred |
boolean |
isSameKey(String key)
|
boolean |
isSet(android.content.SharedPreferences preferences)
|
void |
putDefault(android.content.SharedPreferences preferences)
Method saves default value in preferences container. |
protected abstract void |
putPersistedValue(android.content.SharedPreferences.Editor editor,
T value)
Method saved preference to preferences container editor |
void |
putPreference(android.content.SharedPreferences preferences,
T value)
Method puts (saves) preference represented by value in preferences container |
boolean |
tryPutDefault(android.content.SharedPreferences preferences)
Method applies default value to preference only if explicit value is not set |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractPreference(@Nonnull
String key,
@Nullable
T defaultValue)
| Method Detail |
|---|
@Nonnull public String getKey()
Preference
getKey in interface Preference<T>public T getDefaultValue()
getDefaultValue in interface Preference<T>
public final T getPreference(@Nonnull
android.content.SharedPreferences preferences)
Preference
getPreference in interface Preference<T>preferences - application preferences
public T getPreferenceNoError(@Nonnull
android.content.SharedPreferences preferences)
Preference
getPreferenceNoError in interface Preference<T>preferences - application preferences
public void putDefault(@Nonnull
android.content.SharedPreferences preferences)
Preferencepreferences container.
Should behave exactly as p.putPreference(preferences, p.getDefaultValue())
putDefault in interface Preference<T>preferences - preferences container
public void putPreference(@Nonnull
android.content.SharedPreferences preferences,
@Nullable
T value)
Preferencevalue in preferences container
putPreference in interface Preference<T>preferences - preferences containervalue - value to be saved
public boolean isSet(@Nonnull
android.content.SharedPreferences preferences)
isSet in interface Preference<T>preferences - preferences container
public final boolean tryPutDefault(@Nonnull
android.content.SharedPreferences preferences)
Preference
tryPutDefault in interface Preference<T>preferences - preferences container
public final boolean isSameKey(@Nonnull
String key)
isSameKey in interface Preference<T>key - preference key
@Nullable
protected abstract T getPersistedValue(@Nonnull
android.content.SharedPreferences preferences)
preferences - preferences container
getKey() method
protected abstract void putPersistedValue(@Nonnull
android.content.SharedPreferences.Editor editor,
@Nonnull
T value)
editor - editor in which value must be savedvalue - value to be saved
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||