private void addLoadItem() { if (itemList != null) { itemList.add(new ItemObject("loaded one")); itemList.add(new ItemObject("loaded two")); itemList.add(new ItemObject("loaded three")); itemList.add(new ItemObject("loaded four")); onLoadmoreSucced("load succeed"); adapter.notifyItemRangeInserted(itemList.size() - 1, 4); return; } onLoadmoreFail("load failed"); }
private void addRefreshItem() { if (itemList != null) { itemList.add(0, new ItemObject("refreshed two")); itemList.add(0, new ItemObject("refreshed one")); int insertPos = adapter.hasHeader() ? 1 : 0; adapter.notifyItemRangeInserted(insertPos, 2); if (!adapter.hasHeader()) { recyclerView.smoothScrollToPosition(0); } onRefreshSucced("refresh succeed"); return; } onRefreshFailed("refresh failed"); }