@Test public void testDeselect() { mTracker.select(mItems.get(7)); mTracker.deselect(mItems.get(7)); mSelection.assertNoSelection(); }
@Override public boolean deselect(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { if (!canSetState(key, false)) { if (DEBUG) Log.d(TAG, "Deselect cancelled by selection predicate test."); return false; } mSelection.remove(key); notifyItemStateChanged(key, false); notifySelectionChanged(); if (mSelection.isEmpty() && isRangeActive()) { endRange(); } return true; } return false; }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean deselect(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { if (!canSetState(key, false)) { if (DEBUG) Log.d(TAG, "Deselect cancelled by selection predicate test."); return false; } mSelection.remove(key); notifyItemStateChanged(key, false); notifySelectionChanged(); if (mSelection.isEmpty() && isRangeActive()) { endRange(); } return true; } return false; } }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean deselect(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { if (!canSetState(key, false)) { if (DEBUG) Log.d(TAG, "Deselect cancelled by selection predicate test."); return false; } mSelection.remove(key); notifyItemStateChanged(key, false); notifySelectionChanged(); if (mSelection.isEmpty() && isRangeActive()) { endRange(); } return true; } return false; } DefaultSelectionTracker(
            @NonNull String selectionId,
            @NonNull ItemKeyProvider keyProvider,
            @NonNull SelectionPredicate selectionPredicate,
            @NonNull StorageStrategy<K> storage); }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean deselect(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { if (!canSetState(key, false)) { if (DEBUG) Log.d(TAG, "Deselect cancelled by selection predicate test."); return false; } mSelection.remove(key); notifyItemStateChanged(key, false); notifySelectionChanged(); if (mSelection.isEmpty() && isRangeActive()) { endRange(); } return true; } return false; } DefaultSelectionTracker(
            @NonNull String selectionId,
            @NonNull ItemKeyProvider keyProvider,
            @NonNull SelectionPredicate selectionPredicate,
            @NonNull StorageStrategy<K> storage); @Override void addObserver(@NonNull SelectionObserver callback); @Override boolean hasSelection(); @Override Selection getSelection(); @Override void copySelection(@NonNull MutableSelection dest); @Override boolean isSelected(@Nullable K key); @Override boolean setItemsSelected(@NonNull Iterable<K> keys, boolean selected); @Override boolean clearSelection(); @Override boolean select(@NonNull K key); @Override boolean deselect(@NonNull K key); @Override void startRange(int position); @Override void extendRange(int position); @Override void endRange(); @Override void anchorRange(int position); @Override void extendProvisionalRange(int position); @Override void setProvisionalSelection(@NonNull Set<K> newSelection); @Override void mergeProvisionalSelection(); @Override void clearProvisionalSelection(); @Override boolean isRangeActive(); @Override @SuppressWarnings("unchecked") final void onSaveInstanceState(@NonNull Bundle state); @Override final void onRestoreInstanceState(@Nullable Bundle state); }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean deselect(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { if (!canSetState(key, false)) { if (DEBUG) Log.d(TAG, "Deselect cancelled by selection predicate test."); return false; } mSelection.remove(key); notifyItemStateChanged(key, false); notifySelectionChanged(); if (mSelection.isEmpty() && isRangeActive()) { endRange(); } return true; } return false; } DefaultSelectionTracker(
            @NonNull String selectionId,
            @NonNull ItemKeyProvider keyProvider,
            @NonNull SelectionPredicate selectionPredicate,
            @NonNull StorageStrategy<K> storage); @Override void addObserver(@NonNull SelectionObserver callback); @Override boolean hasSelection(); @Override Selection getSelection(); @Override void copySelection(@NonNull MutableSelection dest); @Override boolean isSelected(@Nullable K key); @Override boolean setItemsSelected(@NonNull Iterable<K> keys, boolean selected); @Override boolean clearSelection(); @Override boolean select(@NonNull K key); @Override boolean deselect(@NonNull K key); @Override void startRange(int position); @Override void extendRange(int position); @Override void endRange(); @Override void anchorRange(int position); @Override void extendProvisionalRange(int position); @Override void setProvisionalSelection(@NonNull Set<K> newSelection); @Override void mergeProvisionalSelection(); @Override void clearProvisionalSelection(); @Override boolean isRangeActive(); @Override @SuppressWarnings("unchecked") final void onSaveInstanceState(@NonNull Bundle state); @Override final void onRestoreInstanceState(@Nullable Bundle state);  }