/** * wraps notifyItemRangeChanged * * @param position the global position * @param itemCount the count of items changed */ public void notifyAdapterItemRangeChanged(int position, int itemCount) { notifyAdapterItemRangeChanged(position, itemCount, null); }
/** * wraps notifyItemChanged * * @param position the global position * @param payload additional payload */ public void notifyAdapterItemChanged(int position, @Nullable Object payload) { notifyAdapterItemRangeChanged(position, 1, payload); }
@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; } };
@Override public void onChanged(int position, int count, Object payload) { adapter.getFastAdapter().notifyAdapterItemRangeChanged(adapter.getFastAdapter().getPreItemCountByOrder(adapter.getOrder()) + position, count, payload); } }