简化RecyclerView使用:SuperRecyclerView
jopen
10年前
这个项目的目的是让RecyclerView更容易使用。
内置功能:
- ProgressBar while adapter hasn't been set
- EmptyView if adapter is empty
- SwipeRefreshLayout (Google's one)
- Infinite scrolling, when you reach the X last item, load more of them.
- Swipe To Dismiss
- Sticky headers (via Eowise, see sample)
recycler.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener { @Override public void onRefresh() { // Do your refresh }); // when there is only 10 items to see in the recycler, this is triggered recycler.setupMoreListener(new OnMoreListener() { @Override public void onMoreAsked(int numberOfItems, int numberBeforeMore, int currentItemPos) { // Fetch more from Api or DB }}, 10); recycler.setupSwipeToDismiss(new SwipeDismissListViewTouchListener.DismissCallbacks() { @Override public boolean canDismiss(int position) { return true } @Override public void onDismiss(RecyclerView recyclerView, int[] reverseSortedPositions) { // Do your stuff like call an Api or update your db }});