public class SettingHeadersAdapter
extends <any>
SimpleAdapter implementation used to provide data set of Items for adapter
view that displays a list of setting preferences in the context of SettingsBaseActivity.
This adapter uses the following view types to provide views for its data set of items:
VIEW_TYPE_CATEGORY - view for the category header that has no fragment nor intent associated,VIEW_TYPE_CATEGORY_DIVIDER - view for divider between category headers,VIEW_TYPE_HEADER - view for the selectable header.
Data set of items with associated headers may be supplied via SettingHeadersAdapter(Context, List)
constructor or changed via changeHeaders(List). The current data set of transformed items
may be obtained via #getItems(). A specific item at a desired position may be obtained
via #getItem(int) and its associated header via getItem(int).getHeader().
| Modifier and Type | Class and Description |
|---|---|
static class |
SettingHeadersAdapter.CategoryDividerHolder
A
ViewHolder implementation for category divider view of SettingHeadersAdapter. |
static class |
SettingHeadersAdapter.CategoryHolder
A
ViewHolder implementation for category item view of SettingHeadersAdapter. |
static class |
SettingHeadersAdapter.HeaderHolder
A
ViewHolder implementation for header item view of SettingHeadersAdapter. |
static class |
SettingHeadersAdapter.Item
Item class represents a data model for
SettingHeadersAdapter. |
| Modifier and Type | Field and Description |
|---|---|
static int |
VIEW_TYPE_CATEGORY
View type for the category item.
|
static int |
VIEW_TYPE_CATEGORY_DIVIDER
View type for the category divider.
|
static int |
VIEW_TYPE_HEADER
View type for the header item.
|
| Constructor and Description |
|---|
SettingHeadersAdapter(android.content.Context context)
Creates a new instance of SettingHeadersAdapter with empty data set.
|
SettingHeadersAdapter(android.content.Context context,
List<android.preference.PreferenceActivity.Header> headers)
Creates a new instance of SettingHeadersAdapter with the initial data set of headers.
|
SettingHeadersAdapter(android.content.Context context,
android.preference.PreferenceActivity.Header[] headers)
Same as
SettingHeadersAdapter(Context, List) for array of headers. |
| Modifier and Type | Method and Description |
|---|---|
void |
changeHeaders(List<android.preference.PreferenceActivity.Header> headers)
Same as
swapHeaders(List) where the old headers are ignored. |
void |
changeItems(List<SettingHeadersAdapter.Item> items) |
int |
getItemViewType(int position) |
int |
getViewTypeCount() |
boolean |
hasStableIds() |
boolean |
isCategoryAt(int position)
Checks whether item at the specified position is a category.
|
boolean |
isCategoryDividerAt(int position)
Checks whether item at the specified position is a category divider.
|
boolean |
isEnabled(int position) |
boolean |
isHeaderAt(int position)
Checks whether item at the specified position is a header.
|
protected void |
onBindViewHolder(ViewHolder viewHolder,
int position) |
protected android.view.View |
onCreateView(android.view.ViewGroup parent,
int position) |
protected ViewHolder |
onCreateViewHolder(android.view.View itemView,
int position) |
void |
setUseVectorIcons(boolean useVectorIcons)
Sets a boolean flag indicating whether this adapter should treat icon parameter specified
via
PreferenceActivity.Header#iconRes as resource of vector drawable or as resource
of standard drawable. |
List<android.preference.PreferenceActivity.Header> |
swapHeaders(List<android.preference.PreferenceActivity.Header> headers)
Swaps the current data set of this adapter for the given headers.
|
List<SettingHeadersAdapter.Item> |
swapItems(List<SettingHeadersAdapter.Item> items) |
public static final int VIEW_TYPE_CATEGORY
public static final int VIEW_TYPE_CATEGORY_DIVIDER
public static final int VIEW_TYPE_HEADER
This is only view type that is by default enabled by this adapter.
isEnabled(int),
Constant Field Valuespublic SettingHeadersAdapter(android.content.Context context)
SimpleAdapter#SimpleAdapter(Context),
SettingHeadersAdapter(Context, List)public SettingHeadersAdapter(android.content.Context context,
android.preference.PreferenceActivity.Header[] headers)
SettingHeadersAdapter(Context, List) for array of headers.public SettingHeadersAdapter(android.content.Context context,
List<android.preference.PreferenceActivity.Header> headers)
context - Context in which will be the new adapter used.headers - Initial data set of headers.changeHeaders(List),
#getItems()public void setUseVectorIcons(boolean useVectorIcons)
PreferenceActivity.Header#iconRes as resource of vector drawable or as resource
of standard drawable.useVectorIcons - True to apply icon resources of items as vector drawables,
false as standard drawables.public final void changeItems(List<SettingHeadersAdapter.Item> items)
UnsupportedOperationException - Use changeHeaders(List) instead.public void changeHeaders(List<android.preference.PreferenceActivity.Header> headers)
swapHeaders(List) where the old headers are ignored.public List<android.preference.PreferenceActivity.Header> swapHeaders(List<android.preference.PreferenceActivity.Header> headers)
Note, that as this adapter uses multiple view types to present its data set, the specified
headers are transformed into data set of Items. The items data set may be obtained
via #getItems() or a specific item at a desired position via #getItem(int).
Header associated with an item at a specific position may
be obtained via getItem(int).getHeader().
headers - The headers for which to create a new data set. May be null to clear
the current data set.changeHeaders(List)public final List<SettingHeadersAdapter.Item> swapItems(List<SettingHeadersAdapter.Item> items)
UnsupportedOperationException - Use swapHeaders(List) instead.public boolean hasStableIds()
public int getViewTypeCount()
public int getItemViewType(int position)
public boolean isEnabled(int position)
True if item at the position is header, false otherwise.isHeaderAt(int)public boolean isHeaderAt(int position)
position - The position of item to check.True if item at the position is header, false otherwise.public boolean isCategoryAt(int position)
position - The position of item to check.True if item at the position is category, false otherwise.isHeaderAt(int),
isCategoryDividerAt(int)public boolean isCategoryDividerAt(int position)
position - The position of item to check.True if item at the position is category divider, false otherwise.isCategoryAt(int)protected android.view.View onCreateView(android.view.ViewGroup parent,
int position)
protected ViewHolder onCreateViewHolder(android.view.View itemView,
int position)
protected void onBindViewHolder(ViewHolder viewHolder,
int position)