@Test public void testTap_UnselectsSelectedItem() { mSelectionMgr.select("11"); mDetailsLookup.initAt(11); mInputDelegate.onSingleTapUp(TAP); mSelection.assertNoSelection(); }
@Override public boolean onSingleTapUp(@NonNull MotionEvent e) { if (!mDetailsLookup.overItemWithSelectionKey(e)) { if (DEBUG) Log.d(TAG, "Tap not associated w/ model item. Clearing selection."); mSelectionTracker.clearSelection(); return false; } ItemDetails<K> item = mDetailsLookup.getItemDetails(e); if (item == null) { return false; } if (mSelectionTracker.hasSelection()) { if (isRangeExtension(e)) { extendSelectionRange(item); } else if (mSelectionTracker.isSelected(item.getSelectionKey())) { mSelectionTracker.deselect(item.getSelectionKey()); } else { selectItem(item); } return true; } return item.inSelectionHotspot(e) ? selectItem(item) : mOnItemActivatedListener.onItemActivated(item, e); }
TouchInputHandler extends MotionInputHandler<K> { @Override public boolean onSingleTapUp(@NonNull MotionEvent e) { if (!mDetailsLookup.overItemWithSelectionKey(e)) { if (DEBUG) Log.d(TAG, "Tap not associated w/ model item. Clearing selection."); mSelectionTracker.clearSelection(); return false; } ItemDetails<K> item = mDetailsLookup.getItemDetails(e); if (item == null) { return false; } if (mSelectionTracker.hasSelection()) { if (isRangeExtension(e)) { extendSelectionRange(item); } else if (mSelectionTracker.isSelected(item.getSelectionKey())) { mSelectionTracker.deselect(item.getSelectionKey()); } else { selectItem(item); } return true; } return item.inSelectionHotspot(e) ? selectItem(item) : mOnItemActivatedListener.onItemActivated(item, e); } }
TouchInputHandler extends MotionInputHandler<K> { @Override public boolean onSingleTapUp(@NonNull MotionEvent e) { if (!mDetailsLookup.overItemWithSelectionKey(e)) { if (DEBUG) Log.d(TAG, "Tap not associated w/ model item. Clearing selection."); mSelectionTracker.clearSelection(); return false; } ItemDetails<K> item = mDetailsLookup.getItemDetails(e); if (item == null) { return false; } if (mSelectionTracker.hasSelection()) { if (isRangeExtension(e)) { extendSelectionRange(item); } else if (mSelectionTracker.isSelected(item.getSelectionKey())) { mSelectionTracker.deselect(item.getSelectionKey()); } else { selectItem(item); } return true; } return item.inSelectionHotspot(e) ? selectItem(item) : mOnItemActivatedListener.onItemActivated(item, e); } TouchInputHandler(
            @NonNull SelectionTracker<K> selectionTracker,
            @NonNull ItemKeyProvider<K> keyProvider,
            @NonNull ItemDetailsLookup<K> detailsLookup,
            @NonNull SelectionPredicate<K> selectionPredicate,
            @NonNull Runnable gestureStarter,
            @NonNull OnDragInitiatedListener onDragInitiatedListener,
            @NonNull OnItemActivatedListener<K> onItemActivatedListener,
            @NonNull FocusDelegate<K> focusDelegate,
            @NonNull Runnable hapticPerformer); }
TouchInputHandler extends MotionInputHandler<K> { @Override public boolean onSingleTapUp(@NonNull MotionEvent e) { if (!mDetailsLookup.overItemWithSelectionKey(e)) { if (DEBUG) Log.d(TAG, "Tap not associated w/ model item. Clearing selection."); mSelectionTracker.clearSelection(); return false; } ItemDetails<K> item = mDetailsLookup.getItemDetails(e); if (item == null) { return false; } if (mSelectionTracker.hasSelection()) { if (isRangeExtension(e)) { extendSelectionRange(item); } else if (mSelectionTracker.isSelected(item.getSelectionKey())) { mSelectionTracker.deselect(item.getSelectionKey()); } else { selectItem(item); } return true; } return item.inSelectionHotspot(e) ? selectItem(item) : mOnItemActivatedListener.onItemActivated(item, e); } TouchInputHandler(
            @NonNull SelectionTracker<K> selectionTracker,
            @NonNull ItemKeyProvider<K> keyProvider,
            @NonNull ItemDetailsLookup<K> detailsLookup,
            @NonNull SelectionPredicate<K> selectionPredicate,
            @NonNull Runnable gestureStarter,
            @NonNull OnDragInitiatedListener onDragInitiatedListener,
            @NonNull OnItemActivatedListener<K> onItemActivatedListener,
            @NonNull FocusDelegate<K> focusDelegate,
            @NonNull Runnable hapticPerformer); @Override boolean onSingleTapUp(@NonNull MotionEvent e); @Override void onLongPress(@NonNull MotionEvent e); }
TouchInputHandler extends MotionInputHandler<K> { @Override public boolean onSingleTapUp(@NonNull MotionEvent e) { if (!mDetailsLookup.overItemWithSelectionKey(e)) { if (DEBUG) Log.d(TAG, "Tap not associated w/ model item. Clearing selection."); mSelectionTracker.clearSelection(); return false; } ItemDetails<K> item = mDetailsLookup.getItemDetails(e); if (item == null) { return false; } if (mSelectionTracker.hasSelection()) { if (isRangeExtension(e)) { extendSelectionRange(item); } else if (mSelectionTracker.isSelected(item.getSelectionKey())) { mSelectionTracker.deselect(item.getSelectionKey()); } else { selectItem(item); } return true; } return item.inSelectionHotspot(e) ? selectItem(item) : mOnItemActivatedListener.onItemActivated(item, e); } TouchInputHandler(
            @NonNull SelectionTracker<K> selectionTracker,
            @NonNull ItemKeyProvider<K> keyProvider,
            @NonNull ItemDetailsLookup<K> detailsLookup,
            @NonNull SelectionPredicate<K> selectionPredicate,
            @NonNull Runnable gestureStarter,
            @NonNull OnDragInitiatedListener onDragInitiatedListener,
            @NonNull OnItemActivatedListener<K> onItemActivatedListener,
            @NonNull FocusDelegate<K> focusDelegate,
            @NonNull Runnable hapticPerformer); @Override boolean onSingleTapUp(@NonNull MotionEvent e); @Override void onLongPress(@NonNull MotionEvent e);  }