/** * moves an item within the list from a position to a position * * @param fromPosition the position global from which we want to move * @param toPosition the global position to which to move * @return this */ public ModelAdapter<?, Item> move(int fromPosition, int toPosition) { if (mOriginalItems != null) { int preItemCount = mItemAdapter.getFastAdapter().getPreItemCount(fromPosition); int adjustedFrom = getAdapterPosition(mItemAdapter.getAdapterItems().get(fromPosition)); int adjustedTo = getAdapterPosition(mItemAdapter.getAdapterItems().get(toPosition)); Item item = mOriginalItems.get(adjustedFrom - preItemCount); mOriginalItems.remove(adjustedFrom - preItemCount); mOriginalItems.add(adjustedTo - preItemCount, item); performFiltering(mConstraint); return mItemAdapter; } else { return mItemAdapter.move(fromPosition, toPosition); } }