本文整理汇总了Java中android.view.KeyEvent.KEYCODE_DPAD_UP属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_DPAD_UP属性的具体用法?Java KeyEvent.KEYCODE_DPAD_UP怎么用?Java KeyEvent.KEYCODE_DPAD_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_DPAD_UP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean handled = false;
// When using DPad, show all the OSD so that focus can move freely
// from/to ActionBar to/from PlayerController
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
if(mPlayerController!=null){
return mPlayerController.onKey(keyCode, event);
}
break;
case KeyEvent.KEYCODE_I:
showVideoInfos();
handled = true;
break;
}
if (!mStopped && (mPlayerController!=null) &&mPlayerControllerPlaceholder!=null&&!handled) {
// Send key event to PlayerController if it (its place-holder actually) has the focus
// Only keep keys used for focus navigation (because this is not handled by PlayerController)
handled = mPlayerController.onKey(keyCode, event);
}
return handled ? true : super.onKeyDown(keyCode, event);
}
示例2: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_RIGHT:
lineByLineMoveTo(1);
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
lineByLineMoveTo(-1);
return true;
case KeyEvent.KEYCODE_DPAD_DOWN:
verticalDpadScroll(1);
return true;
case KeyEvent.KEYCODE_DPAD_UP:
verticalDpadScroll(-1);
return true;
}
}
return super.dispatchKeyEvent(event);
}
示例3: processKey
private boolean processKey(KeyEvent event, boolean realAction) {
int keyCode = event.getKeyCode();
// 按返回键.
if (keyCode == KeyEvent.KEYCODE_BACK) {
return false;
}
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
return false;
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_UP:
//
if (realAction)
mRootView.onKeyDown(keyCode, event);
else
mRootView.onKeyUp(keyCode, event);
return true;
default:
break;
}
return true;
}
示例4: isDpadKey
@SuppressLint("InlinedApi")
private boolean isDpadKey(int keyCode) {
return keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT
|| keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT
|| keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT
|| keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT
|| keyCode == KeyEvent.KEYCODE_DPAD_CENTER;
}
示例5: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (tvCursorManager != null && tvCursorManager.isShowCursor() && !isIMEMode) {
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN ||
event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP ||
event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT ||
event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT ||
event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER)
return tvCursorManager.onDpadClicked(event);
}
return super.dispatchKeyEvent(event);
}
示例6: handleKeyActionDown
private boolean handleKeyActionDown(View v, int keyCode, KeyEvent event) {
if(isInterruptOnKeyActionDown(v, keyCode, event)){
return true;
}
switch (keyCode){
case KeyEvent.KEYCODE_DPAD_UP:
PLog.d(TAG,"onKeyActionDown : dpad up");
return onKeyActionDownDpadUp(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_DOWN:
PLog.d(TAG,"onKeyActionDown : dpad down");
return onKeyActionDownDpadDown(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_LEFT:
PLog.d(TAG,"onKeyActionDown : dpad left");
return onKeyActionDownDpadLeft(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_RIGHT:
PLog.d(TAG,"onKeyActionDown : dpad right");
return onKeyActionDownDpadRight(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
PLog.d(TAG,"onKeyActionDown : dpad enter");
return onKeyActionDownDpadEnter(v, keyCode, event);
case KeyEvent.KEYCODE_BACK:
PLog.d(TAG,"onKeyActionDown : dpad back");
return onKeyActionDownDpadBack(v, keyCode, event);
case KeyEvent.KEYCODE_MENU:
PLog.d(TAG,"onKeyActionDown : dpad menu");
return onKeyActionDownDpadMenu(v, keyCode, event);
}
return false;
}
示例7: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (mOnInterceptListener != null && mOnInterceptListener.onIntercept(event)) {
return true;
}
boolean result = super.dispatchKeyEvent(event);
View focusView = this.getFocusedChild();
if (focusView == null) {
return result;
} else {
// TODO: 2017-11-3 解决不同viewType的item滑动
int dy = 0;
int dx = 0;
if (getChildCount() > 0) {
View firstView = this.getChildAt(0);
dy = firstView.getHeight();
dx = firstView.getWidth();
}
if (event.getAction() == KeyEvent.ACTION_UP
&& keyCodeOfDPAD(event)) {
return true;
} else {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_RIGHT:
return findNextFocusView(focusView, new Point(dx, 0), View.FOCUS_RIGHT);
case KeyEvent.KEYCODE_DPAD_LEFT:
return findNextFocusView(focusView, new Point(-dx, 0), View.FOCUS_LEFT);
case KeyEvent.KEYCODE_DPAD_DOWN:
return findNextFocusView(focusView, new Point(0, dy), View.FOCUS_DOWN);
case KeyEvent.KEYCODE_DPAD_UP:
return findNextFocusView(focusView, new Point(0, -dy), View.FOCUS_UP);
}
}
}
return result;
}
示例8: onKeyDown
public boolean onKeyDown(int kCode, KeyEvent kEvent) {
switch (kCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_CENTER:
break;
case KeyEvent.KEYCODE_BACK:
exitBy2Click();
return true;
}
return super.onKeyDown(kCode, kEvent);
}
示例9: dispatchKeyEvent
@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:
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);
}
示例10: handleKeyActionUp
private boolean handleKeyActionUp(View v, int keyCode, KeyEvent event) {
if(isInterruptOnKeyActionUp(v, keyCode, event)){
return true;
}
switch (keyCode){
case KeyEvent.KEYCODE_DPAD_UP:
PLog.d(TAG,"onKeyActionUp : dpad up");
return onKeyActionUpDpadUp(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_DOWN:
PLog.d(TAG,"onKeyActionUp : dpad down");
return onKeyActionUpDpadDown(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_LEFT:
PLog.d(TAG,"onKeyActionUp : dpad left");
return onKeyActionUpDpadLeft(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_RIGHT:
PLog.d(TAG,"onKeyActionUp : dpad right");
return onKeyActionUpDpadRight(v, keyCode, event);
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
PLog.d(TAG,"onKeyActionUp : dpad enter");
return onKeyActionUpDpadEnter(v, keyCode, event);
case KeyEvent.KEYCODE_BACK:
PLog.d(TAG,"onKeyActionUp : dpad back");
return onKeyActionUpDpadBack(v, keyCode, event);
case KeyEvent.KEYCODE_MENU:
PLog.d(TAG,"onKeyActionUp : dpad menu");
return onKeyActionUpDpadMenu(v, keyCode, event);
}
return false;
}
示例11: extOnKeyEvent
@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;
}
示例12: shouldConsume
/**
* Returns true only if this utility class handles the key code.
*/
public static boolean shouldConsume(int keyCode) {
return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END ||
keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN ||
keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL);
}
示例13: executeKeyEvent
@Override
public boolean executeKeyEvent(KeyEvent event) {
// Ignore all key events except arrow keys and spacebar. Otherwise, the ScrollView consumes
// unwanted events (including the hardware menu button and app-level keyboard shortcuts).
// http://crbug.com/308322
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_SPACE:
return super.executeKeyEvent(event);
default:
return false;
}
}
示例14: executeKeyEvent
/**
* 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()) {
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, false);
} else {
handled = fullScroll(View.FOCUS_UP, false);
}
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (!event.isAltPressed()) {
handled = arrowScroll(View.FOCUS_DOWN, false);
} else {
handled = fullScroll(View.FOCUS_DOWN, false);
}
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
if (!event.isAltPressed()) {
handled = arrowScroll(View.FOCUS_LEFT, true);
} else {
handled = fullScroll(View.FOCUS_LEFT, true);
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (!event.isAltPressed()) {
handled = arrowScroll(View.FOCUS_RIGHT, true);
} else {
handled = fullScroll(View.FOCUS_RIGHT, true);
}
break;
}
}
return handled;
}
示例15: dispatchKeyEvent
@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);
}