@Test public void testSelect_NotifiesListenersOfChange() { mTracker.select(mItems.get(7)); mListener.assertSelectionChanged(); }
@Override public boolean select(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { return false; } if (!canSetState(key, true)) { if (DEBUG) Log.d(TAG, "Select cancelled by selection predicate test."); return false; } if (mSingleSelect && hasSelection()) { Selection prev = clearSelectionQuietly(); notifySelectionCleared(prev); } mSelection.add(key); notifyItemStateChanged(key, true); notifySelectionChanged(); return true; }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean select(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { return false; } if (!canSetState(key, true)) { if (DEBUG) Log.d(TAG, "Select cancelled by selection predicate test."); return false; } if (mSingleSelect && hasSelection()) { Selection prev = clearSelectionQuietly(); notifySelectionCleared(prev); } mSelection.add(key); notifyItemStateChanged(key, true); notifySelectionChanged(); return true; } }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean select(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { return false; } if (!canSetState(key, true)) { if (DEBUG) Log.d(TAG, "Select cancelled by selection predicate test."); return false; } if (mSingleSelect && hasSelection()) { Selection prev = clearSelectionQuietly(); notifySelectionCleared(prev); } mSelection.add(key); notifyItemStateChanged(key, true); notifySelectionChanged(); return true; } DefaultSelectionTracker(
            @NonNull String selectionId,
            @NonNull ItemKeyProvider keyProvider,
            @NonNull SelectionPredicate selectionPredicate,
            @NonNull StorageStrategy<K> storage); }
DefaultSelectionTracker extends SelectionTracker<K> { @Override public boolean select(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { return false; } if (!canSetState(key, true)) { if (DEBUG) Log.d(TAG, "Select cancelled by selection predicate test."); return false; } if (mSingleSelect && hasSelection()) { Selection prev = clearSelectionQuietly(); notifySelectionCleared(prev); } mSelection.add(key); notifyItemStateChanged(key, true); notifySelectionChanged(); return true; } 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 select(@NonNull K key) { checkArgument(key != null); if (mSelection.contains(key)) { return false; } if (!canSetState(key, true)) { if (DEBUG) Log.d(TAG, "Select cancelled by selection predicate test."); return false; } if (mSingleSelect && hasSelection()) { Selection prev = clearSelectionQuietly(); notifySelectionCleared(prev); } mSelection.add(key); notifyItemStateChanged(key, true); notifySelectionChanged(); return true; } 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);  }