Example usage for android.view HapticFeedbackConstants CLOCK_TICK

List of usage examples for android.view HapticFeedbackConstants CLOCK_TICK

Introduction

In this page you can find the example usage for android.view HapticFeedbackConstants CLOCK_TICK.

Prototype

int CLOCK_TICK

To view the source code for android.view HapticFeedbackConstants CLOCK_TICK.

Click Source Link

Document

The user has pressed either an hour or minute tick of a Clock.

Usage

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void vibrateForTimePicker(View view) {
    view.performHapticFeedback(//from  ww w . java 2s. co m
            isApi_21_OrHigher() ? HapticFeedbackConstants.CLOCK_TICK : HapticFeedbackConstants.VIRTUAL_KEY);
}

From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java

private void tryVibrate() {
    mDelegator.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
}

From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java

private boolean handleTouchInput(float x, float y, boolean forceSelection, boolean autoAdvance) {
    final boolean isOnInnerCircle = getInnerCircleFromXY(x, y);
    final int degrees = getDegreesFromXY(x, y, false);
    if (degrees == -1) {
        return false;
    }//from ww w .  j  a  va 2s.c  om

    final int type;
    final int newValue;
    final boolean valueChanged;

    if (mShowHours) {
        final int snapDegrees = snapOnly30s(degrees, 0) % 360;
        valueChanged = mIsOnInnerCircle != isOnInnerCircle || mSelectionDegrees[HOURS] != snapDegrees;
        mIsOnInnerCircle = isOnInnerCircle;
        mSelectionDegrees[HOURS] = snapDegrees;
        type = HOURS;
        newValue = getCurrentHour();
    } else {
        final int snapDegrees = snapPrefer30s(degrees) % 360;
        valueChanged = mSelectionDegrees[MINUTES] != snapDegrees;
        mSelectionDegrees[MINUTES] = snapDegrees;
        type = MINUTES;
        newValue = getCurrentMinute();
    }

    if (valueChanged || forceSelection || autoAdvance) {
        // Fire the listener even if we just need to auto-advance.
        if (mListener != null) {
            mListener.onValueSelected(type, newValue, autoAdvance);
        }

        // Only provide feedback if the value actually changed.
        if (valueChanged || forceSelection) {
            performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
            invalidate();
        }
        return true;
    }

    return false;
}