T - A type of the items within a list that can this implementation of preference hold and
manage its storing/retrieving.public final class ListPreference<T> extends SharedPreference<List<T>>
SharedPreference implementation that may be used to manage (store/retrieve) a List
preference value within SharedPreferences.ArrayPreferenceSharedPreference.PreferenceChangeCallback<PreferenceType>| Constructor and Description |
|---|
ListPreference(int keyResId,
Class<T> componentType,
List<T> defValue)
Creates a new instance of universum.studios.android.preference.ListPreference.
|
ListPreference(String key,
Class<T> componentType,
List<T> defValue)
Creates a new instance of universum.studios.android.preference.ListPreference.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
getFromPreferences(android.content.SharedPreferences preferences,
String key,
List<T> defValue)
Returns a
List mapped in the given shared preferences under the specified
key. |
protected List<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 <T> boolean |
putIntoPreferences(android.content.SharedPreferences preferences,
String key,
List<T> list,
Class<T> componentType)
Saves the given list into the given shared preferences.
|
attachKey, createOnChangeListener, getDefaultValue, getKey, getKeyRes, getValue, retrieve, save, updateValuepublic ListPreference(String key, Class<T> componentType, List<T> defValue)
componentType - Class of components that will be presented within a list managed by the
new list preference.SharedPreference.SharedPreference(String, Object)public ListPreference(int keyResId,
Class<T> componentType,
List<T> defValue)
componentType - Class of components that will be presented within a list managed by the
new list preference.SharedPreference.SharedPreference(int, Object)protected boolean onPutIntoPreferences(android.content.SharedPreferences preferences)
SharedPreferenceonPutIntoPreferences in class SharedPreference<List<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, List, Class)public static <T> boolean putIntoPreferences(android.content.SharedPreferences preferences,
String key,
List<T> list,
Class<T> componentType)
T - Type of items which are presented within the given list.preferences - The instance of shared preferences into which will be the given list saved.key - The key under which will be the saved list mapped in the shared preferences.list - List to save into preferences.componentType - Class of components presented within the given list.True if saving has succeeded, false otherwise.protected List<T> onGetFromPreferences(android.content.SharedPreferences preferences)
SharedPreferenceonGetFromPreferences in class SharedPreference<List<T>>preferences - The instance of shared preferences into which was the value of this preference
before saved.getFromPreferences(SharedPreferences, String, List)public static <T> List<T> getFromPreferences(android.content.SharedPreferences preferences, String key, List<T> defValue)
List mapped in the given shared preferences under the specified
key.T - Type of an items which should be presented within the obtained list.preferences - The instance of shared preferences into which was the requested list
before saved.key - The key under which is the saved list mapped in the shared preferences.defValue - Default list 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/a list.IllegalArgumentException - If type of the requested list is not supported by the
Preferences library.IllegalStateException - If the requested list was not stored by the Preferences library.