Example usage for android.view KeyEvent KEYCODE_DPAD_RIGHT

List of usage examples for android.view KeyEvent KEYCODE_DPAD_RIGHT

Introduction

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

Prototype

int KEYCODE_DPAD_RIGHT

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

Click Source Link

Document

Key code constant: Directional Pad Right key.

Usage

From source file:com.seuf.arseuf.arseuf.java

public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
        sendRequestToArduino("stop");
        break;//from   w w w  .ja  v  a  2s . c o  m
    case KeyEvent.KEYCODE_BUTTON_X:
        sendRequestToArduino("stop");
        break;
    case KeyEvent.KEYCODE_DPAD_LEFT:
        sendRequestToArduino("stopt");
        break;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        sendRequestToArduino("stopt");
        break;
    }
    return true;
}

From source file:Main.java

public static String getKeyNameByCode(int code) {
    switch (code) {
    case KeyEvent.KEYCODE_0:
        return "<0>";
    case KeyEvent.KEYCODE_1:
        return "<1>";
    case KeyEvent.KEYCODE_2:
        return "<2>";
    case KeyEvent.KEYCODE_3:
        return "<3>";
    case KeyEvent.KEYCODE_4:
        return "<4>";
    case KeyEvent.KEYCODE_5:
        return "<5>";
    case KeyEvent.KEYCODE_6:
        return "<6>";
    case KeyEvent.KEYCODE_7:
        return "<7>";
    case KeyEvent.KEYCODE_8:
        return "<8>";
    case KeyEvent.KEYCODE_9:
        return "<9>";
    case KeyEvent.KEYCODE_A:
        return "<A>";
    case KeyEvent.KEYCODE_B:
        return "<B>";
    case KeyEvent.KEYCODE_C:
        return "<C>";
    case KeyEvent.KEYCODE_D:
        return "<D>";
    case KeyEvent.KEYCODE_E:
        return "<E>";
    case KeyEvent.KEYCODE_F:
        return "<F>";
    case KeyEvent.KEYCODE_G:
        return "<G>";
    case KeyEvent.KEYCODE_H:
        return "<H>";
    case KeyEvent.KEYCODE_I:
        return "<I>";
    case KeyEvent.KEYCODE_J:
        return "<J>";
    case KeyEvent.KEYCODE_K:
        return "<K>";
    case KeyEvent.KEYCODE_L:
        return "<L>";
    case KeyEvent.KEYCODE_M:
        return "<M>";
    case KeyEvent.KEYCODE_N:
        return "<N>";
    case KeyEvent.KEYCODE_O:
        return "<O>";
    case KeyEvent.KEYCODE_P:
        return "<P>";
    case KeyEvent.KEYCODE_Q:
        return "<Q>";
    case KeyEvent.KEYCODE_R:
        return "<R>";
    case KeyEvent.KEYCODE_S:
        return "<S>";
    case KeyEvent.KEYCODE_T:
        return "<T>";
    case KeyEvent.KEYCODE_U:
        return "<U>";
    case KeyEvent.KEYCODE_V:
        return "<V>";
    case KeyEvent.KEYCODE_W:
        return "<W>";
    case KeyEvent.KEYCODE_X:
        return "<X>";
    case KeyEvent.KEYCODE_Y:
        return "<Y>";
    case KeyEvent.KEYCODE_Z:
        return "<Z>";
    case KeyEvent.KEYCODE_APOSTROPHE:
        return "<'>";
    case KeyEvent.KEYCODE_AT:
        return "<@>";
    case KeyEvent.KEYCODE_BACK:
        return "<Back>";
    case KeyEvent.KEYCODE_BACKSLASH:
        return "<\\>";
    case KeyEvent.KEYCODE_CALL:
        return "<Call>";
    case KeyEvent.KEYCODE_CAMERA:
        return "<Camera>";
    case KeyEvent.KEYCODE_CLEAR:
        return "<Clear>";
    case KeyEvent.KEYCODE_COMMA:
        return "<,>";
    case KeyEvent.KEYCODE_DEL:
        return "<Del>";
    case KeyEvent.KEYCODE_DPAD_CENTER:
        return "<PadCenter>";
    case KeyEvent.KEYCODE_DPAD_DOWN:
        return "<PadDown>";
    case KeyEvent.KEYCODE_DPAD_LEFT:
        return "<PadLeft>";
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        return "<PadRight>";
    case KeyEvent.KEYCODE_DPAD_UP:
        return "<PadUp>";
    case KeyEvent.KEYCODE_ENDCALL:
        return "<EndCall>";
    case KeyEvent.KEYCODE_ENTER:
        return "<Enter>";
    case KeyEvent.KEYCODE_ENVELOPE:
        return "<Envelope>";
    case KeyEvent.KEYCODE_EQUALS:
        return "<=>";
    case KeyEvent.KEYCODE_EXPLORER:
        return "<Explorer>";
    case KeyEvent.KEYCODE_FOCUS:
        return "<??? 0>";
    case KeyEvent.KEYCODE_GRAVE:
        return "<??? 1>";
    case KeyEvent.KEYCODE_HEADSETHOOK:
        return "<??? 2>";
    case KeyEvent.KEYCODE_HOME:
        return "<Home>";
    case KeyEvent.KEYCODE_LEFT_BRACKET:
        return "<(>";
    case KeyEvent.KEYCODE_MENU:
        return "<Menu>";
    case KeyEvent.KEYCODE_MINUS:
        return "<->";
    case KeyEvent.KEYCODE_NOTIFICATION:
        return "<??? 3>";
    case KeyEvent.KEYCODE_NUM:
        return "<Num>";
    case KeyEvent.KEYCODE_PERIOD:
        return "<??? 4>";
    case KeyEvent.KEYCODE_PLUS:
        return "<+>";
    case KeyEvent.KEYCODE_POUND:
        return "<??? 5>";
    case KeyEvent.KEYCODE_POWER:
        return "<Power>";
    case KeyEvent.KEYCODE_RIGHT_BRACKET:
        return "<)>";
    case KeyEvent.KEYCODE_SEMICOLON:
        return "<;>";
    case KeyEvent.KEYCODE_SLASH:
        return "</>";
    case KeyEvent.KEYCODE_SOFT_LEFT:
        return "<??? 6>";
    case KeyEvent.KEYCODE_SOFT_RIGHT:
        return "<??? 7>";
    case KeyEvent.KEYCODE_SPACE:
        return "<Space>";
    case KeyEvent.KEYCODE_STAR:
        return "<*>";
    case KeyEvent.KEYCODE_SYM:
        return "<Sym>";
    case KeyEvent.KEYCODE_TAB:
        return "<Tab>";
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        return "<VolumeDown>";
    case KeyEvent.KEYCODE_VOLUME_UP:
        return "<VolumeUp>";
    case KeyEvent.KEYCODE_UNKNOWN:
    default://from  w ww .  jav  a 2s .c o  m
        return "<Unknown>";
    }
}

From source file:android.support.v17.leanback.app.BrowseSupportFragmentTest.java

public void testTwoBackKeysWithoutBackStack() throws Throwable {
    mInstrumentation = getInstrumentation();
    Intent intent = new Intent(mInstrumentation.getContext(), BrowseSupportFragmentTestActivity.class);
    intent.putExtra(BrowseSupportFragmentTestActivity.EXTRA_LOAD_DATA_DELAY, (long) 1000);
    intent.putExtra(BrowseSupportFragmentTestActivity.EXTRA_ADD_TO_BACKSTACK, false);
    initActivity(intent);/*from   ww w  .ja va  2 s  . c  o m*/

    sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
    Thread.sleep(TRANSITION_LENGTH);

    sendKeys(KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_BACK);
}

From source file:com.cybrosys.basic.EventListener.java

@Override
public boolean onKey(View vwView, int keyCode, KeyEvent keyEvent) {
    int action = keyEvent.getAction();

    if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        boolean eat = mHandler.eatHorizontalMove(keyCode == KeyEvent.KEYCODE_DPAD_LEFT);
        return eat;
    }//from   w ww  .  ja v  a  2 s .  c o m
    if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
        return true;
    }
    if (keyEvent.getUnicodeChar() == '=') {
        if (action == KeyEvent.ACTION_UP) {
            mHandler.onEnter();
        }
        return true;
    }
    if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP
            && keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) {
        return false;
    }
    if (action == KeyEvent.ACTION_UP) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            mHandler.onEnter();
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
            mHandler.onUp();
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            mHandler.onDown();
            break;
        }
    }
    return true;
}

From source file:net.xpece.android.support.preference.SeekBarPreference.java

/**
 * Listener reacting to the user pressing DPAD left/right keys if {@code
 * adjustable} attribute is set to true; it transfers the key presses to the SeekBar
 * to be handled accordingly./*w  w  w  .  j  av  a 2s  .  c  o  m*/
 */
private View.OnKeyListener buildSeekBarKeyListener(final SeekBar seekBar) {
    return new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_DOWN) {
                return false;
            }

            if (!mAdjustable
                    && (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) {
                // Right or left keys are pressed when in non-adjustable mode; Skip the keys.
                return false;
            }

            // We don't want to propagate the click keys down to the seekbar view since it will
            // create the ripple effect for the thumb.
            if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
                return false;
            }

            if (seekBar == null) {
                Log.e(TAG, "SeekBar view is null and hence cannot be adjusted.");
                return false;
            }
            return seekBar.onKeyDown(keyCode, event);
        }
    };
}

From source file:com.mstar.tv.tvplayer.philips.setting.SettingMainFragment.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_LEFT:
        break;//  ww  w.ja  v  a2  s . c  o m
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        mCallback.onMainClick(listView.getSelectedItemPosition());
        settingAdapter.setSelectViewPosition(-1);
        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  . ja  va2 s .  c  o  m*/

        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:android.car.cluster.sample.MainClusterActivity.java

@Override
public void onKeyEvent(KeyEvent event) {
    Log.i(TAG, "onKeyEvent, event: " + event);
    dispatchKeyEvent(event); // TODO: dispatch event doesn't work for some reason.

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
            int nextItem = (mPager.getCurrentItem() + 1) % mButtonToFacet.size();
            mOrderToFacet.get(nextItem).button.requestFocus();
        } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
            int nextItem = (mPager.getCurrentItem() - 1);
            if (nextItem < 0)
                nextItem = mButtonToFacet.size() - 1;
            mOrderToFacet.get(nextItem).button.requestFocus();
        }/*from  w  w  w .  j  av  a 2  s .  c  om*/
    }
}

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;
    }// www. j a  v a2  s .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:com.mstar.tv.tvplayer.philips.option.OptionThirdFragment.java

public void updateView(String data, int dataPositon) {
    vseekbar_title.setText(data);//w  w  w .  jav  a2  s  .  c om
    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;
        }
    });
}