Example usage for android.view KeyEvent metaStateHasNoModifiers

List of usage examples for android.view KeyEvent metaStateHasNoModifiers

Introduction

In this page you can find the example usage for android.view KeyEvent metaStateHasNoModifiers.

Prototype

public static boolean metaStateHasNoModifiers(int metaState) 

Source Link

Document

Returns true if no modifiers keys are pressed according to the specified meta state.

Usage

From source file:android.support.text.emoji.EmojiProcessor.java

private static boolean hasModifiers(KeyEvent event) {
    return !KeyEvent.metaStateHasNoModifiers(event.getMetaState());
}

From source file:com.lambergar.verticalviewpager.VerticalViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.//from w  ww .j  av a 2 s  . com
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            handled = arrowScroll(FOCUS_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled = arrowScroll(FOCUS_DOWN);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) {
                handled = arrowScroll(FOCUS_FORWARD);
            } else if (KeyEvent.metaStateHasModifiers(event.getMetaState(), KeyEvent.META_SHIFT_ON)) {
                handled = arrowScroll(FOCUS_BACKWARD);
            }
            break;
        }
    }
    return handled;
}