@Override public boolean apply(@NonNull IAdapter<Item> lastParentAdapter, int lastParentPosition, Item item, int position) { if (identifier == item.getIdentifier()) { //if it's a subitem remove it from the parent if (item instanceof ISubItem) { //a sub item which is not in the list can be instantly deleted IExpandable parent = (IExpandable) ((ISubItem) item).getParent(); //parent should not be null, but check in any case.. if (parent != null) { parent.getSubItems().remove(item); } } if (position != -1) { //a normal displayed item can only be deleted afterwards remove(position); } } return false; } }, false);
/** * removes an item at the given position within the existing icons * * @param position the global position */ public ModelAdapter<?, Item> remove(int position) { if (mOriginalItems != null) { mOriginalItems.remove(getAdapterPosition(mItemAdapter.getAdapterItems().get(position)) - mItemAdapter.getFastAdapter().getPreItemCount(position)); publishResults(mConstraint, performFiltering(mConstraint)); return mItemAdapter; } else { return mItemAdapter.remove(position); } }