@Test(expected = AssertionError.class) public void testMoveItemFromPositionOutOfRange() { final SimpleAdapterDataSet dataSet = new SimpleAdapterDataSet<>(); dataSet.moveItem(0, 1); }
@Override public void moveItem(final int fromPosition, final int toPosition) { if (!hasItemAt(fromPosition)) { throw new AssertionError("No item to be moved from position(" + fromPosition + ") to position(" + toPosition + ") found!"); } if (!hasItemAt(toPosition)) { throw new AssertionError("No item to be moved from position(" + toPosition + ") to position(" + fromPosition + ") found!"); } this.items.set(fromPosition, items.set(toPosition, items.get(fromPosition))); AdaptersLogging.d(TAG, "Moved item from position(" + fromPosition + ") to position(" + toPosition + ")."); this.notifyItemMoved(fromPosition, toPosition); }
SimpleAdapterDataSet implements SimpleDataSet<I> { @Override public void moveItem(final int fromPosition, final int toPosition) { if (!hasItemAt(fromPosition)) { throw new AssertionError("No item to be moved from position(" + fromPosition + ") to position(" + toPosition + ") found!"); } if (!hasItemAt(toPosition)) { throw new AssertionError("No item to be moved from position(" + toPosition + ") to position(" + fromPosition + ") found!"); } this.items.set(fromPosition, items.set(toPosition, items.get(fromPosition))); AdaptersLogging.d(TAG, "Moved item from position(" + fromPosition + ") to position(" + toPosition + ")."); this.notifyItemMoved(fromPosition, toPosition); } }
SimpleAdapterDataSet implements SimpleDataSet<I> { @Override public void moveItem(final int fromPosition, final int toPosition) { if (!hasItemAt(fromPosition)) { throw new AssertionError("No item to be moved from position(" + fromPosition + ") to position(" + toPosition + ") found!"); } if (!hasItemAt(toPosition)) { throw new AssertionError("No item to be moved from position(" + toPosition + ") to position(" + fromPosition + ") found!"); } this.items.set(fromPosition, items.set(toPosition, items.get(fromPosition))); AdaptersLogging.d(TAG, "Moved item from position(" + fromPosition + ") to position(" + toPosition + ")."); this.notifyItemMoved(fromPosition, toPosition); } SimpleAdapterDataSet();   SimpleAdapterDataSet(@Nullable final List<I> items); }
SimpleAdapterDataSet implements SimpleDataSet<I> { @Override public void moveItem(final int fromPosition, final int toPosition) { if (!hasItemAt(fromPosition)) { throw new AssertionError("No item to be moved from position(" + fromPosition + ") to position(" + toPosition + ") found!"); } if (!hasItemAt(toPosition)) { throw new AssertionError("No item to be moved from position(" + toPosition + ") to position(" + fromPosition + ") found!"); } this.items.set(fromPosition, items.set(toPosition, items.get(fromPosition))); AdaptersLogging.d(TAG, "Moved item from position(" + fromPosition + ") to position(" + toPosition + ")."); this.notifyItemMoved(fromPosition, toPosition); } SimpleAdapterDataSet();   SimpleAdapterDataSet(@Nullable final List<I> items); @Override boolean isEmpty(); @Override int getItemCount(); @Override void insertItem(@NonNull final I item); @Override void insertItem(final int position, @NonNull final I item); @Override void insertItems(@NonNull final List<I> items); @Override void insertItems(final int positionStart, @NonNull final List<I> items); @Override @NonNull I swapItemById(final long itemId, @NonNull final I item); @Override @NonNull I swapItem(final int position, @NonNull final I item); @Override void moveItem(final int fromPosition, final int toPosition); @Override int removeItem(@NonNull final I item); @Override @NonNull I removeItemById(final long itemId); @Override @NonNull I removeItem(final int position); @Override @NonNull List<I> removeItems(final int positionStart, final int itemCount); @Override boolean hasItemAt(final int position); @Override boolean isEnabled(final int position); @Override boolean hasStableIds(); @Override long getItemId(final int position); @SuppressWarnings({"unchecked", "ConstantConditions"}) @Override @NonNull I getItem(int position); }
SimpleAdapterDataSet implements SimpleDataSet<I> { @Override public void moveItem(final int fromPosition, final int toPosition) { if (!hasItemAt(fromPosition)) { throw new AssertionError("No item to be moved from position(" + fromPosition + ") to position(" + toPosition + ") found!"); } if (!hasItemAt(toPosition)) { throw new AssertionError("No item to be moved from position(" + toPosition + ") to position(" + fromPosition + ") found!"); } this.items.set(fromPosition, items.set(toPosition, items.get(fromPosition))); AdaptersLogging.d(TAG, "Moved item from position(" + fromPosition + ") to position(" + toPosition + ")."); this.notifyItemMoved(fromPosition, toPosition); } SimpleAdapterDataSet();   SimpleAdapterDataSet(@Nullable final List<I> items); @Override boolean isEmpty(); @Override int getItemCount(); @Override void insertItem(@NonNull final I item); @Override void insertItem(final int position, @NonNull final I item); @Override void insertItems(@NonNull final List<I> items); @Override void insertItems(final int positionStart, @NonNull final List<I> items); @Override @NonNull I swapItemById(final long itemId, @NonNull final I item); @Override @NonNull I swapItem(final int position, @NonNull final I item); @Override void moveItem(final int fromPosition, final int toPosition); @Override int removeItem(@NonNull final I item); @Override @NonNull I removeItemById(final long itemId); @Override @NonNull I removeItem(final int position); @Override @NonNull List<I> removeItems(final int positionStart, final int itemCount); @Override boolean hasItemAt(final int position); @Override boolean isEnabled(final int position); @Override boolean hasStableIds(); @Override long getItemId(final int position); @SuppressWarnings({"unchecked", "ConstantConditions"}) @Override @NonNull I getItem(int position);  }