yqritc/RecyclerView-FlexibleDivider

when i load more data,between last data of refresh and first data of loadmore has no divider,then i scroll the recycleview ,then divider has show,why

wei7785929 opened this issue · 1 comments

when i load more data,between last data of refresh and first data of loadmore has no divider,then i scroll the recycleview ,then divider has show,why

RecyclerView-FlexibleDivider builder set showLastDivider to false by default,so the last item will have no divider. When app load more data, you called notifyItemRangedInserted and the item which has no divider will not be invalidated.

to fix the problem, here is my suggestions:

  1. call notifyDatasetChanged when load more data to ensure all items are invalidated
  2. build divider with showLastDivider
    new HorizontalDividerItemDecoration.Builder(this).showLastDivider().build());
  3. call notifyItemChanged() to invalidate the item which has no divider
    final int last = adapter.getItemCount() - 1;
    // adaper.notifyItemRangeInserted(last, list.size());
    adapter.notifyItemChanged(last);

select one you prefer, i suggest the third one.