Java Code Examples for android.view.ViewConfiguration#getDoubleTapTimeout()

The following examples show how to use android.view.ViewConfiguration#getDoubleTapTimeout() . 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: InputPanel.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
/**
 * 隐藏所有输入布局
 */
private void hideAllInputLayout(boolean immediately) {
    if (hideAllInputLayoutRunnable == null) {
        hideAllInputLayoutRunnable = new Runnable() {

            @Override
            public void run() {
                hideInputMethod();
                hideActionPanelLayout();
                hideEmojiLayout();
            }
        };
    }
    long delay = immediately ? 0 : ViewConfiguration.getDoubleTapTimeout();
    uiHandler.postDelayed(hideAllInputLayoutRunnable, delay);
}
 
Example 2
Source File: AttachmentView.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN: {
			if (System.currentTimeMillis() - lastClickTime <= ViewConfiguration.getDoubleTapTimeout()) {
				event.setAction(MotionEvent.ACTION_CANCEL);
				return false;
			}
			break;
		}
		case MotionEvent.ACTION_UP:
		case MotionEvent.ACTION_CANCEL: {
			lastClickTime = System.currentTimeMillis();
			break;
		}
	}
	return super.onTouchEvent(event);
}
 
Example 3
Source File: TextFragment.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
	long time = System.currentTimeMillis();
	if (time - lastClickTime < ViewConfiguration.getDoubleTapTimeout()) {
		lastClickTime = 0L;
		textView.startSelection();
	} else {
		lastClickTime = time;
	}
}
 
Example 4
Source File: InputManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private int getDoubleTapTimeout() {
    return ViewConfiguration.getDoubleTapTimeout();
}
 
Example 5
Source File: ArbitraryTapListener.java    From under-the-hood with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (onClickListener == null) {
        return false;
    }
    boolean consume = false;
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            Log.d(TAG, "down");
            touchDownMs = System.currentTimeMillis();
            break;
        case MotionEvent.ACTION_UP:
            Log.d(TAG, "up");
            if ((System.currentTimeMillis() - touchDownMs) > ViewConfiguration.getTapTimeout()) {
                //it was not a tap
                numberOfTaps = 0;
                lastTapTimeMs = 0;
                Log.d(TAG, "reset");
                break;
            }

            if (numberOfTaps > 0
                    && (System.currentTimeMillis() - lastTapTimeMs) < ViewConfiguration.getDoubleTapTimeout()) {
                numberOfTaps += 1;
                Log.d(TAG, "+1");
                consume = true;
            } else {
                Log.d(TAG, "1");
                numberOfTaps = 1;
            }

            lastTapTimeMs = System.currentTimeMillis();

            if (numberOfTaps >= targetNumberOfTaps) {
                Log.d(TAG, "goal");
                onClickListener.onClick(v);
                numberOfTaps = 0;
                lastTapTimeMs = 0;
                consume = true;
            }
    }
    return consume;
}
 
Example 6
Source File: ViewConfigurationHelper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@CalledByNative
private static int getDoubleTapTimeout() {
    return ViewConfiguration.getDoubleTapTimeout();
}