android.view.View#performHapticFeedback ( )源码实例Demo

下面列出了android.view.View#performHapticFeedback ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Twire   文件: ChatFragment.java
/**
 * 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);
        }
    }
}
 
源代码2 项目: ticdesign   文件: TrackSelectionAdapterWrapper.java
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;
}
 
源代码3 项目: RemoteControlView   文件: Tools.java
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);
    }
}
 
源代码4 项目: green_android   文件: PinFragment.java
@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));
}
 
源代码5 项目: Pocket-Plays-for-Twitch   文件: ChatFragment.java
/**
 * 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);
		}
	}
}
 
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();
}
 
源代码7 项目: Twire   文件: ChatFragment.java
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();
        }
    }
}
 
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);
    }
}
 
源代码9 项目: MultiView   文件: ItemClickSupport.java
@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;
}
 
源代码10 项目: PhoneProfilesPlus   文件: NumberPicker.java
@Override
public void onClick(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    mError.hideImmediately();
    doOnClick(v);
    updateDeleteButtons();
}
 
源代码11 项目: UltimateAndroid   文件: ItemClickSupport.java
@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;
}
 
源代码12 项目: PlayWidget   文件: ItemClickSupport.java
@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;
}
 
源代码13 项目: YTPlayer   文件: RingdroidEditActivity.java
public void onClick(View sender) {
    onPlay(mStartPos);
    sender.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
 
源代码14 项目: iBeebo   文件: Utility.java
public static void vibrate(Context context, View view) {
    // Vibrator vibrator = (Vibrator)
    // context.getSystemService(Context.VIBRATOR_SERVICE);
    // vibrator.vibrate(30);
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
 
源代码15 项目: SublimePicker   文件: SUtils.java
@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*/);
}
 
源代码16 项目: TurboLauncher   文件: Launcher.java
public void onTouchDownAllAppsButton(View v) {
	// Provide the same haptic feedback that the system offers for virtual
	// keys.
	v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
 
源代码17 项目: iBeebo   文件: Utility.java
public static void vibrate(Context context, View view) {
    // Vibrator vibrator = (Vibrator)
    // context.getSystemService(Context.VIBRATOR_SERVICE);
    // vibrator.vibrate(30);
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
 
源代码18 项目: AcDisplay   文件: AcDisplayFragment.java
/**
 * @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();
    }
}
 
源代码19 项目: journaldev   文件: RecyclerViewAdapter.java
@Override
public boolean onLongClick(View view) {
    listener.onRowLongClicked(getAdapterPosition());
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    return true;
}
 
源代码20 项目: TurboLauncher   文件: Launcher.java
/**
 * Event handler for the search button
 * 
 * @param v
 *            The view that was clicked.
 */
public void onClickSearchButton(View v) {

	v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
	onSearchRequested();
}
 
 方法所在类
 同类方法