Java Code Examples for android.view.View#performHapticFeedback()
The following examples show how to use
android.view.View#performHapticFeedback() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatFragment.java From Twire with GNU General Public License v3.0 | 6 votes |
/** * Called from EmoteGridFragments when an Emote in the emotekeyboard has been clicked * * @param clickedEmote */ @Override public void onEmoteClicked(Emote clickedEmote, View view) { view.performHapticFeedback(VIBRATION_FEEDBACK); if (clickedEmote != null) { int startPosition = mSendText.getSelectionStart(); String emoteKeyword = clickedEmote.getKeyword(); if (startPosition != 0 && mSendText.getText().charAt(startPosition - 1) != ' ') { emoteKeyword = " " + emoteKeyword; } mSendText.getText().insert(startPosition, emoteKeyword); if (recentEmotesFragment != null) { recentEmotesFragment.addEmote(clickedEmote); } } }
Example 2
Source File: TrackSelectionAdapterWrapper.java From ticdesign with Apache License 2.0 | 6 votes |
boolean performLongPress(final View child, final int longPressPosition, final long longPressId) { // CHOICE_MODE_MULTIPLE_MODAL takes over long press. if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) { if (mChoiceActionMode == null) { setItemChecked(longPressPosition, true); child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return true; } boolean handled = false; if (mOnItemLongClickListener != null) { handled = mOnItemLongClickListener.onItemLongClick(this, child, longPressPosition, longPressId); } if (handled) { child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return handled; }
Example 3
Source File: Tools.java From RemoteControlView with Apache License 2.0 | 6 votes |
public static void startDrag(View view){ DraggableInfo tag = (DraggableInfo) view.getTag(); if (tag == null){ tag = new DraggableInfo("Text", 0, 0, 1); } Intent intent = new Intent(); intent.putExtra("data", tag); ClipData dragData = ClipData.newIntent("value", intent); View.DragShadowBuilder myShadow = new View.DragShadowBuilder(view); // 震动反馈,不需要震动权限 view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { view.startDragAndDrop(dragData, myShadow, null, 0); }else{ view.startDrag(dragData, myShadow, null, 0); } }
Example 4
Source File: PinFragment.java From green_android with GNU General Public License v3.0 | 6 votes |
@Override public void onKey(final int primaryCode, final int[] keyCodes) { final Editable editable; final View view; if (mIsSixDigit) { editable = mPinEntryView.getText(); view = mPinEntryView; } else { editable = mPinLongText.getEditableText(); view = mPinLongText; } view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); if (primaryCode >= 0 && primaryCode <= 9) editable.append(String.valueOf(primaryCode)); else if (primaryCode == -2) clear(); else if (primaryCode == -1) view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); }
Example 5
Source File: ChatFragment.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 6 votes |
/** * Called from EmoteGridFragments when an Emote in the emotekeyboard has been clicked * @param clickedEmote */ @Override public void onEmoteClicked(Emote clickedEmote, View view) { view.performHapticFeedback(VIBRATION_FEEDBACK); if (clickedEmote != null) { int startPosition = mSendText.getSelectionStart(); String emoteKeyword = clickedEmote.getKeyword(); if (startPosition != 0 && mSendText.getText().charAt(startPosition - 1) != ' ') { emoteKeyword = " " + emoteKeyword; } mSendText.getText().insert(startPosition, emoteKeyword); if (recentEmotesFragment != null) { recentEmotesFragment.addEmote(clickedEmote); } } }
Example 6
Source File: ItemClickSupport.java From PlayWidget with MIT License | 5 votes |
@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; }
Example 7
Source File: ChatFragment.java From Twire with GNU General Public License v3.0 | 5 votes |
private void emoteButtonClicked(View clickedView) { clickedView.performHapticFeedback(VIBRATION_FEEDBACK); if (hasSoftKeyboardBeenShown) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } if (!isEmoteKeyboardOpen) { if (!hasSoftKeyboardBeenShown) { Log.d(LOG_TAG, "SHOW SOFT KEYBOARD"); hideKeyboardWhenShown = true; if (mSendText.requestFocus()) { openSoftKeyboard(); } } showEmoteKeyboard(); } else { if (isSoftKeyboardOpen) { closeSoftKeyboard(); } else { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); openSoftKeyboard(); } } }
Example 8
Source File: ItemClickSupport.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@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; }
Example 9
Source File: AudioAndHapticFeedbackManager.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) { if (!mSettingsValues.mVibrateOn) { return; } if (mSettingsValues.mKeypressVibrationDuration >= 0) { vibrate(mSettingsValues.mKeypressVibrationDuration); return; } // Go ahead with the system default if (viewToPerformHapticFeedbackOn != null) { viewToPerformHapticFeedbackOn.performHapticFeedback( HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } }
Example 10
Source File: ConversationReactionOverlay.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void growView(@NonNull View view) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); view.animate() .scaleY(1.5f) .scaleX(1.5f) .translationY(-selectedVerticalTranslation) .setDuration(200) .setInterpolator(INTERPOLATOR) .start(); }
Example 11
Source File: ItemClickSupport.java From MultiView with Apache License 2.0 | 5 votes |
@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; }
Example 12
Source File: NumberPicker.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); mError.hideImmediately(); doOnClick(v); updateDeleteButtons(); }
Example 13
Source File: SUtils.java From SublimePicker with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void vibrateForDatePicker(View view) { // Using a different haptic feedback constant view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY /*(5) - HapticFeedbackConstants.CALENDAR_DATE*/); }
Example 14
Source File: RecyclerViewAdapter.java From journaldev with MIT License | 4 votes |
@Override public boolean onLongClick(View view) { listener.onRowLongClicked(getAdapterPosition()); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); return true; }
Example 15
Source File: AcDisplayFragment.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
/** * @see #showWidget(com.achep.acdisplay.ui.components.Widget) */ protected void showWidget(@NonNull Widget widget, boolean animate) { mHandler.removeMessages(MSG_SHOW_HOME_WIDGET); mHasPinnedWidget = false; Log.d(TAG, "showing widget " + widget); View iconView; if (mSelectedWidget != null) { iconView = mSelectedWidget.getIconView(); if (iconView != null) { iconView.setSelected(false); } mSelectedWidget.onViewDetached(); } mSelectedWidget = widget; resetSceneContainerParams(); animate &= isAnimatableAuto(); SceneCompat scene = findSceneByWidget(mSelectedWidget); if (scene == null) scene = mSceneMainClock; if (mCurrentScene != scene) { goScene(scene, animate); } else if (animate) { final ViewGroup viewGroup = mSelectedWidget.getView(); maybeBeginDelayedTransition(viewGroup, mTransitionJit); } mSelectedWidget.onViewAttached(); mBackground.dispatchSetBackground( mSelectedWidget.getBackground(), mSelectedWidget.getBackgroundMask()); updateStatusClockVisibility(!mSelectedWidget.hasClock() && getConfig().isFullScreen()); iconView = mSelectedWidget.getIconView(); if (iconView != null) { iconView.setSelected(true); iconView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } if (!isResumed()) { return; } // Start timeout on main or media widgets, and // pause it otherwise. if (widget.isHomeWidget()) { mTimeout.resume(); } else { mTimeout.setTimeoutDelayed(mTimeoutNormal, true); mTimeout.pause(); } }
Example 16
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 4 votes |
public static void vibrate(Context context, View view) { // Vibrator vibrator = (Vibrator) // context.getSystemService(Context.VIBRATOR_SERVICE); // vibrator.vibrate(30); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); }
Example 17
Source File: Launcher.java From TurboLauncher with Apache License 2.0 | 4 votes |
public void onTouchDownAllAppsButton(View v) { // Provide the same haptic feedback that the system offers for virtual // keys. v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); }
Example 18
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 4 votes |
public static void vibrate(Context context, View view) { // Vibrator vibrator = (Vibrator) // context.getSystemService(Context.VIBRATOR_SERVICE); // vibrator.vibrate(30); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); }
Example 19
Source File: RingdroidEditActivity.java From YTPlayer with GNU General Public License v3.0 | 4 votes |
public void onClick(View sender) { onPlay(mStartPos); sender.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); }
Example 20
Source File: Launcher.java From TurboLauncher with Apache License 2.0 | 2 votes |
/** * Event handler for the search button * * @param v * The view that was clicked. */ public void onClickSearchButton(View v) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); onSearchRequested(); }