/** * wraps notifyItemInserted * * @param position the global position */ public void notifyAdapterItemInserted(int position) { notifyAdapterItemRangeInserted(position, 1); }
@Override public void addAll(List<Item> items, int preItemCount) { int countBefore = mItems.size(); mItems.addAll(items); if (getFastAdapter() != null) { getFastAdapter().notifyAdapterItemRangeInserted(preItemCount + countBefore, items.size()); } }
@Override public void addAll(int position, List<Item> items, int preItemCount) { mItems.addAll(position - preItemCount, items); if (getFastAdapter() != null) { getFastAdapter().notifyAdapterItemRangeInserted(position, items.size()); } }
@Override public void onInserted(int position, int count) { adapter.getFastAdapter().notifyAdapterItemRangeInserted(adapter.getFastAdapter().getPreItemCountByOrder(adapter.getOrder()) + position, count); }
@Override public boolean notify(FastAdapter fastAdapter, int newItemsCount, int previousItemsCount, int itemsBeforeThisAdapter) { //now properly notify the adapter about the changes if (newItemsCount > previousItemsCount) { if (previousItemsCount > 0) { fastAdapter.notifyAdapterItemRangeChanged(itemsBeforeThisAdapter, previousItemsCount); } fastAdapter.notifyAdapterItemRangeInserted(itemsBeforeThisAdapter + previousItemsCount, newItemsCount - previousItemsCount); } else if (newItemsCount > 0 && newItemsCount < previousItemsCount) { fastAdapter.notifyAdapterItemRangeChanged(itemsBeforeThisAdapter, newItemsCount); fastAdapter.notifyAdapterItemRangeRemoved(itemsBeforeThisAdapter + newItemsCount, previousItemsCount - newItemsCount); } else if (newItemsCount == 0) { fastAdapter.notifyAdapterItemRangeRemoved(itemsBeforeThisAdapter, previousItemsCount); } else { //this condition should practically never happen fastAdapter.notifyAdapterDataSetChanged(); } return false; } };
@Override public boolean notify(FastAdapter fastAdapter, int newItemsCount, int previousItemsCount, int itemsBeforeThisAdapter) { //now properly notify the adapter about the changes if (newItemsCount > previousItemsCount) { if (previousItemsCount > 0) { fastAdapter.notifyAdapterItemRangeChanged(itemsBeforeThisAdapter, previousItemsCount); } fastAdapter.notifyAdapterItemRangeInserted(itemsBeforeThisAdapter + previousItemsCount, newItemsCount - previousItemsCount); } else if (newItemsCount > 0) { fastAdapter.notifyAdapterItemRangeChanged(itemsBeforeThisAdapter, newItemsCount); if (newItemsCount < previousItemsCount) { fastAdapter.notifyAdapterItemRangeRemoved(itemsBeforeThisAdapter + newItemsCount, previousItemsCount - newItemsCount); } } else if (newItemsCount == 0) { fastAdapter.notifyAdapterItemRangeRemoved(itemsBeforeThisAdapter, previousItemsCount); } else { //this condition should practically never happen fastAdapter.notifyAdapterDataSetChanged(); } return false; } };