public class InfiniteScrollAdapter extends Object
Allows adapting a scroll container to scroll indefinitely (or at least until running out of data), this effectively works by showing an infinite progress indicator when reaching scroll end then allowing code to fetch additional components.
Warning: If you call Container.removeAll()
on the container to which an InfiniteScrollAdapter is
installed, it will disable the infinite scrolling behavior. You can re-enable infinite scrolling by calling addMoreComponents(com.codename1.ui.Container, com.codename1.ui.Component[], boolean)
again.
The sample code shows the usage of the nestoria API to fill out an infinitely scrolling list.
Modifier and Type | Method and Description |
---|---|
void |
addMoreComponents(Component[] components,
boolean areThereMore)
Invoke this method to add additional components to the container, if you use
addComponent/removeComponent you will get undefined behavior.
|
static void |
addMoreComponents(Container cnt,
Component[] components,
boolean areThereMore)
Invoke this method to add additional components to the container, if you use
addComponent/removeComponent you will get undefined behavior.
|
void |
continueFetching()
If we previously added components with false for are there more this
method can continue the process of fetching.
|
static void |
continueFetching(Container cnt)
If we previously added components with false for are there more this
method can continue the process of fetching.
|
static InfiniteScrollAdapter |
createInfiniteScroll(Container cont,
Runnable fetchMore)
Creates an instance of the InfiniteScrollAdapter that will invoke the fetch more
callback to fetch additional components, once that method completes its task it
should add the components via the addMoreComponents() invocation.
|
static InfiniteScrollAdapter |
createInfiniteScroll(Container cont,
Runnable fetchMore,
boolean fetchOnCreate)
Creates an instance of the InfiniteScrollAdapter that will invoke the fetch more
callback to fetch additional components, once that method completes its task it
should add the components via the addMoreComponents() invocation.
|
int |
getComponentLimit()
Deprecated.
this feature has some inherent problems and doesn't work as expected
|
InfiniteProgress |
getInfiniteProgress()
Lets us manipulate the infinite progress object e.g.
|
void |
setComponentLimit(int componentLimit)
Deprecated.
this feature has some inherent problems and doesn't work as expected
|
public static InfiniteScrollAdapter createInfiniteScroll(Container cont, Runnable fetchMore)
cont
- the container to bind, it MUST be empty and must be scrollable on the Y axisfetchMore
- a callback that will be invoked on the EDT to fetch more data (do not block this method)public static InfiniteScrollAdapter createInfiniteScroll(Container cont, Runnable fetchMore, boolean fetchOnCreate)
cont
- the container to bind, it MUST be empty and must be scrollable on the Y axisfetchMore
- a callback that will be invoked on the EDT to fetch more data (do not block this method)fetchOnCreate
- if true the fetchMore callback is called upon calling this methodpublic static void addMoreComponents(Container cnt, Component[] components, boolean areThereMore)
cnt
- container to add the components tocomponents
- the components to addareThereMore
- whether additional components existpublic void addMoreComponents(Component[] components, boolean areThereMore)
components
- the components to addareThereMore
- whether additional components existpublic void continueFetching()
public static void continueFetching(Container cnt)
cnt
- the container associated with the infinite scroll adapterpublic int getComponentLimit()
public void setComponentLimit(int componentLimit)
componentLimit
- the componentLimit to setpublic InfiniteProgress getInfiniteProgress()