| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Set of light and non-invasive extensions for Android RecyclerView widget. Does not use custom RecyclerView or LayoutManager. With this extensions you can create RecyclerView with following features:
dragDropTouchListener = new DragDropTouchListener(recyclerView, this) {
@Override
protected void onItemSwitch(RecyclerView recyclerView, int from, int to) {
adapter.swapPositions(from, to);
adapter.notifyItemChanged(to);
adapter.notifyItemChanged(from);
@Override
protected void onItemDrop(RecyclerView recyclerView, int position) {
}
};
}
recyclerView.addOnItemTouchListener(dragDropTouchListener);This is port of Roman Nurik's SwipeToDismiss for ListView
swipeToDismissTouchListener = new SwipeToDismissTouchListener(recyclerView, new SwipeToDismissTouchListener.DismissCallbacks() {
@Override
public SwipeToDismissTouchListener.SwipeDirection canDismiss(int position) {
return SwipeToDismissTouchListener.SwipeDirection.RIGHT;
}
@Override
public void onDismiss(RecyclerView view, List<SwipeToDismissTouchListener.PendingDismissData> dismissData) {
for (SwipeToDismissTouchListener.PendingDismissData data : dismissData) {
adapter.removeItem(data.position);
adapter.notifyItemRemoved(data.position);
}
}
});
recyclerView.addOnItemTouchListener(swipeToDismissTouchListener);Use as normal RecyclerView.Adapter
As RecyclerView does not have standard way to add click listeners to the items, this RecyclerView.OnItemTouchListener intercepts touch events and translates them to simple onItemClick() and onItemLongClick() callbacks.
recyclerView.addOnItemTouchListener(new ItemTouchListenerAdapter(recyclerView, this));Sample app code is included, please see DemoActivity.
For full featured demo of real app see /du:/ tasks app on Google Play Store
| Back | FazBrowse Home | New Git URL |