Example usage for android.view KeyEvent KEYCODE_DPAD_LEFT

List of usage examples for android.view KeyEvent KEYCODE_DPAD_LEFT

Introduction

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

Prototype

int KEYCODE_DPAD_LEFT

To view the source code for android.view KeyEvent KEYCODE_DPAD_LEFT.

Click Source Link

Document

Key code constant: Directional Pad Left key.

Usage

From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java

private static boolean isReadable(int keyCode, KeyEvent event) {
    if (KeyEvent.isModifierKey(keyCode) || event.isSystem()) {
        return false;
    }//w  ww  .  j  a va  2  s.c om

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_ENTER:
        return false;
    }

    return true;
}

From source file:uk.org.downiesoft.slideshow.SlidesFragment.java

/**
 * Called by parent activity to handle cursor key events.
 * @param keyCode The keycode associated with the key pressed.
 * @return true if the keycode was consumed.
 *//*from  w  ww  .  jav a2  s  . c  o  m*/
public boolean onKeyUp(int keyCode) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_LEFT:
        prevImage(1);
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_SPACE:
        nextImage(-1);
        return true;
    case KeyEvent.KEYCODE_DPAD_UP:
        mUiHider.hideUi();
        return true;
    case KeyEvent.KEYCODE_DPAD_DOWN:
        mUiHider.showUi(false);
        return true;
    }
    return false;
}

From source file:org.mozilla.gecko.AwesomeBar.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // This method is called only if the key event was not handled
    // by any of the views, which usually means the edit box lost focus
    if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU
            || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_DPAD_UP
            || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT
            || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER
            || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        return super.onKeyDown(keyCode, event);
    } else {/* ww  w  .  ja  v  a2s.c  o  m*/
        int selStart = -1;
        int selEnd = -1;
        if (mText.hasSelection()) {
            selStart = mText.getSelectionStart();
            selEnd = mText.getSelectionEnd();
        }

        // Return focus to the edit box, and dispatch the event to it
        mText.requestFocusFromTouch();

        if (selStart >= 0) {
            // Restore the selection, which gets lost due to the focus switch
            mText.setSelection(selStart, selEnd);
        }

        mText.dispatchKeyEvent(event);
        return true;
    }
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

private boolean onInterceptInputEvent(InputEvent event) {
    final boolean controlsHidden = !mControlVisible;
    if (DEBUG)/*from w w w.  j  a  va2 s  .c  om*/
        Log.v(TAG, "onInterceptInputEvent hidden " + controlsHidden + " " + event);
    boolean consumeEvent = false;
    int keyCode = KeyEvent.KEYCODE_UNKNOWN;
    int keyAction = 0;

    if (event instanceof KeyEvent) {
        keyCode = ((KeyEvent) event).getKeyCode();
        keyAction = ((KeyEvent) event).getAction();
        if (mInputEventHandler != null) {
            consumeEvent = mInputEventHandler.onKey(getView(), keyCode, (KeyEvent) event);
        }
    }

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        // Event may be consumed; regardless, if controls are hidden then these keys will
        // bring up the controls.
        if (controlsHidden) {
            consumeEvent = true;
        }
        if (keyAction == KeyEvent.ACTION_DOWN) {
            tickle();
        }
        break;
    case KeyEvent.KEYCODE_BACK:
    case KeyEvent.KEYCODE_ESCAPE:
        if (mInSeek) {
            // when in seek, the SeekUi will handle the BACK.
            return false;
        }
        // If controls are not hidden, back will be consumed to fade
        // them out (even if the key was consumed by the handler).
        if (!controlsHidden) {
            consumeEvent = true;

            if (((KeyEvent) event).getAction() == KeyEvent.ACTION_UP) {
                hideControlsOverlay(true);
            }
        }
        break;
    default:
        if (consumeEvent) {
            if (keyAction == KeyEvent.ACTION_DOWN) {
                tickle();
            }
        }
    }
    return consumeEvent;
}

From source file:com.hippo.widget.BothScrollView.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 w  w . j a v a2 s. c  o  m*/
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();

    if (!canScrollHorizontally()) {
        if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
            View currentFocused = findFocus();
            if (currentFocused == this) {
                currentFocused = null;
            }
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_RIGHT);
            return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_RIGHT);
        }
        return false;
    }

    if (!canScrollVertically()) {
        if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
            View currentFocused = findFocus();
            if (currentFocused == this) {
                currentFocused = null;
            }
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
            return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (!event.isAltPressed()) {
                handled = arrowScrollHorizontally(View.FOCUS_LEFT);
            } else {
                handled = fullScroll(View.FOCUS_LEFT);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (!event.isAltPressed()) {
                handled = arrowScrollHorizontally(View.FOCUS_RIGHT);
            } else {
                handled = fullScroll(View.FOCUS_RIGHT);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!event.isAltPressed()) {
                handled = arrowScrollVertically(View.FOCUS_UP);
            } else {
                handled = fullScroll(View.FOCUS_UP);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (!event.isAltPressed()) {
                handled = arrowScrollVertically(View.FOCUS_DOWN);
            } else {
                handled = fullScroll(View.FOCUS_DOWN);
            }
            break;
        case KeyEvent.KEYCODE_SPACE:
            if (event.isCtrlPressed()) {
                pageScroll(event.isShiftPressed() ? View.FOCUS_LEFT : View.FOCUS_RIGHT);
            } else {
                pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
            }
            break;
        }
    }

    return handled;
}

From source file:org.ligi.gobandroid_hd.ui.GoActivity.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        final Cell ensuredTouchPosition = interaction_scope.getEnsuredTouchPosition();
        final BoardCell boardCell = getGame().getCalcBoard().getCell(ensuredTouchPosition);

        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (boardCell.up != null) {
                interaction_scope.touch_position = boardCell.up;
            } else {
                return false;
            }/*from  ww w .ja va  2  s  .  co  m*/
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (boardCell.left != null) {
                interaction_scope.touch_position = boardCell.left;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (boardCell.down != null) {
                interaction_scope.touch_position = boardCell.down;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (boardCell.right != null) {
                interaction_scope.touch_position = boardCell.right;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            doMoveWithUIFeedback(boardCell);
            break;

        default:

            return false;

        }

        go_board.postInvalidate();
        refreshZoomFragment();
        return true;
    }
    return false;
}

From source file:org.medcare.Dicom.DicomActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.e(TAG, "onKeyDown!!!!!!!!!!!!!!! " + keyCode);
    if (keyCode == KeyEvent.KEYCODE_PLUS) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MINUS) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        Log.e(TAG, "Del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        Log.e(TAG, "del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
        Log.e(TAG, "TAGS_INFO!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_INFO");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        Log.e(TAG, "TAGS_OFF!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_OFF");
    }//from  w  w  w .  j  a  v a  2  s . c o m
    return false;
}

From source file:com.aretha.slidemenu.SlideMenu.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (KeyEvent.ACTION_UP == event.getAction()) {
        final boolean isOpen = isOpen();
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            if (isOpen) {
                close(true);/*from w  ww .j a  va2 s  . c  o  m*/
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (STATE_OPEN_LEFT == mCurrentState) {
                close(true);
                return true;
            } else if (!isOpen) {
                open(true, true);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (STATE_OPEN_RIGHT == mCurrentState) {
                close(true);
                return true;
            } else if (!isOpen) {
                open(false, true);
                return true;
            }
            break;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:com.bitflake.counter.HorizontalPicker.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (!isEnabled()) {
        return super.onKeyDown(keyCode, event);
    }/* www .j av a  2s. co m*/

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        selectItem();
        return true;
    case KeyEvent.KEYCODE_DPAD_LEFT:
        smoothScrollBy(-1);
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        smoothScrollBy(1);
        return true;
    default:
        return super.onKeyDown(keyCode, event);
    }

}