public class SwipeRefreshBehavior extends ListViewBehavior
ListViewBehavior
that can be used to allow the end user
to refresh a list of items by swiping from the top of the list.Modifier and Type | Class and Description |
---|---|
static interface |
SwipeRefreshBehavior.SwipeRefreshListener
Interface definition for a callback to be invoked when a refresh is requested.
|
Constructor and Description |
---|
SwipeRefreshBehavior() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(SwipeRefreshBehavior.SwipeRefreshListener listener)
Adds a listener to be called when items refresh is requested.
|
void |
endRefresh(boolean scrollToStart)
A method that is used to notify the behavior that the refresh is complete.
|
void |
init(Context context)
Method that can be used to force the initialization of the
swipeRefresh()
before the behavior is attached to RadListView instance. |
boolean |
isInProgress()
Returns true if the current behavior is in progress.
|
boolean |
onActionUpOrCancel(boolean isCanceled)
Called when a previous gesture ends on up or cancel.
|
void |
onAttached(RadListView listView)
Called when the behavior is attached to
RadListView with
addBehavior(ListViewBehavior). |
void |
onDetached(RadListView listView)
Called when the behavior is detached to
RadListView with
removeBehavior(ListViewBehavior). |
void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom)
Called when
RadListView 's onLayout method is called. |
void |
onLongPress(MotionEvent motionEvent)
Called when the long press gesture is detected by
RadListView 's
ListViewGestureListener . |
void |
removeListener(SwipeRefreshBehavior.SwipeRefreshListener listener)
Removes a listener that is called when items refresh is requested.
|
SwipeRefreshLayout |
swipeRefresh()
Gets the instance of
SwipeRefreshLayout that is used by
this behavior. |
bindViewHolder, createViewHolder, getItemViewType, managesViewHolders, onDispatchDraw, onFling, onInterceptTouchEvent, onLongPressDrag, onLongPressDragEnded, onScrolled, onShortPressDrag, onTapUp
public SwipeRefreshLayout swipeRefresh()
SwipeRefreshLayout
that is used by
this behavior.
Note that this layout will be initialized when the behavior is attached to RadListView
.
If you need to access it before that you can manually initialize it with init(android.content.Context)
.public void addListener(SwipeRefreshBehavior.SwipeRefreshListener listener)
listener
- the new listener.public void removeListener(SwipeRefreshBehavior.SwipeRefreshListener listener)
listener
- the listener to remove.public void endRefresh(boolean scrollToStart)
scrollToStart
- a boolean value which defines whether the list should be
automatically scrolled to top to display the
refreshed list from the beginning.public void init(Context context)
swipeRefresh()
before the behavior is attached to RadListView
instance.context
- context to be usedpublic boolean isInProgress()
ListViewBehavior
isInProgress
in class ListViewBehavior
public void onAttached(RadListView listView)
ListViewBehavior
RadListView
with
addBehavior(ListViewBehavior).onAttached
in class ListViewBehavior
listView
- The parent list viewpublic void onDetached(RadListView listView)
ListViewBehavior
RadListView
with
removeBehavior(ListViewBehavior).onDetached
in class ListViewBehavior
listView
- The parent list viewpublic void onLongPress(MotionEvent motionEvent)
ListViewBehavior
RadListView
's
ListViewGestureListener
.onLongPress
in class ListViewBehavior
motionEvent
- The motion eventpublic boolean onActionUpOrCancel(boolean isCanceled)
ListViewBehavior
onActionUpOrCancel
in class ListViewBehavior
isCanceled
- whether the gesture was cancelledpublic void onLayout(boolean changed, int left, int top, int right, int bottom)
ListViewBehavior
RadListView
's onLayout method is called.
Derived classes with children should override this method and call layout on each of their children.
onLayout
in class ListViewBehavior
changed
- This is a new size or position for this viewleft
- Left position, relative to parenttop
- Top position, relative to parentright
- Right position, relative to parentbottom
- Bottom position, relative to parent