public abstract class PageSliderProvider extends Object
This class provides the page item management functions, such as calculating the number of
available components and creating a component at a specified position. You need to inherit and implement
PageSliderProvider to display multiple components on different pages.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
POSITION_INVALID |
Indicates that a page is invalid from a container.
|
static int |
POSITION_REMAIN |
Indicates that the position of a page remains unchanged in a container.
|
| 构造器 | 说明 |
|---|---|
PageSliderProvider() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addDataSubscriber(DataSetSubscriber subscriber) |
Adds an subscriber for the current
PageSliderProvider. |
abstract Object |
createPageInContainer(ComponentContainer container,
int position) |
Creates a page at a specified position.
|
abstract void |
destroyPageFromContainer(ComponentContainer container,
int position,
Object object) |
Destroys a specified page in a container.
|
abstract int |
getCount() |
Obtains the number of available components in the current adapter.
|
int |
getPageIndex(Object object) |
Obtains the index of an
object in a container. |
String |
getPageTitle(int position) |
Obtains the title of a page at a specified position.
|
abstract boolean |
isPageMatchToObject(Component page,
Object object) |
Checks whether a
component is associated with a specific object returned from
createPageInContainer(ohos.agp.components.ComponentContainer,int). |
void |
notifyDataChanged() |
Notifies the page slider provider of a data set change.
|
void |
onUpdateFinished(ComponentContainer componentContainer) |
Notifies a container that a page update is finished.
|
void |
removeDataSubscriber(DataSetSubscriber subscriber) |
Unregisters an subscriber from the current
PageSliderProvider. |
void |
startUpdate(ComponentContainer container) |
Receives a notification indicating that an update on the displayed page is about to occur.
|
public static final int POSITION_INVALID
public static final int POSITION_REMAIN
public abstract int getCount()
public abstract Object createPageInContainer(ComponentContainer container, int position)
The page is added to the specified position in a container.
container - Indicates the container to display PageSliderProvider.position - Indicates the specified position in the container.public abstract void destroyPageFromContainer(ComponentContainer container, int position, Object object)
container - Indicates the container to which the page adapter belongs.position - Indicates the specified position in the container.object - Indicates the page to be destroyed.public abstract boolean isPageMatchToObject(Component page, Object object)
component is associated with a specific object returned from
createPageInContainer(ohos.agp.components.ComponentContainer,int).page - Indicates Component to be checked.object - Indicates the object associated with component to be checked.component is associated with the object.public void startUpdate(ComponentContainer container)
container - Indicates ComponentContainer to which the page adapter belongs.public void onUpdateFinished(ComponentContainer componentContainer)
When calling this method, you must ensure that all pages have been added to or removed from the container as required.
componentContainer - Indicates the container to which the page adapter belongs.public int getPageIndex(Object object)
object in a container.object - Indicates the object used to generate a component.object in the container;
returns POSITION_REMAIN if the object index has not changed;
returns POSITION_INVALID if the object is absent from the container.public void notifyDataChanged()
This method is called when the data to be displayed has changed.
public final void addDataSubscriber(DataSetSubscriber subscriber)
PageSliderProvider.
The subscriber receives callbacks related to data changes.
subscriber - Indicates the subscriber.IllegalArgumentException - Throws this exception if the parameter value is null.IllegalStateException - Throws this exception if the object is already addedpublic final void removeDataSubscriber(DataSetSubscriber subscriber)
PageSliderProvider.subscriber - Indicates the subscriber to be removed.IllegalArgumentException - Throws this exception if the parameter value is null.IllegalStateException - Throws this exception if the object is already removedpublic String getPageTitle(int position)
This method can be used for a PageSliderProvider object to obtain the title of a specified page.
position - Indicates the position of the page in PageSliderProvider.