Example usage for android.view KeyEvent KEYCODE_DPAD_DOWN

List of usage examples for android.view KeyEvent KEYCODE_DPAD_DOWN

Introduction

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

Prototype

int KEYCODE_DPAD_DOWN

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

Click Source Link

Document

Key code constant: Directional Pad Down key.

Usage

From source file:pl.pelotasplus.pongtv.PongFragment.java

@Override
public void onKeyDown(int keyCode, KeyEvent event) {
    PongView.Player player;//  w w w .j a  v a  2s.com

    if (event.getDeviceId() % 2 == 0) {
        player = PongView.Player.LEFT;
    } else {
        player = PongView.Player.RIGHT;
    }
    Log.e("tag", "keyCode: " + keyCode);

    if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        pongView.changePlayerPosition(PongView.Player.LEFT, keyCode);
    } else if (keyCode == 23) {
        pongView.changePlayerPosition(PongView.Player.RIGHT, KeyEvent.KEYCODE_DPAD_DOWN);
    } else if (keyCode == 62) {
        pongView.changePlayerPosition(PongView.Player.RIGHT, KeyEvent.KEYCODE_DPAD_UP);
    }
}

From source file:com.mstar.tv.tvplayer.philips.option.OptionThirdFragment.java

public void updateView(String data, int dataPositon) {
    vseekbar_title.setText(data);/*from   w  ww  .  j  a v a2  s.  c o m*/
    switch (dataPositon) {
    case 0:
        currentIndex = K_TvPictureManager.getInstance().K_getPCHPos();
        Log.v(TAG, "=========hpos===currentIndex=" + currentIndex);
        break;
    case 1:
        currentIndex = K_TvPictureManager.getInstance().K_getPCVPos();
        Log.v(TAG, "=========vpos===currentIndex=" + currentIndex);
        break;
    case 2:
        currentIndex = K_TvPictureManager.getInstance().K_getPCClock();
        Log.v(TAG, "=========clock===currentIndex=" + currentIndex);
        break;
    case 3:
        currentIndex = K_TvPictureManager.getInstance().K_getPCPhase();
        Log.v(TAG, "=========phase===currentIndex=" + currentIndex);
        break;

    default:
        break;
    }
    seekBar.setProgress(currentIndex);
    progressVal.setText(String.valueOf(seekBar.getProgress()));
    up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted);
    down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted);
    final int flag = dataPositon;
    seekBar.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View arg0, int keyCode, KeyEvent keyevent) {
            if (keyevent.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_UP:
                    seekBar.incrementProgressBy(1);
                    progressVal.setText(String.valueOf(seekBar.getProgress()));
                    up_img.setBackgroundResource(R.drawable.slider_arrow_up_pressed);
                    down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted);
                    updateSeekbarData(flag, seekBar);
                    return true;
                case KeyEvent.KEYCODE_DPAD_DOWN:
                    seekBar.incrementProgressBy(-1);
                    progressVal.setText(String.valueOf(seekBar.getProgress()));
                    up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted);
                    down_img.setBackgroundResource(R.drawable.slider_arrow_down_pressed);
                    updateSeekbarData(flag, seekBar);
                    return true;
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    getActivity().onKeyDown(keyCode, keyevent);
                    return true;
                case KeyEvent.KEYCODE_DPAD_RIGHT:

                    return true;
                default:
                    break;
                }

            }
            return false;
        }
    });
}

From source file:com.commonsware.android.preso.decktastic.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_SPACE:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_PAGE_DOWN:
    case KeyEvent.KEYCODE_MEDIA_NEXT:
        if (pager.canScrollHorizontally(1)) {
            pager.setCurrentItem(pager.getCurrentItem() + 1, true);
        }/*from   w  w  w .j a  v  a 2s .c  om*/

        return (true);

    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_PAGE_UP:
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        if (pager.canScrollHorizontally(-1)) {
            pager.setCurrentItem(pager.getCurrentItem() - 1, true);
        }

        return (true);
    }

    return (super.onKeyDown(keyCode, event));
}

From source file:com.google.mist.plot.MainActivity.java

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

    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        toggleRecording(RecordingType.POSITIVE);
        return true;
    }//w  w  w.  j  a va  2s .  c  o m

    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        toggleRecording(RecordingType.NEGATIVE);
        return true;
    }

    /* To label magnet pulls with ground truth, connect with ADB and run command:
       $ input keyevent 66
       or from console, not inside adb shell,
       $ adb shell input keyevent 66
       or connect a bluetooth keyboard and hit "enter" key
     */
    if (mIsRecording && (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_DPAD_UP
            || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT
            || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) {
        mVibrator.vibrate(30);
        int recordedLabel = 0;
        switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
            recordedLabel = POSITIVE_LABEL;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            recordedLabel = UP_LABEL;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            recordedLabel = DOWN_LABEL;
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            recordedLabel = LEFT_LABEL;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            recordedLabel = RIGHT_LABEL;
            break;
        }
        long lastFiring = mSensorTime.get(mSensorTime.size() - 1);
        mPositivesTime.add(lastFiring);
        mPositivesData.add(recordedLabel);
    }

    return super.onKeyDown(keyCode, event);
}

From source file:org.videolan.vlc.gui.dialogs.PickTimeFragment.java

@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN)
        return false;
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_DPAD_DOWN:
        updateViews(keyCode);//from ww  w  .  ja v a  2 s. co  m
        return true;
    }
    return false;
}

From source file:com.android.screenspeak.KeyboardSearchManager.java

@Override
public boolean onKeyEvent(KeyEvent event) {
    // Only handle single-key events here. The KeyComboManager will pass us combos.
    if (event.getModifiers() != 0 || !mNodeSearch.isActive()) {
        return false;
    }/*from  www.jav  a  2  s . c  o m*/

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_ENTER:
            if (mHasNavigated || mNodeSearch.hasMatch()) {
                finishSearch();
                mContext.getCursorController().clickCurrent();
            } else {
                cancelSearch();
            }
            return true;
        case KeyEvent.KEYCODE_DEL:
            resetHintTime();
            final String queryText = mNodeSearch.getCurrentQuery();
            if (queryText.isEmpty()) {
                cancelSearch();
            } else {
                final String lastChar = queryText.substring(queryText.length() - 1);
                mNodeSearch.backspaceQueryText();
                mSpeechController.speak(mContext.getString(R.string.template_text_removed, lastChar),
                        SpeechController.QUEUE_MODE_FLUSH_ALL, FeedbackItem.FLAG_NO_HISTORY, null);
            }
            return true;
        case KeyEvent.KEYCODE_DPAD_UP:
            moveToEnd(NodeFocusFinder.SEARCH_BACKWARD);
            return true;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            moveToNext(NodeFocusFinder.SEARCH_BACKWARD);
            return true;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            moveToEnd(NodeFocusFinder.SEARCH_FORWARD);
            return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            moveToNext(NodeFocusFinder.SEARCH_FORWARD);
            return true;
        case KeyEvent.KEYCODE_SPACE:
            resetHintTime();
            if (mNodeSearch.tryAddQueryText(" ")) {
                mSpeechController.speak(mContext.getString(R.string.symbol_space),
                        SpeechController.QUEUE_MODE_FLUSH_ALL, FeedbackItem.FLAG_NO_HISTORY, null);
            } else {
                mContext.getFeedbackController().playAuditory(R.raw.complete);
            }
            return true;
        default:
            if (event.isPrintingKey()) {
                resetHintTime();
                final String key = String.valueOf(event.getDisplayLabel());
                if (mNodeSearch.tryAddQueryText(key)) {
                    mSpeechController.speak(key.toLowerCase(), SpeechController.QUEUE_MODE_FLUSH_ALL,
                            FeedbackItem.FLAG_NO_HISTORY, null);
                } else {
                    mContext.getFeedbackController().playAuditory(R.raw.complete);
                }
                return true;
            }
            break;
        }
    }

    return false;
}

From source file:com.vuze.android.remote.AndroidUtilsUI.java

public static boolean handleBrokenListViewScrolling(Activity a, int keyCode) {
    // Hack for FireTV 1st Gen (and possibly others):
    // sometimes scrolling up/down stops being processed by ListView,
    // even though there's more list to show.  Handle this manually
    // Dirty implemenation -- doesn't take into consideration disabled rows
    // or page-up/down/top/bottom key modifiers
    if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        ListView lv = null;//from   w ww. j  a  v a2 s.c o  m

        View currentFocus = a.getCurrentFocus();
        if (currentFocus instanceof ListView) {
            lv = (ListView) currentFocus;
            if (lv.getChoiceMode() == ListView.CHOICE_MODE_SINGLE) {
                int position = lv.getSelectedItemPosition();
                if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
                    position--;
                } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
                    position++;
                }

                if (position > 0 && position < lv.getCount()) {
                    lv.setSelection(position);
                    return true;
                }
            }
        }

        //         // For RecyclerView, we just need to scroll the next item into
        //         // view, so that the super logic can find that the next down/up
        //         // item exists.
        //         // A PreCachingLayoutManager might also fix this problem
        //         if (currentFocus != null &&
        //               currentFocus.getParent() instanceof RecyclerView) {
        //            RecyclerView rv = (RecyclerView) currentFocus.getParent();
        //            RecyclerView.Adapter adapter = rv.getAdapter();
        //            if (adapter instanceof FlexibleRecyclerAdapter) {
        //               int position = ((FlexibleRecyclerAdapter) adapter)
        //                     .getSelectedPosition();
        //               if (position >= 0) {
        //                  if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        //                     position--;
        //                  } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        //                     position++;
        //                  }
        //
        //                  if (position >= 0 && position < adapter.getItemCount()) {
        //                     rv.scrollToPosition(position);
        //                     Log.d(TAG, "handleBrokenListViewScrolling: DPAD HANDLED ");
        //                     return false;
        //                  }
        //               }
        //            }
        //         }
    }

    return false;
}

From source file:com.lib.media.widget.seekbar.VerticalSeekBar.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isEnabled()) {
        final boolean handled;
        int direction = 0;

        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_DOWN:
            direction = (mRotationAngle == ROTATION_ANGLE_CW_90) ? 1 : -1;
            handled = true;// w  w w. j  a  v  a2s . c o m
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            direction = (mRotationAngle == ROTATION_ANGLE_CW_270) ? 1 : -1;
            handled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            // move view focus to previous/next view
            return false;
        default:
            handled = false;
            break;
        }

        if (handled) {
            final int keyProgressIncrement = getKeyProgressIncrement();
            int progress = getProgress();

            progress += (direction * keyProgressIncrement);

            if (progress >= 0 && progress <= getMax()) {
                _setProgressFromUser(progress, true);
            }

            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.anl.wxb.jieqi.view.VerticalSeekBar.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isEnabled()) {
        final boolean handled;
        int direction = 0;

        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_DOWN:
            direction = (mRotationAngle == ROTATION_ANGLE_CW_90) ? 1 : -1;
            handled = true;//from ww w  .  j  av a  2s. c  o  m
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            direction = (mRotationAngle == ROTATION_ANGLE_CW_270) ? 1 : -1;
            handled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = true;
            break;
        default:
            handled = false;
            break;
        }

        if (handled) {
            final int keyProgressIncrement = getKeyProgressIncrement();
            int progress = getProgress();

            progress += (direction * keyProgressIncrement);

            if (progress >= 0 && progress <= getMax()) {
                setProgress(progress - keyProgressIncrement, true);
            }

            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:android.support.v17.leanback.widget.GridWidgetTest.java

protected void scrollToEnd(Runnable verify) throws Throwable {
    int key;/*from  w w  w .j a  va  2 s  .co  m*/
    if (mOrientation == BaseGridView.HORIZONTAL) {
        if (mGridView.getLayoutDirection() == ViewGroup.LAYOUT_DIRECTION_RTL) {
            key = KeyEvent.KEYCODE_DPAD_LEFT;
        } else {
            key = KeyEvent.KEYCODE_DPAD_RIGHT;
        }
    } else {
        key = KeyEvent.KEYCODE_DPAD_DOWN;
    }
    scroll(key, verify);
}