public class SwipeRecyclerView
extends RecyclerView
| Modifier and Type | Class and Description |
|---|---|
static interface |
SwipeRecyclerView.DirectionMode |
static interface |
SwipeRecyclerView.LoadMoreListener |
static interface |
SwipeRecyclerView.LoadMoreView |
| Modifier and Type | Field and Description |
|---|---|
static int |
LEFT_DIRECTION
Left menu.
|
protected SwipeMenuLayout |
mOldSwipedLayout |
protected int |
mOldTouchedPosition |
protected int |
mScaleTouchSlop |
static int |
RIGHT_DIRECTION
Right menu.
|
| Constructor and Description |
|---|
SwipeRecyclerView(android.content.Context context) |
SwipeRecyclerView(android.content.Context context,
android.util.AttributeSet attrs) |
SwipeRecyclerView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFooterView(android.view.View view)
Add view at the footer.
|
void |
addHeaderView(android.view.View view)
Add view at the headers.
|
int |
getFooterCount()
Get size of footer.
|
int |
getHeaderCount()
Get size of headers.
|
int |
getItemViewType(int position)
Get ViewType of item.
|
Adapter |
getOriginAdapter()
Get the original adapter.
|
boolean |
isItemViewSwipeEnabled()
Get can long press swipe.
|
boolean |
isLongPressDragEnabled()
Get can long press drag.
|
boolean |
isSwipeItemMenuEnabled()
True means available, otherwise not available; default is true.
|
boolean |
isSwipeItemMenuEnabled(int position)
True means available, otherwise not available; default is true.
|
void |
loadMoreError(int errorCode,
java.lang.String errorMessage)
Called when data is loaded incorrectly.
|
void |
loadMoreFinish(boolean dataEmpty,
boolean hasMore)
Load more done.
|
boolean |
onInterceptTouchEvent(android.view.MotionEvent e) |
void |
onScrolled(int dx,
int dy) |
void |
onScrollStateChanged(int state) |
boolean |
onTouchEvent(android.view.MotionEvent e) |
void |
removeFooterView(android.view.View view) |
void |
removeHeaderView(android.view.View view)
Remove view from header.
|
void |
setAdapter(Adapter adapter) |
void |
setAutoLoadMore(boolean autoLoadMore)
Automatically load more automatically.
|
void |
setItemViewSwipeEnabled(boolean canSwipe)
Set can swipe delete.
|
void |
setLayoutManager(LayoutManager layoutManager) |
void |
setLoadMoreListener(SwipeRecyclerView.LoadMoreListener listener)
Load more listener.
|
void |
setLoadMoreView(SwipeRecyclerView.LoadMoreView view)
Load more view.
|
void |
setLongPressDragEnabled(boolean canDrag)
Set can long press drag.
|
void |
setOnItemClickListener(OnItemClickListener listener)
Set item click listener.
|
void |
setOnItemLongClickListener(OnItemLongClickListener listener)
Set item click listener.
|
void |
setOnItemMenuClickListener(OnItemMenuClickListener listener)
Set to click menu listener.
|
void |
setOnItemMoveListener(OnItemMoveListener listener)
Set OnItemMoveListener.
|
void |
setOnItemMovementListener(OnItemMovementListener listener)
Set OnItemMovementListener.
|
void |
setOnItemStateChangedListener(OnItemStateChangedListener listener)
Set OnItemStateChangedListener.
|
void |
setSwipeItemMenuEnabled(boolean enabled)
Set the item menu to enable status.
|
void |
setSwipeItemMenuEnabled(int position,
boolean enabled)
Set the item menu to enable status.
|
void |
setSwipeMenuCreator(SwipeMenuCreator menuCreator)
Set to create menu listener.
|
void |
smoothCloseMenu()
Close menu.
|
void |
smoothOpenLeftMenu(int position)
open menu on left.
|
void |
smoothOpenLeftMenu(int position,
int duration)
open menu on left.
|
void |
smoothOpenMenu(int position,
int direction,
int duration)
open menu.
|
void |
smoothOpenRightMenu(int position)
open menu on right.
|
void |
smoothOpenRightMenu(int position,
int duration)
open menu on right.
|
void |
startDrag(ViewHolder viewHolder)
Start drag a item.
|
void |
startSwipe(ViewHolder viewHolder)
Star swipe a item.
|
void |
useDefaultLoadMore()
Use the default to load more View.
|
public static final int LEFT_DIRECTION
public static final int RIGHT_DIRECTION
protected int mScaleTouchSlop
protected SwipeMenuLayout mOldSwipedLayout
protected int mOldTouchedPosition
public SwipeRecyclerView(android.content.Context context)
public SwipeRecyclerView(android.content.Context context,
android.util.AttributeSet attrs)
public SwipeRecyclerView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle)
public void setOnItemMoveListener(OnItemMoveListener listener)
listener - OnItemMoveListener.public void setOnItemMovementListener(OnItemMovementListener listener)
listener - OnItemMovementListener.public void setOnItemStateChangedListener(OnItemStateChangedListener listener)
listener - OnItemStateChangedListener.public void setSwipeItemMenuEnabled(boolean enabled)
enabled - true means available, otherwise not available; default is true.public boolean isSwipeItemMenuEnabled()
public void setSwipeItemMenuEnabled(int position,
boolean enabled)
position - the position of the item.enabled - true means available, otherwise not available; default is true.public boolean isSwipeItemMenuEnabled(int position)
position - the position of the item.public void setLongPressDragEnabled(boolean canDrag)
canDrag - drag true, otherwise is can't.public boolean isLongPressDragEnabled()
public void setItemViewSwipeEnabled(boolean canSwipe)
canSwipe - swipe true, otherwise is can't.public boolean isItemViewSwipeEnabled()
public void startDrag(ViewHolder viewHolder)
viewHolder - the ViewHolder to start dragging. It must be a direct child of RecyclerView.public void startSwipe(ViewHolder viewHolder)
viewHolder - the ViewHolder to start swiping. It must be a direct child of RecyclerView.public void setOnItemClickListener(OnItemClickListener listener)
public void setOnItemLongClickListener(OnItemLongClickListener listener)
public void setSwipeMenuCreator(SwipeMenuCreator menuCreator)
public void setOnItemMenuClickListener(OnItemMenuClickListener listener)
public void setLayoutManager(LayoutManager layoutManager)
public Adapter getOriginAdapter()
public void setAdapter(Adapter adapter)
public void addHeaderView(android.view.View view)
public void removeHeaderView(android.view.View view)
public void addFooterView(android.view.View view)
public void removeFooterView(android.view.View view)
public int getHeaderCount()
public int getFooterCount()
public int getItemViewType(int position)
public void smoothOpenLeftMenu(int position)
position - position.public void smoothOpenLeftMenu(int position,
int duration)
position - position.duration - time millis.public void smoothOpenRightMenu(int position)
position - position.public void smoothOpenRightMenu(int position,
int duration)
position - position.duration - time millis.public void smoothOpenMenu(int position,
int direction,
int duration)
position - position.direction - use LEFT_DIRECTION, RIGHT_DIRECTION.duration - time millis.public void smoothCloseMenu()
public boolean onInterceptTouchEvent(android.view.MotionEvent e)
public boolean onTouchEvent(android.view.MotionEvent e)
public void onScrollStateChanged(int state)
public void onScrolled(int dx,
int dy)
public void useDefaultLoadMore()
public void setLoadMoreView(SwipeRecyclerView.LoadMoreView view)
public void setLoadMoreListener(SwipeRecyclerView.LoadMoreListener listener)
public void setAutoLoadMore(boolean autoLoadMore)
Non-auto-loading mode, you can to click on the item to load.
autoLoadMore - you can use false.LoadMoreView#onWaitToLoadMore(LoadMoreListener)public final void loadMoreFinish(boolean dataEmpty,
boolean hasMore)
dataEmpty - data is empty ?hasMore - has more data ?public void loadMoreError(int errorCode,
java.lang.String errorMessage)
errorCode - Error code, will be passed to the LoadView, you can according to it to customize the prompt
information.errorMessage - Error message.