T - A type of the items within an array that can this implementation of preference hold and
manage its storing/retrieving.public final class ArrayPreference<T> extends SharedPreference<T>
SharedPreference implementation that may be used to manage (store/retrieve) an array
preference value within SharedPreferences.ListPreferenceSharedPreference.PreferenceChangeCallback<PreferenceType>| Constructor and Description |
|---|
ArrayPreference(int keyResId,
T defValue)
Creates a new instance of universum.studios.android.preference.ArrayPreference.
|
ArrayPreference(String key,
T defValue)
Creates a new instance of universum.studios.android.preference.ArrayPreference.
|
| Modifier and Type | Method and Description |
|---|---|
static <A> A |
getFromPreferences(android.content.SharedPreferences preferences,
String key,
Object defValue)
Returns an array mapped in the given shared preferences under the specified
key.
|
protected T |
onGetFromPreferences(android.content.SharedPreferences preferences)
Invoked to retrieve the actual value of this preference from the given shared preferences.
|
protected boolean |
onPutIntoPreferences(android.content.SharedPreferences preferences)
Invoked to save the actual value into the given shared preferences.
|
static boolean |
putIntoPreferences(android.content.SharedPreferences preferences,
String key,
Object array)
Saves the given array into the given shared preferences.
|
attachKey, createOnChangeListener, getDefaultValue, getKey, getKeyRes, getValue, retrieve, save, updateValuepublic ArrayPreference(String key, T defValue)
IllegalArgumentException - If the given defValue is not actually an array.SharedPreference.SharedPreference(String, Object)public ArrayPreference(int keyResId,
T defValue)
IllegalArgumentException - If the given defValue is not actually an array.SharedPreference.SharedPreference(int, Object)protected boolean onPutIntoPreferences(android.content.SharedPreferences preferences)
SharedPreferenceonPutIntoPreferences in class SharedPreference<T>preferences - The instance of shared preferences into which should be the current value of
this preference saved.True if saving operation succeed, false otherwise.putIntoPreferences(SharedPreferences, String, Object)public static boolean putIntoPreferences(android.content.SharedPreferences preferences,
String key,
Object array)
preferences - The instance of shared preferences into which will be the given array saved.key - The key under which will be the saved array mapped in the shared preferences.array - Array to save into preferences.True if saving succeeded, false otherwise.IllegalArgumentException - If the given array is not actually an array.protected T onGetFromPreferences(android.content.SharedPreferences preferences)
SharedPreferenceonGetFromPreferences in class SharedPreference<T>preferences - The instance of shared preferences into which was the value of this preference
before saved.getFromPreferences(SharedPreferences, String, Object)public static <A> A getFromPreferences(android.content.SharedPreferences preferences,
String key,
Object defValue)
A - The type of an array to obtain.preferences - The instance of shared preferences into which was the requested array before
saved.key - The key under which is the saved list mapped in the shared preferences.defValue - Default array to return if there is no mapping for the specified key
yet.ClassCastException - If value stored under the specified key does not represents
an array.IllegalArgumentException - If type of the requested array is not supported by the
Preferences library.IllegalStateException - If the requested array was not stored by the Preferences library.