public class SwipeActionsBehavior 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 |
---|---|
class |
SwipeActionsBehavior.SwipeActionEvent
This class is used to encapsulate information about swipe-actions events that occur during
the process swiping and releasing an item.
|
static interface |
SwipeActionsBehavior.SwipeActionsListener
Interface definition for a callback to be invoked when swipe behavior is working.
|
static class |
SwipeActionsBehavior.SwipeActionsState
Defines the possible states for the
SwipeActionsBehavior . |
static class |
SwipeActionsBehavior.SwipeDockMode
Lists the possible dock modes for a swiped item.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SWIPE_LIMIT |
static int |
DEFAULT_SWIPE_OFFSET |
Constructor and Description |
---|
SwipeActionsBehavior() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(SwipeActionsBehavior.SwipeActionsListener listener)
Adds a listener to be called during the cycle of a swipe gesture.
|
void |
bindViewHolder(ListViewHolder holder,
int i)
Binds the provided
ListViewHolder instance to the dataitem at the specified index. |
ListViewHolder |
createViewHolder(ViewGroup parent,
int suggestedViewType)
Creates a
ListViewHolder instance for the corresponding view type. |
void |
endExecute()
A method that is used to notify the behavior that the execution is complete.
|
void |
endExecute(boolean forceReset)
A method that is used to notify the behavior that the execution is complete.
|
SwipeActionsBehavior.SwipeDockMode |
getDockMode()
Gets the dock mode for the item being swiped.
|
int |
getSwipeLimitEnd()
Gets an integer defining the swipe position from the end (right or bottom) beyond which the item cannot be dragged.
|
int |
getSwipeLimitStart()
Gets an integer defining the swipe position from the start (left or top) beyond which the item cannot be dragged.
|
SwipeActionsBehavior.SwipeActionsState |
getSwipeState()
Returns a value from the
SwipeActionsBehavior.SwipeActionsState enum determining the current state of the SwipeActionsBehavior . |
boolean |
isInProgress()
Returns true if the current behavior is in progress.
|
boolean |
managesViewHolders()
Gets a boolean value determining whether the behavior takes care of creating and binding view holders.
|
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). |
boolean |
onFling(MotionEvent motionEvent,
MotionEvent motionEvent2,
float v,
float v2)
Called when the fling gesture is detected by
RadListView 's
ListViewGestureListener . |
boolean |
onInterceptTouchEvent(MotionEvent motionEvent) |
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 . |
boolean |
onShortPressDrag(float startX,
float startY,
float currentX,
float currentY)
Called when the drag gesture is detected by
RadListView 's
ListViewGestureListener . |
boolean |
onTapUp(MotionEvent motionEvent)
Called when the tap up gesture is detected by
RadListView 's
ListViewGestureListener . |
void |
removeListener(SwipeActionsBehavior.SwipeActionsListener listener)
Removes a listener that is called during the cycle of a swipe gesture.
|
void |
setDockMode(SwipeActionsBehavior.SwipeDockMode dockMode)
Sets the dock mode for the item being swiped.
|
void |
setSwipeLimitEnd(int swipeLimitEnd)
Sets an integer defining the swipe position from the end (right or bottom) beyond which the item cannot be dragged.
|
void |
setSwipeLimitStart(int swipeLimitStart)
Sets an integer defining the swipe position from the start (left or top) beyond which the item cannot be dragged.
|
void |
setSwipeThresholdEnd(int swipeThreshold)
Sets an integer defining the swipe position from the end (right or bottom) where, when dragged beyond, the swiped item will stick at.
|
void |
setSwipeThresholdStart(int swipeThreshold)
Sets an integer defining the swipe position from the start (left or top) where, when dragged beyond, the swiped item will stick at.
|
getItemViewType, onDispatchDraw, onLongPressDrag, onLongPressDragEnded, onScrolled
public static final int DEFAULT_SWIPE_OFFSET
public static final int DEFAULT_SWIPE_LIMIT
public void addListener(SwipeActionsBehavior.SwipeActionsListener listener)
listener
- the new listener.public void removeListener(SwipeActionsBehavior.SwipeActionsListener listener)
listener
- the listener to remove.public void setSwipeThresholdStart(int swipeThreshold)
swipeThreshold
- the swipe position at which to stick.public void setSwipeThresholdEnd(int swipeThreshold)
swipeThreshold
- the swipe position at which to stick.public int getSwipeLimitStart()
public void setSwipeLimitStart(int swipeLimitStart)
swipeLimitStart
- an integer representing the swipe limit.public int getSwipeLimitEnd()
public void setSwipeLimitEnd(int swipeLimitEnd)
swipeLimitEnd
- an integer representing the swipe limit.public SwipeActionsBehavior.SwipeDockMode getDockMode()
SwipeActionsBehavior.SwipeDockMode
enum which defines the dock mode.public void setDockMode(SwipeActionsBehavior.SwipeDockMode dockMode)
dockMode
- a value from the SwipeActionsBehavior.SwipeDockMode
enum which defines the dock mode.public boolean managesViewHolders()
ListViewBehavior
managesViewHolders
in class ListViewBehavior
true
if view holders are managed by the behavior; false
otherwise.public ListViewHolder createViewHolder(ViewGroup parent, int suggestedViewType)
ListViewBehavior
ListViewHolder
instance for the corresponding view type.createViewHolder
in class ListViewBehavior
parent
- the parent of the view hosted by the view holder.suggestedViewType
- the type of view to create a view holder for.ListViewHolder
instance.public void bindViewHolder(ListViewHolder holder, int i)
ListViewBehavior
ListViewHolder
instance to the dataitem at the specified index.bindViewHolder
in class ListViewBehavior
holder
- the ListViewHolder
instance to bind.i
- the index of the data item in the source collection.public void endExecute()
public void endExecute(boolean forceReset)
forceReset
argument can be used to instruct the SwipeActionsBehavior
that
the swiped item must be reset to its original position without animation. Calling
this method with forceReset
equal to true
will immediately reset the behavior to
its SwipeActionsBehavior.SwipeActionsState.IDLE
state.forceReset
- true
for force reset, otherwise false.public SwipeActionsBehavior.SwipeActionsState getSwipeState()
SwipeActionsBehavior.SwipeActionsState
enum determining the current state of the SwipeActionsBehavior
.SwipeActionsBehavior.SwipeActionsState
value.public 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 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 parentpublic boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float v, float v2)
ListViewBehavior
RadListView
's
ListViewGestureListener
.onFling
in class ListViewBehavior
motionEvent
- The first down motion event that started the fling.motionEvent2
- The move motion event that triggered the current onFling.v
- The velocity of this fling measured in pixels per second
along the x axis.v2
- The velocity of this fling measured in pixels per second
along the y axis.public boolean onActionUpOrCancel(boolean isCanceled)
ListViewBehavior
onActionUpOrCancel
in class ListViewBehavior
isCanceled
- whether the gesture was cancelledpublic boolean onShortPressDrag(float startX, float startY, float currentX, float currentY)
ListViewBehavior
RadListView
's
ListViewGestureListener
.onShortPressDrag
in class ListViewBehavior
startX
- the x coordinate where the gesture startedstartY
- the y coordinate where the gesture startedcurrentX
- the x coordinate where the gesture occurring nowcurrentY
- the y coordinate where the gesture occurring nowpublic boolean onTapUp(MotionEvent motionEvent)
ListViewBehavior
RadListView
's
ListViewGestureListener
.onTapUp
in class ListViewBehavior
motionEvent
- The motion eventpublic boolean onInterceptTouchEvent(MotionEvent motionEvent)
onInterceptTouchEvent
in class ListViewBehavior