view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); return true; } });
View view = findViewById(...) view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
@Test public void performHapticFeedback_shouldSetLastPerformedHapticFeedback() throws Exception { assertThat(shadowOf(view).lastHapticFeedbackPerformed()).isEqualTo(-1); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); assertThat(shadowOf(view).lastHapticFeedbackPerformed()).isEqualTo(HapticFeedbackConstants.LONG_PRESS); }
mSelected = selected; if (actionState == ACTION_STATE_DRAG) { mSelected.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
View view = findViewById(...) view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
@Override public boolean onLongClick(View v){ v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); attemptExport(true); return false; } });
private void playHapticFeedback() { // Use any observer's view to play haptic feedback. for (DroppedFrameDetectorObserver observer : observers) { View view = observer.getHostViewForDroppedFrameHapticFeedback(); if (view != null) { view.performHapticFeedback(CONTEXT_CLICK, FLAG_IGNORE_GLOBAL_SETTING); break; } } }
@Override public boolean onKeyDown(int keycode, @NonNull KeyEvent e) { if (keycode == KeyEvent.KEYCODE_MENU) { // For devices with a physical menu button, we still want to display *our* contextual menu menuButton.showContextMenu(); menuButton.performHapticFeedback(LONG_PRESS); return true; } return super.onKeyDown(keycode, e); }
@Override public void onClick(View v) { int favNumber = (int) v.getTag(); final Result result = getFavResult(favNumber); result.fastLaunch(mainActivity, v); v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); }
@Override public boolean onLongClick(View v) { int favNumber = (int) v.getTag(); final Result result = getFavResult(favNumber); ListPopup popup = result.getPopupMenu(mainActivity, mainActivity.adapter, v); mainActivity.registerPopup(popup); popup.show(v); v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); return true; }
/** * Display menu, on short or long press. * * @param menuButton "kebab" menu (3 dots) */ public void onMenuButtonClicked(View menuButton) { // When the kiss bar is displayed, the button can still be clicked in a few areas (due to favorite margin) // To fix this, we discard any click event occurring when the kissbar is displayed if (!isViewingSearchResults()) { return; } if (!forwarderManager.onMenuButtonClicked(this.menuButton)) { this.menuButton.showContextMenu(); this.menuButton.performHapticFeedback(LONG_PRESS); } }
public static void vibrate(Context context, View view) { // Vibrator vibrator = (Vibrator) // context.getSystemService(Context.VIBRATOR_SERVICE); // vibrator.vibrate(30); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); }
@Override public boolean performLongPressHaptic(View v) { return v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING|HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING ); }
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } return false; } };
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } return false; } };
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } return false; } };
@Override boolean performItemLongClick(RecyclerView parent, View view, int position, long id) { if (mItemLongClickListener != null) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); return mItemLongClickListener.onItemLongClick(parent, view, position, id); } return false; }
@Override boolean performItemLongClick(RecyclerView parent, View view, int position, long id) { if (mItemLongClickListener != null) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); return mItemLongClickListener.onItemLongClick(parent, view, position, id); } return false; }
@Override public void onLongPress(MotionEvent e) { getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); BackgroundService.runWithPlugin(this, deviceId, MousePadPlugin.class, MousePadPlugin::sendSingleHold); }
@Override public boolean onLongClick(View v) { v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); if (v == mDelete) { mDelete.setPressed(false); mAmPmState = AMPM_NOT_SELECTED; reset(); updateKeypad(); return true; } return false; }