public class SwipeExecuteBehavior 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 |
SwipeExecuteBehavior.SwipeExecuteListener
Interface definition for a callback to be invoked when swipe behavior is working.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SWIPE_LIMIT |
static int |
DEFAULT_SWIPE_OFFSET |
Constructor and Description |
---|
SwipeExecuteBehavior() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(SwipeExecuteBehavior.SwipeExecuteListener listener)
Adds a listener to be called during the cycle of a swipe gesture.
|
void |
addSwipeDrawable(int offset,
Drawable drawable) |
void |
clearSwipeDrawables() |
void |
endExecute()
A method that is used to notify the behavior that the execution is complete.
|
int |
ensureWithinSwipeLimits(int currentSwipe) |
int |
getSwipeLimitEnd() |
int |
getSwipeLimitStart() |
int |
getSwipeOffset()
Gets the current value for the final offset that is set to a swiped item when the swipe gesture ends.
|
boolean |
isAutoDissolve()
Gets a value that determines if the swiped item will automatically fade as it reaches the end.
|
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 |
onDispatchDraw(Canvas canvas)
Called when
RadListView 's onDispatchDraw method is called. |
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 |
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(SwipeExecuteBehavior.SwipeExecuteListener listener)
Removes a listener that is called during the cycle of a swipe gesture.
|
boolean |
removeSwipeDrawable(int offset) |
void |
setAutoDissolve(boolean autoDissolve)
Sets a value that determines if the swiped item will automatically fade as it reaches the end.
|
void |
setSwipeLimitEnd(int swipeLimitEnd) |
void |
setSwipeLimitStart(int swipeLimitStart) |
void |
setSwipeOffset(int swipeOffset)
Sets a value for the final offset that is set to a swiped item when the swipe gesture ends.
|
bindViewHolder, createViewHolder, getItemViewType, managesViewHolders, onLayout, onLongPressDrag, onLongPressDragEnded, onScrolled
public static final int DEFAULT_SWIPE_OFFSET
public static final int DEFAULT_SWIPE_LIMIT
public void addListener(SwipeExecuteBehavior.SwipeExecuteListener listener)
listener
- the new listener.public void removeListener(SwipeExecuteBehavior.SwipeExecuteListener listener)
listener
- the listener to remove.public int getSwipeOffset()
300
. If your button is on the right,
then the offset should be set to -300
.
Note that when this is set to the default value which is DEFAULT_SWIPE_OFFSET
,
the behavior will try to manually calculate the final offset.public void setSwipeOffset(int swipeOffset)
300
. If your button is on the right,
then the offset should be set to -300
.
Note that when this is set to the default value which is DEFAULT_SWIPE_OFFSET
,
the behavior will try to manually calculate the final offset.swipeOffset
- the final swipe offset for a swiped item.public int getSwipeLimitStart()
public void setSwipeLimitStart(int swipeLimitStart)
public int getSwipeLimitEnd()
public void setSwipeLimitEnd(int swipeLimitEnd)
public boolean isAutoDissolve()
true
.public void setAutoDissolve(boolean autoDissolve)
true
.autoDissolve
- whether the swiped item will auto fade.public void endExecute()
public void addSwipeDrawable(int offset, Drawable drawable)
public boolean removeSwipeDrawable(int offset)
public void clearSwipeDrawables()
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 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 void onDispatchDraw(Canvas canvas)
ListViewBehavior
RadListView
's onDispatchDraw method is called.onDispatchDraw
in class ListViewBehavior
canvas
- the canvas on which to draw the viewpublic int ensureWithinSwipeLimits(int currentSwipe)
public boolean onInterceptTouchEvent(MotionEvent motionEvent)
onInterceptTouchEvent
in class ListViewBehavior