public abstract class Provider<E extends ComponentOwner> extends Object
ListComponent data and sets up a relationship between the ComponentOwner
and the ListComponent data.| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static long |
INVALID_ID |
Indicates an invalid component ID in the
ListComponent. |
protected long |
mNativePtr |
Obtains the native object.
|
| 构造器 | 说明 |
|---|---|
Provider() |
A constructor used to create a
Provider instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
long |
getComponentId(int position) |
Obtains the unique identifier of the component at the specified position in the provider.
|
E |
getComponentOwner(long componentOwnerPtr) |
Obtains the
ComponentOwner corresponding to a native pointer. |
Component |
getItemComponent(long componentPtr) |
Obtains the
Component corresponding to a native pointer. |
int |
getItemComponentType(int position) |
Obtains the
componentType of the component at the specified position in the provider. |
abstract int |
getItemNumber() |
Obtains the total number of components in the provider.
|
long |
getNativePtr() |
Obtains the native object.
|
boolean |
hasObserversRegistered() |
Checks whether an observer is registered with the provider.
|
boolean |
hasUniqueIdentifier() |
Checks whether each component in the provider has a unique identifier,
ItemId. |
void |
notifyDataCollectionChanged() |
Notifies any registered observer that all components in the provider have been updated.
|
void |
notifyInsertedAt(int position) |
Notifies any registered observer that a component has been inserted to the specified position in the provider.
|
void |
notifyPositionMoved(int fromPosition,
int toPosition) |
Notifies any registered observer that a component has been moved from one position to another in the provider.
|
void |
notifyRangeInserted(int positionStart,
int itemCount) |
Notifies any registered observer that a given number of components have been inserted to the specified position
in the provider.
|
void |
notifyRangeRemoved(int positionStart,
int itemCount) |
Notifies any registered observer that a given number of components have been removed from the specified position
in the provider.
|
void |
notifyRangeUpdated(int positionStart,
int itemCount) |
Notifies any registered observer that a given number of components have been updated from the specified
position.
|
void |
notifyRangeUpdated(int positionStart,
int itemCount,
Object crab) |
Notifies any registered observer that a given number of components have been updated from the specified
position, with a crab object.
|
void |
notifyRemovedAt(int position) |
Notifies any registered observer that a component has been removed from the specified position in the provider.
|
void |
notifyUpdatedAt(int position) |
Notifies any registered observer that the component at the specified position in the provider has been updated.
|
void |
notifyUpdatedAt(int position,
Object crab) |
Notifies any registered observer that the component at the specified position in the provider has been updated
with a crab object.
|
abstract void |
onBindComponentOwner(E owner,
int position) |
Called when a
ComponentOwner is bound to a component. |
void |
onBindComponentOwner(E owner,
int position,
List<Object> crabs) |
Called when a
ComponentOwner is bound to a component. |
void |
onBoundToListComponent(ListComponent listContainer) |
Called when a
ListComponent is bound to the provider. |
void |
onComponentBoundToWindow(E owner) |
Called when the component corresponding to the
ComponentOwner created by the provider is bound to the
window. |
void |
onComponentOwnerToCachePool(E owner) |
Called when the component corresponding to the
ComponentOwner created by the provider is reclaimed to
the ListComponentPool. |
void |
onComponentUnboundFromWindow(E owner) |
Called when the component corresponding to the
ComponentOwner created by the provider is unbound from
the window. |
abstract E |
onCreateComponentOwner(ListComponent parent,
int componentType) |
Called when a
ComponentOwner is created. |
void |
onUnboundFromListComponent(ListComponent listContainer) |
Called when a
ListComponent is unbound from the provider. |
void |
registerDataObserver(ProviderSubscriber subscriber) |
Registers an observer to observe data changes.
|
void |
setHasUniqueIdentifier(boolean hasUniqueIdentifier) |
Sets whether each component in the data set can be represented by a unique identifier of the type
Long. |
void |
unregisterDataObserver(ProviderSubscriber subscriber) |
Unregisters an observer used to observe data changes.
|
public static final long INVALID_ID
ListComponent.protected long mNativePtr
public abstract E onCreateComponentOwner(ListComponent parent, int componentType)
ComponentOwner is created. You can create a ComponentOwner for the
ListComponent based on the specified componentType.
parent - Indicates the ListComponent to which the new component, after being bound to the provider,
will be added.componentType - Indicates the type of the new component.ComponentOwner.public final E getComponentOwner(long componentOwnerPtr)
ComponentOwner corresponding to a native pointer.componentOwnerPtr - Indicates the native pointer.ComponentOwner.public final Component getItemComponent(long componentPtr)
Component corresponding to a native pointer.componentPtr - Indicates the native pointer.Component.public abstract int getItemNumber()
public abstract void onBindComponentOwner(E owner, int position)
ComponentOwner is bound to a component. You can update the component effect of the
ComponentOwner based on the updates to the component at the specified position.
owner - Indicates the ComponentOwner of the component.position - Indicates the position of the component in the provider's data set.public void onBindComponentOwner(E owner, int position, List<Object> crabs)
ComponentOwner is bound to a component. You can update the component effect of the
ComponentOwner based on the updates to the component at the specified position. Partial update
is supported.
owner - Indicates the ComponentOwner of the component.position - Indicates the position of the component in the provider's data set.crabs - Indicates the crabs. Data from the crabs in Provider#notifyItemChanged(int, Object)
or Provider#notifyItemRangeChanged(int, int, Object) is the basis for providing the partial
update feature.public long getNativePtr()
public void setHasUniqueIdentifier(boolean hasUniqueIdentifier)
Long.hasUniqueIdentifier - Specifies whether each component in the data set has a unique identifier. The value
true means that each component has a unique identifier, and false means the opposite.public final boolean hasUniqueIdentifier()
ItemId.true if each component has a unique identifier; returns false otherwise.public int getItemComponentType(int position)
componentType of the component at the specified position in the provider.position - Indicates the position of the component in the provider.componentType of the component.public long getComponentId(int position)
position - Indicates the position of the component in the provider.public final void notifyDataCollectionChanged()
public final void notifyUpdatedAt(int position)
position - Indicates the position of the component that has been updated.public final void notifyUpdatedAt(int position,
Object crab)
position - Indicates the position of the component that has been updated.crab - Specifies whether it is a partial update. If this parameter is set to null, all the content
in ComponentOwner has been updated. If this parameter is not set to null, a partial
update is performed on the ComponentOwner, which improves the performance when sliding the
ListComponent.public final void notifyRangeUpdated(int positionStart,
int itemCount)
positionStart - Indicates the position of the first component that has been updated.itemCount - Indicates the number of components that has been updated.public final void notifyRangeUpdated(int positionStart,
int itemCount,
Object crab)
positionStart - Indicates the position of the first component that has been updated.itemCount - Indicates the number of components that has been updated.crab - Specifies whether it is a partial update. If this parameter is set to null, all the content
in ComponentOwner has been updated. If this parameter is not set to null, a partial
update is performed on the ComponentOwner, which improves the performance when sliding the
ListComponent.public final void notifyInsertedAt(int position)
position - Indicates the position of the component that has been inserted.public final void notifyRangeInserted(int positionStart,
int itemCount)
positionStart - Indicates the position of the first component that has been inserted.itemCount - Indicates the number of components that have been inserted.public final void notifyRemovedAt(int position)
position - Indicates the position of the component that has been removed.public final void notifyRangeRemoved(int positionStart,
int itemCount)
positionStart - Indicates the position of the first component that has been removed.itemCount - Indicates the number of components that have been removed.public final void notifyPositionMoved(int fromPosition,
int toPosition)
fromPosition - Indicates the previous position of the component.toPosition - Indicates the new position of the component.public void onComponentOwnerToCachePool(E owner)
ComponentOwner created by the provider is reclaimed to
the ListComponentPool.owner - Indicates the ComponentOwner of the component that is reclaimed.public void onComponentBoundToWindow(E owner)
ComponentOwner created by the provider is bound to the
window.owner - Indicates the ComponentOwner of the component that is bound to the window.public void onComponentUnboundFromWindow(E owner)
ComponentOwner created by the provider is unbound from
the window.owner - Indicates the ComponentOwner of the component that is unbound from the window.public void onBoundToListComponent(ListComponent listContainer)
ListComponent is bound to the provider.listComponent - Indicates the ListComponent bound to the provider.public void onUnboundFromListComponent(ListComponent listContainer)
ListComponent is unbound from the provider.listComponent - Indicates the ListComponent unbound from the provider.public final boolean hasObserversRegistered()
true if one or more observers are registered with the provider; returns false
otherwise.public void registerDataObserver(ProviderSubscriber subscriber)
subscriber - Indicates the observer to register.public void unregisterDataObserver(ProviderSubscriber subscriber)
subscriber - Indicates the observer to unregister.