Java Code Examples for android.view.KeyEvent#KEYCODE_DPAD_DOWN

The following examples show how to use android.view.KeyEvent#KEYCODE_DPAD_DOWN . 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: AwWebContentsDelegateAdapter.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void handleKeyboardEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        int direction;
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_DOWN:
                direction = View.FOCUS_DOWN;
                break;
            case KeyEvent.KEYCODE_DPAD_UP:
                direction = View.FOCUS_UP;
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                direction = View.FOCUS_LEFT;
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                direction = View.FOCUS_RIGHT;
                break;
            default:
                direction = 0;
                break;
        }
        if (direction != 0 && tryToMoveFocus(direction)) return;
    }
    mContentsClient.onUnhandledKeyEvent(event);
}
 
Example 2
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void reportExtractedMovement(int keyCode, int count) {
    int dx = 0, dy = 0;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            dx = -count;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            dx = count;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            dy = -count;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            dy = count;
            break;
    }
    onExtractedCursorMovement(dx, dy);
}
 
Example 3
Source File: FocusHelper.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Helper method to be used for playing sound effects.
 */
@Thunk static void playSoundEffect(int keyCode, View v) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_PAGE_DOWN:
        case KeyEvent.KEYCODE_MOVE_END:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_PAGE_UP:
        case KeyEvent.KEYCODE_MOVE_HOME:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP);
            break;
        default:
            break;
    }
}
 
Example 4
Source File: EnterPasswordActivity.java    From TuentiTV with Apache License 2.0 6 votes vote down vote up
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
  switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_DOWN:
      presenter.onDpadDownPressed();
      return true;
    case KeyEvent.KEYCODE_DPAD_LEFT:
      presenter.onDpadLeftPressed();
      return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
      presenter.onDpadRightPressed();
      return true;
    case KeyEvent.KEYCODE_DPAD_UP:
      presenter.onDpadUpPressed();
      return true;
    default:
      return super.onKeyDown(keyCode, event);
  }
}
 
Example 5
Source File: InternalSelectionView.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch(event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (mSelectedRow > 0) {
                mSelectedRow--;
                invalidate();
                ensureRectVisible();
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (mSelectedRow < (mNumRows - 1)) {
                mSelectedRow++;
                invalidate();
                ensureRectVisible();
                return true;
            }
            break;
    }
    return false;
}
 
Example 6
Source File: GalleryActivity.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Check volume
    if (Settings.getVolumePage()) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
                keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            return true;
        }
    }

    // Check keyboard and Dpad
    if (keyCode == KeyEvent.KEYCODE_PAGE_UP ||
            keyCode == KeyEvent.KEYCODE_PAGE_DOWN ||
            keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
            keyCode == KeyEvent.KEYCODE_DPAD_UP ||
            keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
            keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
            keyCode == KeyEvent.KEYCODE_DPAD_CENTER ||
            keyCode == KeyEvent.KEYCODE_SPACE ||
            keyCode == KeyEvent.KEYCODE_MENU) {
        return true;
    }

    return super.onKeyUp(keyCode, event);
}
 
Example 7
Source File: NumberPicker.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            removeAllCallbacks();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!mHasSelectorWheel) {
                break;
            }
            switch (event.getAction()) {
                case KeyEvent.ACTION_DOWN:
                    if (mWrapSelectorWheel || (keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                            ? getValue() < getMaxValue() : getValue() > getMinValue()) {
                        requestFocus();
                        mLastHandledDownDpadKeyCode = keyCode;
                        removeAllCallbacks();
                        if (mFlingScroller.isFinished()) {
                            changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
                        }
                        return true;
                    }
                    break;
                case KeyEvent.ACTION_UP:
                    if (mLastHandledDownDpadKeyCode == keyCode) {
                        mLastHandledDownDpadKeyCode = -1;
                        return true;
                    }
                    break;
            }
    }
    return super.dispatchKeyEvent(event);
}
 
Example 8
Source File: KeysInterpreter.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
public static boolean isNavigationKey(KeyEvent event) {
	int keyCode = event.getKeyCode();
	return keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
		keyCode == KeyEvent.KEYCODE_DPAD_UP ||
		keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
		keyCode == KeyEvent.KEYCODE_DPAD_LEFT;
}
 
Example 9
Source File: MainActivity.java    From crazyflie-android-client with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isJoystickButton(int keyCode) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            return true;
        default:
            return KeyEvent.isGamepadButton(keyCode);
    }
}
 
Example 10
Source File: NumberPicker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            removeAllCallbacks();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!mHasSelectorWheel) {
                break;
            }
            switch (event.getAction()) {
                case KeyEvent.ACTION_DOWN:
                    if (mWrapSelectorWheel || ((keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                            ? getValue() < getMaxValue() : getValue() > getMinValue())) {
                        requestFocus();
                        mLastHandledDownDpadKeyCode = keyCode;
                        removeAllCallbacks();
                        if (mFlingScroller.isFinished()) {
                            changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
                        }
                        return true;
                    }
                    break;
                case KeyEvent.ACTION_UP:
                    if (mLastHandledDownDpadKeyCode == keyCode) {
                        mLastHandledDownDpadKeyCode = -1;
                        return true;
                    }
                    break;
            }
    }
    return super.dispatchKeyEvent(event);
}
 
Example 11
Source File: AppAdapter.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isDown(int keycode) {
    switch (keycode) {
        case KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            return true;
        default:
            return false;
    }
}
 
Example 12
Source File: IMEService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
private boolean handleKeyboardFocusEvent(int keyCode){
	if(mInputView != null) {
		if (Environment.needDebug) {
			Environment.debug(TAG, "handleKeyboardFocusEvent:" + keyCode);
		}
		switch (keyCode) {
			case KeyEvent.KEYCODE_DPAD_UP:
			case KeyEvent.KEYCODE_DPAD_DOWN:
			case KeyEvent.KEYCODE_DPAD_LEFT:
			case KeyEvent.KEYCODE_DPAD_RIGHT:
				if(mInputView.isShown()) {
					requestNextButtonFocus(keyCode);
					return true;
				}
				break;
			case KeyEvent.KEYCODE_ENTER:
			case KeyEvent.KEYCODE_DPAD_CENTER:
				if (mInputView.isShown() && focusedView != null) {
					clickButtonByKey(focusedView);
					return true;
				}
				break;
			case KeyEvent.KEYCODE_CAPS_LOCK:
				toggleCapsState(true);
				return true;
			case KeyEvent.KEYCODE_ESCAPE:
			case KeyEvent.KEYCODE_BACK:
				if (mInputView.isShown()){
					if(helpDialog != null && helpDialog.isShown()){
						helpDialog.setVisibility(View.GONE);
					}else {
						this.finishInput();
					}
					return true;
				}
				break;
		}
	}
	return false;
}
 
Example 13
Source File: XulExt_ExternalEditBox.java    From starcor.xul with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean extOnKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            return dispatchKeyEvent(event);
    }
    return false;
}
 
Example 14
Source File: SudokuBoardView.java    From opensudoku with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (!mReadonly) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_UP:
                return moveCellSelection(0, -1);
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                return moveCellSelection(1, 0);
            case KeyEvent.KEYCODE_DPAD_DOWN:
                return moveCellSelection(0, 1);
            case KeyEvent.KEYCODE_DPAD_LEFT:
                return moveCellSelection(-1, 0);
            case KeyEvent.KEYCODE_0:
            case KeyEvent.KEYCODE_SPACE:
            case KeyEvent.KEYCODE_DEL:
                // clear value in selected cell
                // TODO: I'm not really sure that this is thread-safe
                if (mSelectedCell != null) {
                    if (event.isShiftPressed() || event.isAltPressed()) {
                        setCellNote(mSelectedCell, CellNote.EMPTY);
                    } else {
                        setCellValue(mSelectedCell, 0);
                        moveCellSelectionRight();
                    }
                }
                return true;
            case KeyEvent.KEYCODE_DPAD_CENTER:
                if (mSelectedCell != null) {
                    onCellTapped(mSelectedCell);
                }
                return true;
        }

        if (keyCode >= KeyEvent.KEYCODE_1 && keyCode <= KeyEvent.KEYCODE_9 && mSelectedCell != null) {
            int selNumber = keyCode - KeyEvent.KEYCODE_0;
            Cell cell = mSelectedCell;

            if (event.isShiftPressed() || event.isAltPressed()) {
                // add or remove number in cell's note
                setCellNote(cell, cell.getNote().toggleNumber(selNumber));
            } else {
                // enter number in cell
                setCellValue(cell, selNumber);
                moveCellSelectionRight();
            }
            return true;
        }
    }


    return false;
}
 
Example 15
Source File: GalleryActivity.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mGalleryView == null) {
        return super.onKeyDown(keyCode, event);
    }

    // Check volume
    if (Settings.getVolumePage()) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            if (mLayoutMode == GalleryView.LAYOUT_RIGHT_TO_LEFT) {
                mGalleryView.pageRight();
            } else {
                mGalleryView.pageLeft();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            if (mLayoutMode == GalleryView.LAYOUT_RIGHT_TO_LEFT) {
                mGalleryView.pageLeft();
            } else {
                mGalleryView.pageRight();
            }
            return true;
        }
    }

    // Check keyboard and Dpad
    switch (keyCode) {
        case KeyEvent.KEYCODE_PAGE_UP:
        case KeyEvent.KEYCODE_DPAD_UP:
            if (mLayoutMode == GalleryView.LAYOUT_RIGHT_TO_LEFT) {
                mGalleryView.pageRight();
            } else {
                mGalleryView.pageLeft();
            }
            return true;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            mGalleryView.pageLeft();
            return true;
        case KeyEvent.KEYCODE_PAGE_DOWN:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (mLayoutMode == GalleryView.LAYOUT_RIGHT_TO_LEFT) {
                mGalleryView.pageLeft();
            } else {
                mGalleryView.pageRight();
            }
            return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            mGalleryView.pageRight();
            return true;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_SPACE:
        case KeyEvent.KEYCODE_MENU:
            onTapMenuArea();
            return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
Example 16
Source File: TwoWayGridView.java    From recent-images with MIT License 4 votes vote down vote up
private boolean commonKey(int keyCode, int count, KeyEvent event) {
	if (mAdapter == null) {
		return false;
	}

	if (mDataChanged) {
		layoutChildren();
	}

	boolean handled = false;
	int action = event.getAction();

	if (action != KeyEvent.ACTION_UP) {
		if (mSelectedPosition < 0) {
			switch (keyCode) {
			case KeyEvent.KEYCODE_DPAD_UP:
			case KeyEvent.KEYCODE_DPAD_DOWN:
			case KeyEvent.KEYCODE_DPAD_LEFT:
			case KeyEvent.KEYCODE_DPAD_RIGHT:
			case KeyEvent.KEYCODE_DPAD_CENTER:
			case KeyEvent.KEYCODE_SPACE:
			case KeyEvent.KEYCODE_ENTER:
				resurrectSelection();
				return true;
			}
		}

		switch (keyCode) {
		case KeyEvent.KEYCODE_DPAD_LEFT:
			if (!event.isAltPressed()) {
				handled = mGridBuilder.arrowScroll(FOCUS_LEFT);
			} else {
				handled = fullScroll(FOCUS_UP);
			}
			break;

		case KeyEvent.KEYCODE_DPAD_RIGHT:
			if (!event.isAltPressed()) {
				handled = mGridBuilder.arrowScroll(FOCUS_RIGHT);
			} else {
				handled = fullScroll(FOCUS_DOWN);
			}
			break;

		case KeyEvent.KEYCODE_DPAD_UP:
			if (!event.isAltPressed()) {
				handled = mGridBuilder.arrowScroll(FOCUS_UP);

			} else {
				handled = fullScroll(FOCUS_UP);
			}
			break;

		case KeyEvent.KEYCODE_DPAD_DOWN:
			if (!event.isAltPressed()) {
				handled = mGridBuilder.arrowScroll(FOCUS_DOWN);
			} else {
				handled = fullScroll(FOCUS_DOWN);
			}
			break;

		case KeyEvent.KEYCODE_DPAD_CENTER:
		case KeyEvent.KEYCODE_ENTER: {
			if (getChildCount() > 0 && event.getRepeatCount() == 0) {
				keyPressed();
			}

			return true;
		}

		case KeyEvent.KEYCODE_SPACE:
			//if (mPopup == null || !mPopup.isShowing()) {
			if (!event.isShiftPressed()) {
				handled = pageScroll(FOCUS_DOWN);
			} else {
				handled = pageScroll(FOCUS_UP);
			}
			//}
			break;
		}
	}

	//if (!handled) {
	//    handled = sendToTextFilter(keyCode, count, event);
	//}

	if (handled) {
		return true;
	} else {
		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;
		}
	}
}
 
Example 17
Source File: XulLabelRender.java    From starcor.xul with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean onKeyEvent(KeyEvent event) {
	XulMarqueeTextRenderer textRenderer = _textRenderer;
	if (textRenderer == null) {
		return false;
	}
	if (textRenderer.isMultiline() && !(textRenderer.isAutoWrap() && textRenderer.isDrawingEllipsis())) {
		int scrollLines = 3;
		// 处理滚动事件
		int viewHeight = XulUtils.calRectHeight(_rect) - _padding.top - _padding.bottom;
		float textHeight = textRenderer.getHeight();
		float lineHeight = textRenderer.getLineHeight();
		if (textHeight > viewHeight && event.getAction() == KeyEvent.ACTION_DOWN) {
			int maxMumScrollStep = (int) (viewHeight / lineHeight - 1);
			if (maxMumScrollStep <= 0) {
				maxMumScrollStep = 1;
			}
			if (scrollLines > maxMumScrollStep) {
				scrollLines = maxMumScrollStep;
			}
			float scrollDelta = lineHeight * scrollLines;
			switch (event.getKeyCode()) {
			case KeyEvent.KEYCODE_DPAD_UP:
				if (_scrollTargetY < 0) {
					_scrollTargetY += scrollDelta;
					_scrollTargetY -= (_scrollTargetY % lineHeight);
					if (_scrollTargetY > 0) {
						_scrollTargetY = 0;
					}
					if (_scrollBar != null) {
						_scrollBar.reset();
					}
					markDirtyView();
					return true;
				}
				break;
			case KeyEvent.KEYCODE_DPAD_DOWN:
				int minScrollYPos = (int) (viewHeight - textHeight);
				if (_scrollTargetY > minScrollYPos) {
					_scrollTargetY -= scrollDelta;
					if (_scrollTargetY < minScrollYPos) {
						_scrollTargetY = minScrollYPos;
					}
					if (_scrollBar != null) {
						_scrollBar.reset();
					}
					markDirtyView();
					return true;
				}
				break;
			}
		}
	}
	return false;
}
 
Example 18
Source File: NestedScrollView.java    From AndroidAnimationExercise with Apache License 2.0 4 votes vote down vote up
/**
 * 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.
 *
 * @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 (!canScroll()) {
        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_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP);
                } else {
                    handled = fullScroll(View.FOCUS_UP);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN);
                }
                break;
            case KeyEvent.KEYCODE_SPACE:
                pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
                break;
        }
    }

    return handled;
}
 
Example 19
Source File: XLVideoPlayActivity.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode){
        case KeyEvent.KEYCODE_ESCAPE:
        case KeyEvent.KEYCODE_BACK:
            if(playListView.isShown()) {
                show(defaultTimeout);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if(!changeProgressByKey)changeProgressByKey = true;
            if(oldProgressValue == -1){
                oldProgressValue = 0;
                newProgressValue = oldProgressValue;
            }
            newProgressValue += keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? -GlobalSettings.FastForwardInterval : GlobalSettings.FastForwardInterval;
            int max = mVideoView.getDuration();
            //Log.d(TAG, "newProgressValue = " + newProgressValue);
            if(newProgressValue < (0 - max))newProgressValue = (0 - max);
            if(newProgressValue > max)newProgressValue = max;
            float deltaP = oldProgressValue - newProgressValue;
            onProgressSlide(-deltaP / max);
            return true;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_DPAD_UP:
            if(playListView.isShown()){
                View view = playListView.getLayoutManager().getFocusedChild();
                if(view != null){
                    View nextView = playListView.getLayoutManager().onInterceptFocusSearch(view, keyCode == KeyEvent.KEYCODE_DPAD_DOWN ? View.FOCUS_DOWN : View.FOCUS_UP);
                    if(nextView != null)nextView.requestFocus();
                }else {
                    playListView.requestFocus(keyCode == KeyEvent.KEYCODE_DPAD_DOWN ? View.FOCUS_DOWN : View.FOCUS_UP);
                }
                return true;
            }else if(xlDownloadManager.taskInstance().getPlayList().size() > 1){
                playListView.setVisibility(View.VISIBLE);
                return true;
            }else if(keyCode == KeyEvent.KEYCODE_DPAD_DOWN){
                keyDownComboCount ++;
                //Log.d(TAG, "keyDownComboCount = " + keyDownComboCount);
            }
            break;
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            doPauseResume();
            show(defaultTimeout);
            return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 20
Source File: ArrowKeyMovementMethod.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
private boolean executeDown(TextView widget, Spannable buffer, int keyCode , KeyEvent event) {
    boolean handled = false;

    if ( keyCode == KEYCODE_PAGE_UP ){
        handled |= volup(widget, buffer);
    }else if ( keyCode == KEYCODE_PAGE_DOWN){
        handled |= voldown(widget, buffer);
    }else if ( keyCode == KEYCODE_MOVE_HOME){
        handled |= movehome(widget, buffer ,event);
    }else if ( keyCode == KEYCODE_MOVE_END){
        handled |= moveend(widget, buffer , event);
    }else{
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled |= up(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled |= down(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled |= left(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled |= right(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            if (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0) {
                if (widget.showContextMenu()) {
                    handled = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if ( sUseVolumeKey ){
                handled |= volup(widget, buffer);
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if ( sUseVolumeKey ){
                handled |= voldown(widget, buffer);
            }
            break;
        }
    }
    if (handled) {
        MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
        resetLockedMeta(buffer);
    }

    return handled;
}