RecycleItemProviderpublic abstract class BaseItemProvider extends Object
BaseItemProvider object to associate an ComponentProvider item with the fundamental
data of the component.
A provider provides access to data items and creates a Component for each item in the
dataset. When the content in a dataset changes, the subscriber is notified to respond to the changes, and the
updated content is refreshed on the screen synchronously.
| 构造器 | 说明 |
|---|---|
BaseItemProvider() |
The constructor
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addDataSubscriber(DataSetSubscriber subscriber) |
Adds a dataset subscriber.
|
abstract Component |
getComponent(int position,
Component convertComponent,
ComponentContainer parent) |
Obtains a component that displays data in a specified position in the data set.
|
int |
getComponentTypeCount() |
Obtains the number of component types of all items in a dataset.
|
abstract int |
getCount() |
Obtains the total number of data items in a provider.
|
TextFilter |
getFilter() |
Obtains the text filter.
|
abstract Object |
getItem(int position) |
Obtains the data item in a specified position in the data set.
|
int |
getItemComponentType(int position) |
Obtains the component type of a data item in a dataset based on the position.
|
abstract long |
getItemId(int position) |
Obtains the row ID of a data item in a specified position in the data set.
|
void |
notifyDataChanged() |
Refreshes the component of an updated data item.
|
void |
notifyDataInvalidated() |
Called when a provider data is invalid.
|
void |
notifyDataSetItemChanged(int position) |
Refreshes the component of an updated data item.
|
void |
notifyDataSetItemInserted(int position) |
Refreshes the component for which a specified data item has changed.
|
void |
notifyDataSetItemRangeChanged(int startPos,
int countItems) |
Refreshes the component for which a specified number of data items starting from
the given position have changed.
|
void |
notifyDataSetItemRangeInserted(int startPos,
int countItems) |
Refreshes the component for which a specified number of data items starting from
the given position have been inserted.
|
void |
notifyDataSetItemRangeRemoved(int startPos,
int countItems) |
Refreshes the component from which a specified number of data items starting from
the given position have been removed.
|
void |
notifyDataSetItemRemoved(int position) |
Refreshes the component from which a specified data item has been removed.
|
void |
onItemMoved(int from,
int to) |
Called internally when a component item should be moved to other position into dataset.
|
void |
removeDataSubscriber(DataSetSubscriber subscriber) |
Removes a dataset subscriber.
|
void |
setFilter(TextFilter filter) |
Sets the text filter.
|
public abstract int getCount()
public abstract Object getItem(int position)
position - Indicates the position of the data item in the data set.public abstract long getItemId(int position)
position - Indicates the position of the row ID of the data item.public abstract Component getComponent(int position, Component convertComponent, ComponentContainer parent)
position - Indicates the position of the component in the data set.convertComponent - Indicates the previous component to be reused.
This parameter can be null if there is no such component.parent - Indicates the parent component matching the component to be obtained.public int getItemComponentType(int position)
Each time a component layout is added to the dataset, a component type must be added to match the component
layout. The
component type value ranges from 0 to the result of getComponentTypeCount() minus 1. For example, a
component layout
containing one key matches the component type value 0, and a component layout containing two keys
matches the
component type value 1.
position - Indicates the position of the component item in the provider dataset.public int getComponentTypeCount()
1.public void notifyDataChanged()
Each registered subscriber is notified using the DataSetPublisher#notifyChanged() method.
public void notifyDataInvalidated()
Each registered subscriber is notified using the DataSetPublisher#informInvalidated() method.
public void notifyDataSetItemChanged(int position)
Each registered subscriber is notified using the DataSetPublisher#notifyItemChanged(int) method.
position - Indicates the position of the item in the data set.public void notifyDataSetItemInserted(int position)
To notify data change subscribers, call DataSetPublisher#notifyItemChanged(int).
position - Indicates the position of the changed data item in the data set.public void notifyDataSetItemRemoved(int position)
To notify data change subscribers, call DataSetPublisher#notifyItemRemoved(int).
position - Indicates the position of the removed data item in the data set.public void notifyDataSetItemRangeChanged(int startPos,
int countItems)
To notify data change subscribers, call DataSetPublisher#notifyItemRangeChanged(int, int).
startPos - Indicates the position of the first data item that has changed.countItems - Indicates the number of data items that have changed.public void notifyDataSetItemRangeInserted(int startPos,
int countItems)
To notify data change subscribers, call DataSetPublisher#notifyItemRangeInserted(int, int).
startPos - Indicates the position of the first data item that has been inserted.countItems - Indicates the number of data items that have been inserted.public void notifyDataSetItemRangeRemoved(int startPos,
int countItems)
To notify data change subscribers, call DataSetPublisher#notifyItemRangeRemoved(int, int).
startPos - Indicates the position of the first data item that has been removed.countItems - Indicates the number of data items that have been removed.public final void addDataSubscriber(DataSetSubscriber subscriber)
subscriber - Indicates the subscriber to notify when the content in the dataset changes.public final void removeDataSubscriber(DataSetSubscriber subscriber)
subscriber - Indicates the subscriber to notify when the content in the dataset changes.public void setFilter(TextFilter filter)
filter - Indicates the text filter.TextFilterpublic TextFilter getFilter()
TextFilterpublic void onItemMoved(int from,
int to)