List of usage examples for android.view KeyEvent KEYCODE_DPAD_RIGHT
int KEYCODE_DPAD_RIGHT
To view the source code for android.view KeyEvent KEYCODE_DPAD_RIGHT.
Click Source Link
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
private void onFunctionKey(final int primaryCode, final Key key, final int multiTapIndex, final int[] nearByKeyCodes, final boolean fromUI) { if (BuildConfig.DEBUG) Logger.d(TAG, "onFunctionKey %d", primaryCode); final InputConnection ic = getCurrentInputConnection(); switch (primaryCode) { case KeyCodes.DELETE: if (ic == null)// if we don't want to do anything, lets check null first. break; // we do backword if the shift is pressed while pressing // backspace (like in a PC) if (mAskPrefs.useBackword() && mShiftKeyState.isPressed() && !mShiftKeyState.isLocked()) { handleBackWord(ic);//from ww w . j a v a2 s.c om } else { handleDeleteLastCharacter(false); } break; case KeyCodes.SHIFT: if (fromUI) { handleShift(); } else { //not from UI (user not actually pressed that button) onPress(primaryCode); onRelease(primaryCode); } break; case KeyCodes.SHIFT_LOCK: mShiftKeyState.toggleLocked(); handleShift(); break; case KeyCodes.DELETE_WORD: if (ic == null)// if we don't want to do anything, lets check // null first. break; handleBackWord(ic); break; case KeyCodes.CLEAR_INPUT: if (ic != null) { ic.beginBatchEdit(); abortCorrectionAndResetPredictionState(false); ic.deleteSurroundingText(Integer.MAX_VALUE, Integer.MAX_VALUE); ic.endBatchEdit(); } break; case KeyCodes.CTRL: if (fromUI) { handleControl(); } else { //not from UI (user not actually pressed that button) onPress(primaryCode); onRelease(primaryCode); } break; case KeyCodes.CTRL_LOCK: mControlKeyState.toggleLocked(); handleControl(); break; case KeyCodes.ARROW_LEFT: case KeyCodes.ARROW_RIGHT: final int keyEventKeyCode = primaryCode == KeyCodes.ARROW_LEFT ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT; if (!handleSelectionExpending(keyEventKeyCode, ic, mGlobalSelectionStartPosition, mGlobalCursorPosition)) { sendDownUpKeyEvents(keyEventKeyCode); } break; case KeyCodes.ARROW_UP: sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_UP); break; case KeyCodes.ARROW_DOWN: sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN); break; case KeyCodes.MOVE_HOME: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { sendDownUpKeyEvents(0x0000007a/*API 11:KeyEvent.KEYCODE_MOVE_HOME*/); } else { if (ic != null) { CharSequence textBefore = ic.getTextBeforeCursor(1024, 0); if (!TextUtils.isEmpty(textBefore)) { int newPosition = textBefore.length() - 1; while (newPosition > 0) { char chatAt = textBefore.charAt(newPosition - 1); if (chatAt == '\n' || chatAt == '\r') { break; } newPosition--; } if (newPosition < 0) newPosition = 0; ic.setSelection(newPosition, newPosition); } } } break; case KeyCodes.MOVE_END: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //API 11: KeyEvent.KEYCODE_MOVE_END sendDownUpKeyEvents(0x0000007b); } else { if (ic != null) { CharSequence textAfter = ic.getTextAfterCursor(1024, 0); if (!TextUtils.isEmpty(textAfter)) { int newPosition = 1; while (newPosition < textAfter.length()) { char chatAt = textAfter.charAt(newPosition); if (chatAt == '\n' || chatAt == '\r') { break; } newPosition++; } if (newPosition > textAfter.length()) newPosition = textAfter.length(); try { CharSequence textBefore = ic.getTextBeforeCursor(Integer.MAX_VALUE, 0); if (!TextUtils.isEmpty(textBefore)) { newPosition = newPosition + textBefore.length(); } ic.setSelection(newPosition, newPosition); } catch (Throwable e/*I'm using Integer.MAX_VALUE, it's scary.*/) { Logger.w(TAG, "Failed to getTextBeforeCursor.", e); } } } } break; case KeyCodes.VOICE_INPUT: if (mVoiceRecognitionTrigger.isInstalled()) { mVoiceRecognitionTrigger .startVoiceRecognition(getCurrentAlphabetKeyboard().getDefaultDictionaryLocale()); } else { Intent voiceInputNotInstalledIntent = new Intent(getApplicationContext(), VoiceInputNotInstalledActivity.class); voiceInputNotInstalledIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(voiceInputNotInstalledIntent); } break; case KeyCodes.CANCEL: hideWindow(); break; case KeyCodes.SETTINGS: showOptionsMenu(); break; case KeyCodes.SPLIT_LAYOUT: case KeyCodes.MERGE_LAYOUT: case KeyCodes.COMPACT_LAYOUT_TO_RIGHT: case KeyCodes.COMPACT_LAYOUT_TO_LEFT: if (getInputView() != null) { mKeyboardInCondensedMode = CondenseType.fromKeyCode(primaryCode); setKeyboardForView(getCurrentKeyboard()); } break; case KeyCodes.DOMAIN: onText(key, mAskPrefs.getDomainText()); break; case KeyCodes.QUICK_TEXT: onQuickTextRequested(key); break; case KeyCodes.QUICK_TEXT_POPUP: onQuickTextKeyboardRequested(key); break; case KeyCodes.MODE_SYMOBLS: nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.Symbols); break; case KeyCodes.MODE_ALPHABET: if (getKeyboardSwitcher().shouldPopupForLanguageSwitch()) { showLanguageSelectionDialog(); } else { nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.Alphabet); } break; case KeyCodes.UTILITY_KEYBOARD: getInputView().openUtilityKeyboard(); break; case KeyCodes.MODE_ALPHABET_POPUP: showLanguageSelectionDialog(); break; case KeyCodes.ALT: nextAlterKeyboard(getCurrentInputEditorInfo()); break; case KeyCodes.KEYBOARD_CYCLE: nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.Any); break; case KeyCodes.KEYBOARD_REVERSE_CYCLE: nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.PreviousAny); break; case KeyCodes.KEYBOARD_CYCLE_INSIDE_MODE: nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.AnyInsideMode); break; case KeyCodes.KEYBOARD_MODE_CHANGE: nextKeyboard(getCurrentInputEditorInfo(), NextKeyboardType.OtherMode); break; case KeyCodes.CLIPBOARD_COPY: case KeyCodes.CLIPBOARD_PASTE: case KeyCodes.CLIPBOARD_CUT: case KeyCodes.CLIPBOARD_SELECT_ALL: case KeyCodes.CLIPBOARD_PASTE_POPUP: case KeyCodes.CLIPBOARD_SELECT: handleClipboardOperation(key, primaryCode, ic); //not allowing undo on-text in clipboard paste operations. if (primaryCode == KeyCodes.CLIPBOARD_PASTE) mCommittedWord = ""; break; default: if (BuildConfig.DEBUG) { //this should not happen! We should handle ALL function keys. throw new RuntimeException("UNHANDLED FUNCTION KEY! primary code " + primaryCode); } else { Logger.w(TAG, "UNHANDLED FUNCTION KEY! primary code %d. Ignoring.", primaryCode); } } }
From source file:com.appunite.list.GridView.java
private boolean commonKey(int keyCode, int count, KeyEvent event) { if (mAdapter == null) { return false; }/* w w w. j av a 2 s . co m*/ if (mDataChanged) { layoutChildren(); } boolean handled = false; int action = event.getAction(); if (action != KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_LEFT); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_RIGHT); } break; case KeyEvent.KEYCODE_DPAD_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded(); if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) { keyPressed(); handled = true; } } break; case KeyEvent.KEYCODE_SPACE: if (mPopup == null || !mPopup.isShowing()) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } } break; case KeyEvent.KEYCODE_PAGE_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_PAGE_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_MOVE_HOME: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_MOVE_END: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_TAB: // XXX Sometimes it is useful to be able to TAB through the items in // a GridView sequentially. Unfortunately this can create an // asymmetry in TAB navigation order unless the list selection // always reverts to the top or bottom when receiving TAB focus from // another widget. Leaving this behavior disabled for now but // perhaps it should be configurable (and more comprehensive). if (false) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_BACKWARD); } } break; } } if (handled) { return true; } if (sendToTextFilter(keyCode, count, event)) { return true; } switch (action) { case KeyEvent.ACTION_DOWN: return super.onKeyDown(keyCode, event); case KeyEvent.ACTION_UP: return super.onKeyUp(keyCode, event); case KeyEvent.ACTION_MULTIPLE: return super.onKeyMultiple(keyCode, count, event); default: return false; } }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }//from w ww. j a v a2 s .com } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, * we want to be able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: * once through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:bw.com.yunifangstore.view.LazyViewPager.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.// 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) { 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_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } break; } } return handled; }
From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }//from ww w .j a v a2s . c o m } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, * we want to be able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: * once through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (!Configuration.IS_NOOK_TOUCH || action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }//www . ja v a 2s . c o m } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, we want to be * able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: once * through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (!Configuration.IS_NOOK_TOUCH || action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && MenuItemCompat.isActionViewExpanded(searchMenuItem)) { boolean result = MenuItemCompat.getActionView(searchMenuItem).dispatchKeyEvent(event); if (result) { return true; }//from ww w . j a v a 2s .c om } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, * we want to be able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: * once through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:com.chenglong.muscle.ui.LazyViewPager.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 ww w .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_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and // FOCUS_BACKWARD // before Android 3.0. Ignore the include_tab key on those // devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
From source file:beichen.douban.ui.view.LazyViewPager.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 . ja v a 2 s .c om*/ * * @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_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and // FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those // devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
From source file:cn.xiaowen.news.view.LazyViewPager.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. ja v a 2 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) { 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_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and // FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }