@Test public void testClearSelectionInRange() { final SelectionModule module = new SelectionModule(); final Adapter adapter = new Adapter(context); module.attachToAdapter(adapter); module.setMode(SelectionModule.MULTIPLE); module.selectRange(0, adapter.getItemCount()); module.clearSelectionInRange(adapter.getItemCount() - 5, 5); for (int i = 0; i < adapter.getItemCount(); i++) { assertThat(module.isSelected(adapter.getItemId(i)), is(i < 5)); } }
public void clearSelectionInRange(final int startPosition, final int count) { assertInMultipleSelectionModeOrThrow(); assertAttachedToAdapterOrThrow(); final int n = adapter.getItemCount(); if (startPosition + count > n) { throw new IndexOutOfBoundsException("Incorrect count(" + count + ") for start position(" + startPosition + "). Adapter has only " + n + " items."); } for (int i = startPosition; i < startPosition + count; i++) { deselect(adapter.getItemId(i)); } notifyAdapter(); }
SelectionModule extends AdapterModule { public void clearSelectionInRange(final int startPosition, final int count) { assertInMultipleSelectionModeOrThrow(); assertAttachedToAdapterOrThrow(); final int n = adapter.getItemCount(); if (startPosition + count > n) { throw new IndexOutOfBoundsException("Incorrect count(" + count + ") for start position(" + startPosition + "). Adapter has only " + n + " items."); } for (int i = startPosition; i < startPosition + count; i++) { deselect(adapter.getItemId(i)); } notifyAdapter(); } }
SelectionModule extends AdapterModule { public void clearSelectionInRange(final int startPosition, final int count) { assertInMultipleSelectionModeOrThrow(); assertAttachedToAdapterOrThrow(); final int n = adapter.getItemCount(); if (startPosition + count > n) { throw new IndexOutOfBoundsException("Incorrect count(" + count + ") for start position(" + startPosition + "). Adapter has only " + n + " items."); } for (int i = startPosition; i < startPosition + count; i++) { deselect(adapter.getItemId(i)); } notifyAdapter(); }  }
SelectionModule extends AdapterModule { public void clearSelectionInRange(final int startPosition, final int count) { assertInMultipleSelectionModeOrThrow(); assertAttachedToAdapterOrThrow(); final int n = adapter.getItemCount(); if (startPosition + count > n) { throw new IndexOutOfBoundsException("Incorrect count(" + count + ") for start position(" + startPosition + "). Adapter has only " + n + " items."); } for (int i = startPosition; i < startPosition + count; i++) { deselect(adapter.getItemId(i)); } notifyAdapter(); }  void setMode(@SelectionMode final int mode); @SelectionMode int getMode(); int toggleSelection(final long id); void setSelected(final long id, final boolean selected); void selectAll(); void selectRange(final int startPosition, final int count); void setSelection(@Nullable final List<Long> selection); boolean isSelected(final long id); @NonNull List<Long> getSelection(); int getSelectionSize(); void clearSelection(); void clearSelectionInRange(final int startPosition, final int count); @Override boolean requiresStateSaving(); @Override @CallSuper @NonNull Parcelable saveInstanceState(); @Override @CallSuper void restoreInstanceState(@NonNull final Parcelable savedState); }
SelectionModule extends AdapterModule { public void clearSelectionInRange(final int startPosition, final int count) { assertInMultipleSelectionModeOrThrow(); assertAttachedToAdapterOrThrow(); final int n = adapter.getItemCount(); if (startPosition + count > n) { throw new IndexOutOfBoundsException("Incorrect count(" + count + ") for start position(" + startPosition + "). Adapter has only " + n + " items."); } for (int i = startPosition; i < startPosition + count; i++) { deselect(adapter.getItemId(i)); } notifyAdapter(); }  void setMode(@SelectionMode final int mode); @SelectionMode int getMode(); int toggleSelection(final long id); void setSelected(final long id, final boolean selected); void selectAll(); void selectRange(final int startPosition, final int count); void setSelection(@Nullable final List<Long> selection); boolean isSelected(final long id); @NonNull List<Long> getSelection(); int getSelectionSize(); void clearSelection(); void clearSelectionInRange(final int startPosition, final int count); @Override boolean requiresStateSaving(); @Override @CallSuper @NonNull Parcelable saveInstanceState(); @Override @CallSuper void restoreInstanceState(@NonNull final Parcelable savedState); static final int SINGLE; static final int MULTIPLE; }