Making: github.com/niniloveyou…

Feel ok star thanks!

Effect picture :(effect picture loop after playing, always feel some weird! , may be the GIF cut point is wrong, on the phone to see the effect of normal)




swipeRecyclerView.gif

I’m not going to talk about how the code works. Say what is implemented:

  1. Supports automatic drop-down refresh
    / / set up automatic drop-down refresh, remember to in recyclerView. SetOnLoadListener () called after / / because there is no set in monitoring interface, SetRefreshing (true), can't call OnLoadListener mSwipeRecyclerView. SetRefreshing (true);Copy the code
  1. Support emptyView
mSwipeRecyclerView.setEmptyView(View emptyView);Copy the code

3. Disable pull-up loading or pull-down refreshing

/ / prohibited drop-down refresh mSwipeRecyclerView. SetRefreshEnable (false); / / prohibited to load more mSwipeRecyclerView. SetLoadMoreEnable (false);Copy the code

4. Support custom Footer View

FooterView / / / / Settings but custom footerView must inherit BaseFooterView mSwipeRecyclerView. SetFooterView (new SimpleFooterView (this));Copy the code

5. SpanSizeLookup support for GridLayoutManager

GridLayoutManager SpanSizeLookup = SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup = GridLayoutManager SpanSizeLookup mSwipeRecyclerView.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return 3; }});Copy the code

Childcount-1 does not contain the footerView

/ / set to remove footerView divider mSwipeRecyclerView. GetRecyclerView () addItemDecoration (new RecyclerView. ItemDecoration () { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { super.onDraw(c, parent, state); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(0xFFEECCCC); Rect rect = new Rect(); int left = parent.getPaddingLeft(); int right = parent.getWidth() - parent.getPaddingRight(); final int childCount = parent.getChildCount() - 1; for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); / / for the layout of the child information final RecyclerView. LayoutParams params = (RecyclerView. LayoutParams) child. GetLayoutParams (); final int top = child.getBottom() + params.bottomMargin; final int itemDividerHeight = 1; //px rect.set(left + 50, top, right - 50, top + itemDividerHeight); c.drawRect(rect, paint); }}});Copy the code

7. If you need to do other Settings for SwipeRefreshLayout or RecyclerView

       mSwipeRecyclerView.getSwipeRefreshLayout()
       mSwipeRecyclerView.getRecyclerView()Copy the code

8. Possible problems

Because the Recycler.Adapter methods for data set updating are all final and cannot be rewritten, and custom DataObserver methods cannot be implemented, such as: NotifyItemMoved method Therefore, using methods other than the DataObserver method in SwipeRecyclerView to update data sets can be problematic so it is recommended to update data sets using the methods in DataObserver.

Making: github.com/niniloveyou…

Feel ok star thanks!



201609272123578195.gif

Aren’t you going to like it?