public class AlphabeticHeaders extends HeadersModule<HeadersModule.SimpleHeader>
HeadersModule implementation which may be used to provide set of alphabetic headers for
data set of a specific adapter to which is this module attached.
Alphabetic headers are generated whenever one of fromAlphabeticList(List) and
fromAlphabeticCursor(Cursor) methods is called.
Note, that this module assumes, that the data set to be processed is already ordered alphabetically.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AlphabeticHeaders.AlphabeticItem
Required interface for item of which data set can be processed via
fromAlphabeticList(List)
or fromAlphabeticCursor(Cursor). |
HeadersModule.Header, HeadersModule.SimpleHeaderAdapterModule.ModuleAdapter| Constructor and Description |
|---|
AlphabeticHeaders() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearHeaders()
Clears the current headers data set of this module.
|
<C extends Cursor & AlphabeticHeaders.AlphabeticItem> |
fromAlphabeticCursor(C cursor)
Like
fromAlphabeticList(List) for the given cursor of which content
will be iterated to obtain the item names. |
<Item extends AlphabeticHeaders.AlphabeticItem> |
fromAlphabeticList(List<Item> list)
Processes the given list of alphabetic items.
|
protected void |
onProcessAlphabeticItem(AlphabeticHeaders.AlphabeticItem item,
int position)
Invoked to process the given alphabetic item and to create header item from it.
|
addHeader, bindViewHolder, correctPosition, createView, createViewHolder, getHeader, getHeaders, getHeadersCountBeforePosition, getHeaderStyleAttr, isEmpty, isHeaderAt, removeHeaderAt, setHeaderStyleAttr, sizeassertAttachedToAdapterOrThrow, attachToAdapter, isAdapterNotificationEnabled, notifyAdapter, onAttachedToAdapter, requiresStateSaving, setAdapterNotificationEnabledpublic <C extends Cursor & AlphabeticHeaders.AlphabeticItem> void fromAlphabeticCursor(@NonNull C cursor)
fromAlphabeticList(List) for the given cursor of which content
will be iterated to obtain the item names.C - Type of the alphabetic cursor.cursor - The desired cursor with content for alphabetic items to process.public <Item extends AlphabeticHeaders.AlphabeticItem> void fromAlphabeticList(@NonNull List<Item> list)
Also, the adapter, to which is this module attached, will be notified about occurred data set
change via AdapterModule.notifyAdapter().
Note, that items in the given list should be already alphabetically sorted, otherwise the resulting headers data set may contain duplicates.
Item - Type of the alphabetic items in the list.list - The desired list of alphabetic items to process.fromAlphabeticCursor(Cursor)public void clearHeaders()
HeadersModuleclearHeaders in class HeadersModule<HeadersModule.SimpleHeader>protected final void onProcessAlphabeticItem(@NonNull AlphabeticHeaders.AlphabeticItem item, int position)
item - An alphabetic item to process.position - The position at which should be header presented within the headers data set.