android.view.KeyEvent#KEYCODE_DPAD_RIGHT源码实例Demo

下面列出了android.view.KeyEvent#KEYCODE_DPAD_RIGHT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


/**
 * 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) {
    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;
}
 
源代码2 项目: ankihelper   文件: 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.
 *
 * @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 (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) {
                        handled = arrowScroll(FOCUS_FORWARD);
                    } else if (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) {
                        handled = arrowScroll(FOCUS_BACKWARD);
                    }
                }
                break;
        }
    }
    return handled;
}
 
源代码3 项目: Bailan   文件: AutoGallery.java

/**
 * 重写Galler中手指滑动的手势方法
 * @param e1 按下的点
 * @param e2 抬起的点
 * @param velocityX X轴
 * @param velocityY Y轴
 * @return
 */
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                       float velocityY) {
    int kEvent;
    if (isScrollingLeft(e1, e2)) {
        kEvent = KeyEvent.KEYCODE_DPAD_LEFT; //设置手势滑动的方法 --向左
    } else {
        kEvent = KeyEvent.KEYCODE_DPAD_RIGHT; //设置手势滑动的方法--向右
    }
    onKeyDown(kEvent, null);  //进行设置galler切换图片
    if (this.getSelectedItemPosition() == 0) {
        this.setSelection(length);
    }
    return false;
}
 
源代码4 项目: nono-android   文件: FuckViewPager.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.
 *
 * @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;
}
 
源代码5 项目: WeekDatePicker   文件: WeekDatePicker.java

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

        if (!isEnabled()) {
            return super.onKeyDown(keyCode, event);
        }

        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_CENTER:
            case KeyEvent.KEYCODE_ENTER:
//                selectDay();
                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);
        }

    }
 
源代码6 项目: SprintNBA   文件: 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.
 *
 * @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;
}
 
源代码7 项目: adt-leanback-support   文件: ViewPager.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.
 *
 * @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;
}
 
源代码8 项目: android-recipes-app   文件: ViewPager.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.
 *
 * @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;
}
 
源代码9 项目: ankihelper   文件: ViewPager.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.
 *
 * @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:
                if (isOrientationHorizontal())
                    handled = arrowScroll(FOCUS_LEFT);
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (isOrientationHorizontal())
                    handled = arrowScroll(FOCUS_RIGHT);
                break;
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!isOrientationHorizontal())
                    handled = arrowScroll(FOCUS_UP);
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!isOrientationHorizontal())
                    handled = arrowScroll(FOCUS_DOWN);
                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;
}
 
源代码10 项目: AndroidTVWidget   文件: RecyclerViewTV.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    if (action == KeyEvent.ACTION_UP) {
        if (!isHorizontalLayoutManger() && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            // 垂直布局向下按键.
            exeuteKeyEvent();
        } else if (isHorizontalLayoutManger() && keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            // 横向布局向右按键.
            exeuteKeyEvent();
        }
    }
    return super.dispatchKeyEvent(event);
}
 
源代码11 项目: 365browser   文件: GamepadMappings.java

private static void mapCommonDpadButtons(float[] mappedButtons, float[] rawButtons) {
    float dpadDown = rawButtons[KeyEvent.KEYCODE_DPAD_DOWN];
    float dpadUp = rawButtons[KeyEvent.KEYCODE_DPAD_UP];
    float dpadLeft = rawButtons[KeyEvent.KEYCODE_DPAD_LEFT];
    float dpadRight = rawButtons[KeyEvent.KEYCODE_DPAD_RIGHT];
    mappedButtons[CanonicalButtonIndex.DPAD_DOWN] = dpadDown;
    mappedButtons[CanonicalButtonIndex.DPAD_UP] = dpadUp;
    mappedButtons[CanonicalButtonIndex.DPAD_LEFT] = dpadLeft;
    mappedButtons[CanonicalButtonIndex.DPAD_RIGHT] = dpadRight;
}
 

@Test
public void testMoveThumbFocus_dPad_correctThumbHasFocus() {
  slider.requestFocus();

  KeyEventBuilder left = new KeyEventBuilder(KeyEvent.KEYCODE_DPAD_LEFT);
  KeyEventBuilder right = new KeyEventBuilder(KeyEvent.KEYCODE_DPAD_RIGHT);

  // We start at far right in RTL so go left first, then go back right.
  sendKeyEventThereAndBack(left, right);
}
 
源代码13 项目: base-module   文件: ImageActivity.java

@Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        Log.i("!!!!!!", "===============================");
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_RIGHT:
//                loadResImage(mImageView);
//                loadSdImage(mImageView);
//                loadNetImageByFresco(mImageView);
//                loadResImageByFresco(mImageView);
//                loadSdImageByFresco(mImageView);
                loadResImageByGlide(mImageView);
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
//                loadResImage(mImageView1);
//                loadSdImage(mImageView1);
//                loadNetImageByFresco(mImageView1);
//                loadResImageByFresco(mImageView1);
//                loadSdImageByFresco(mImageView1);
                loadResImageByGlide(mImageView1);
                break;
            case KeyEvent.KEYCODE_DPAD_UP:

                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:

                break;
        }
        return super.onKeyUp(keyCode, event);
    }
 
源代码14 项目: codeexamples-android   文件: GameView.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    ensureInitialized();

    // Handle keys going up.
    boolean handled = false;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            mShip.setHeadingX(0);
            mDPadState &= ~DPAD_STATE_LEFT;
            handled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            mShip.setHeadingX(0);
            mDPadState &= ~DPAD_STATE_RIGHT;
            handled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            mShip.setHeadingY(0);
            mDPadState &= ~DPAD_STATE_UP;
            handled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            mShip.setHeadingY(0);
            mDPadState &= ~DPAD_STATE_DOWN;
            handled = true;
            break;
        default:
            if (isFireKey(keyCode)) {
                handled = true;
            }
            break;
    }
    if (handled) {
        step(event.getEventTime());
        return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
源代码15 项目: CSipSimple   文件: SearchView.java

/**
 * React to the user typing while in the suggestions list. First, check for
 * action keys. If not handled, try refocusing regular characters into the
 * EditText.
 */
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions (late arrival after dismiss)
    if (mSearchable == null) {
        return false;
    }
    if (mSuggestionsAdapter == null) {
        return false;
    }
    if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) {
        // First, check for enter or search (both of which we'll treat as a
        // "click")
        if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH
                || keyCode == KeyEvent.KEYCODE_TAB) {
            int position = mQueryTextView.getListSelection();
            return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null);
        }

        // Next, check for left/right moves, which we use to "return" the
        // user to the edit view
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            // give "focus" to text editor, with cursor at the beginning if
            // left key, at end if right key
            // TODO: Reverse left/right for right-to-left languages, e.g.
            // Arabic
            int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView
                    .length();
            mQueryTextView.setSelection(selPoint);
            mQueryTextView.setListSelection(0);
            mQueryTextView.clearListSelection();
            ensureImeVisible(mQueryTextView, true);

            return true;
        }

        // Next, check for an "up and out" move
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) {
            // TODO: restoreUserQuery();
            // let ACTV complete the move
            return false;
        }

        // Next, check for an "action key"
        // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
        // TODO if ((actionKey != null)
        // TODO         && ((actionKey.getSuggestActionMsg() != null) || (actionKey
        // TODO                 .getSuggestActionMsgColumn() != null))) {
        // TODO     // launch suggestion using action key column
        // TODO     int position = mQueryTextView.getListSelection();
        // TODO     if (position != ListView.INVALID_POSITION) {
        // TODO         Cursor c = mSuggestionsAdapter.getCursor();
        // TODO         if (c.moveToPosition(position)) {
        // TODO             final String actionMsg = getActionKeyMessage(c, actionKey);
        // TODO             if (actionMsg != null && (actionMsg.length() > 0)) {
        // TODO                 return onItemClicked(position, keyCode, actionMsg);
        // TODO             }
        // TODO         }
        // TODO     }
        // TODO }
    }
    return false;
}
 
源代码16 项目: BobEngine   文件: Gamepad.java

/**
 * Convert the KeyEvent key code into a Gamepad key code. Returns -1
 * if the key code does not have a matching Gamepad key code.
 * @param keyCode a KeyEvent key code
 * @return Gamepad key code
 */
public int getButton(int keyCode) {
	int button = -1;

	switch (keyCode) {
		case KeyEvent.KEYCODE_DPAD_RIGHT:
			button = D_RIGHT;
			break;
		case KeyEvent.KEYCODE_DPAD_LEFT:
			button = D_LEFT;
			break;
		case KeyEvent.KEYCODE_DPAD_UP:
			button = D_UP;
			break;
		case KeyEvent.KEYCODE_DPAD_DOWN:
			button = D_DOWN;
			break;
		case KeyEvent.KEYCODE_BUTTON_A:
			button = A;
			break;
		case KeyEvent.KEYCODE_BUTTON_B:
			button = B;
			break;
		case KeyEvent.KEYCODE_BUTTON_X:
			button = X;
			break;
		case KeyEvent.KEYCODE_BUTTON_Y:
			button = Y;
			break;
		case KeyEvent.KEYCODE_BUTTON_R1:
			button = R1;
			break;
		case KeyEvent.KEYCODE_BUTTON_L1:
			button = L1;
			break;
		case KeyEvent.KEYCODE_BUTTON_START:
			button = START;
			break;
		case KeyEvent.KEYCODE_BUTTON_SELECT:
			button = SELECT;
			break;
	}

	return button;
}
 
源代码17 项目: android_9.0.0_r45   文件: TabHost.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final boolean handled = super.dispatchKeyEvent(event);

    // unhandled key events change focus to tab indicator for embedded
    // activities when there is nothing that will take focus from default
    // focus searching
    if (!handled
            && (event.getAction() == KeyEvent.ACTION_DOWN)
            && (mCurrentView != null)
            && (mCurrentView.isRootNamespace())
            && (mCurrentView.hasFocus())) {
        int keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_UP;
        int directionShouldChangeFocus = View.FOCUS_UP;
        int soundEffect = SoundEffectConstants.NAVIGATION_UP;

        switch (getTabWidgetLocation()) {
            case TABWIDGET_LOCATION_LEFT:
                keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_LEFT;
                directionShouldChangeFocus = View.FOCUS_LEFT;
                soundEffect = SoundEffectConstants.NAVIGATION_LEFT;
                break;
            case TABWIDGET_LOCATION_RIGHT:
                keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_RIGHT;
                directionShouldChangeFocus = View.FOCUS_RIGHT;
                soundEffect = SoundEffectConstants.NAVIGATION_RIGHT;
                break;
            case TABWIDGET_LOCATION_BOTTOM:
                keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_DOWN;
                directionShouldChangeFocus = View.FOCUS_DOWN;
                soundEffect = SoundEffectConstants.NAVIGATION_DOWN;
                break;
            case TABWIDGET_LOCATION_TOP:
            default:
                keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_UP;
                directionShouldChangeFocus = View.FOCUS_UP;
                soundEffect = SoundEffectConstants.NAVIGATION_UP;
                break;
        }
        if (event.getKeyCode() == keyCodeShouldChangeFocus
                && mCurrentView.findFocus().focusSearch(directionShouldChangeFocus) == null) {
            mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus();
            playSoundEffect(soundEffect);
            return true;
        }
    }
    return handled;
}
 
源代码18 项目: TurboLauncher   文件: FocusHelper.java

/**
 * Handles key events in the workspace hotseat (bottom of the screen).
 */
static boolean handleHotseatButtonKeyEvent(View v, int keyCode, KeyEvent e, int orientation) {
    final ViewGroup parent = (ViewGroup) v.getParent();
    final ViewGroup launcher = (ViewGroup) parent.getParent();
    final Workspace workspace = (Workspace) launcher.findViewById(R.id.workspace);
    final int buttonIndex = parent.indexOfChild(v);
    final int buttonCount = parent.getChildCount();
    final int pageIndex = workspace.getCurrentPage();

    // NOTE: currently we don't special case for the phone UI in different
    // orientations, even though the hotseat is on the side in landscape mode.  This
    // is to ensure that accessibility consistency is maintained across rotations.

    final int action = e.getAction();
    final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
    boolean wasHandled = false;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (handleKeyEvent) {
                // Select the previous button, otherwise snap to the previous page
                if (buttonIndex > 0) {
                    parent.getChildAt(buttonIndex - 1).requestFocus();
                } else {
                    workspace.snapToPage(pageIndex - 1);
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (handleKeyEvent) {
                // Select the next button, otherwise snap to the next page
                if (buttonIndex < (buttonCount - 1)) {
                    parent.getChildAt(buttonIndex + 1).requestFocus();
                } else {
                    workspace.snapToPage(pageIndex + 1);
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            if (handleKeyEvent) {
                // Select the first bubble text view in the current page of the workspace
                final CellLayout layout = (CellLayout) workspace.getChildAt(pageIndex);
                final ShortcutAndWidgetContainer children = layout.getShortcutsAndWidgets();
                final View newIcon = getIconInDirection(layout, children, -1, 1);
                if (newIcon != null) {
                    newIcon.requestFocus();
                } else {
                    workspace.requestFocus();
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            // Do nothing
            wasHandled = true;
            break;
        default: break;
    }
    return wasHandled;
}
 
源代码19 项目: MHViewer   文件: GalleryActivity.java

@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);
}
 
源代码20 项目: AndroidChromium   文件: KeyNavigationUtil.java

/**
 * Checks whether the given event is any of DPAD right or NUMPAD right.
 * @param event Event to be checked.
 * @return Whether the event should be processed as a navigation right.
 */
public static boolean isGoRight(KeyEvent event) {
    return isActionDown(event) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT
            || (!event.isNumLockOn() && event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_6));
}
 
 方法所在类
 同类方法