List of usage examples for android.view KeyEvent KEYCODE_DPAD_RIGHT
int KEYCODE_DPAD_RIGHT
To view the source code for android.view KeyEvent KEYCODE_DPAD_RIGHT.
Click Source Link
From source file:com.mstar.tv.tvplayer.philips.option.OptionFirstFragment.java
public boolean onKeyDown(int keyCode, KeyEvent event) { int selectPositon = getSelectedItemPosition(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: break;//from w ww .ja va 2 s . co m case KeyEvent.KEYCODE_DPAD_RIGHT: if (selectPositon == -1) break; if (OptionKarrays.isFromLauncher) { if (selectPositon == 2 || selectPositon == 3) { mCallback.onFirstSelectedData(selectPositon); } } else { if (getSelectedItemPosition() != 2) mCallback.onFirstSelectedData(selectPositon); } break; } return false; }
From source file:com.volosyukivan.WiFiInputMethod.java
void sendKey(int code, boolean down, boolean resetModifiers) { long time = System.currentTimeMillis(); if (time - lastWake > 5000) { wakeLock.acquire();/*from w w w . j a v a 2 s . com*/ wakeLock.release(); lastWake = time; } InputConnection conn = getCurrentInputConnection(); if (conn == null) { // Debug.d("connection closed"); return; } if (code < 0) { if (down == false) return; switch (code) { case KEY_HOME: keyHome(conn); break; case KEY_END: keyEnd(conn); break; case KEY_DEL: keyDel(conn); break; } return; } if (code == KeyEvent.KEYCODE_DPAD_LEFT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordLeft(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_RIGHT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordRight(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_CENTER) { if (pressedKeys.contains(KEY_CONTROL)) { if (!down) return; copy(conn); return; } if (pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT)) { if (!down) return; paste(conn); return; } } // if (pressedKeys.contains(KEY_CONTROL)) { // if (down == false) return; // switch (code) { // case KeyEvent.KEYCODE_A: selectAll(conn); break; // case KeyEvent.KEYCODE_X: cut(conn); break; // case KeyEvent.KEYCODE_C: copy(conn); break; // case KeyEvent.KEYCODE_V: paste(conn); break; // } // return; // } conn.sendKeyEvent(new KeyEvent(down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP, code)); if (resetModifiers) { conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); } }
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
protected void scrollToEnd(Runnable verify) throws Throwable { int key;/*from ww w .ja v a 2 s . c o 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); }
From source file:org.opensilk.video.tv.ui.playback.PlaybackControlsFragment.java
@Override protected boolean onInterceptInputEvent(InputEvent event) { boolean hidden = areControlsHidden(); Timber.d("onInterceptInputEvent(%s) hidden = %s", event, hidden); boolean consumeEvent = false; boolean handled = false; int keyCode = KeyEvent.KEYCODE_UNKNOWN; if (event instanceof KeyEvent) { keyCode = ((KeyEvent) event).getKeyCode(); }/*from www . j ava2 s . c o m*/ switch (keyCode) { // case KeyEvent.KEYCODE_DPAD_CENTER: // case KeyEvent.KEYCODE_DPAD_DOWN: // case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: if (hidden) { if (((KeyEvent) event).getAction() == KeyEvent.ACTION_DOWN) { int delta = keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? -10000 : 15000; consumeEvent = seekDelta(delta); } handled = true; } break; } return handled ? consumeEvent : super.onInterceptInputEvent(event); }
From source file:com.oakesville.mythling.MediaPagerActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) { if ((getCurrentFocus().getParent() instanceof View && ((View) getCurrentFocus().getParent()).getId() == R.id.button_bar) || getCurrentFocus().getId() == R.id.title_text) { findViewById(R.id.pager_position).requestFocus(); return true; }//from ww w . ja v a 2s . c om } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) { if (getCurrentFocus().getId() == R.id.pager_position) { if (pager.getCurrentItem() < getListables().size() - 1) { pager.setCurrentItem(pager.getCurrentItem() + 1); positionBar.setProgress(pager.getCurrentItem()); return true; } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) { if (getCurrentFocus().getId() == R.id.pager_position) { if (pager.getCurrentItem() > 0) { pager.setCurrentItem(pager.getCurrentItem() - 1); positionBar.setProgress(pager.getCurrentItem()); return true; } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { pager.setCurrentItem(getListables().size() - 1); positionBar.setProgress(getListables().size() - 1); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_REWIND) { pager.setCurrentItem(0); positionBar.setProgress(0); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY) { Listable listable = getListables().get(pager.getCurrentItem()); if (listable instanceof Item) { playItem((Item) listable); return true; } } } return super.dispatchKeyEvent(event); }
From source file:org.mariotaku.harmony.activity.MusicPlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mService == null) return super.onKeyDown(keyCode, event); final int repcnt = event.getRepeatCount(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; }/* w w w. jav a2s .c o m*/ if (!mPrevButton.hasFocus()) { mPrevButton.requestFocus(); } scanBackward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!useDpadMusicControl()) { break; } if (!mNextButton.hasFocus()) { mNextButton.requestFocus(); } scanForward(repcnt, event.getEventTime() - event.getDownTime()); return true; // case KeyEvent.KEYCODE_R: // toggleRepeat(); // return true; // // case KeyEvent.KEYCODE_S: // toggleShuffle(); // return true; case KeyEvent.KEYCODE_N: { doNext(); return true; } case KeyEvent.KEYCODE_P: { doPrev(); return true; } case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: { doPauseResume(); return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.vuze.android.remote.fragment.FilesFragment.java
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {// w w w . j av a 2 s . com if (AndroidUtils.DEBUG) { Log.d(TAG, "onCreateview " + this); } View view = inflater.inflate(R.layout.frag_torrent_files, container, false); FragmentActivity activity = getActivity(); progressBar = (ProgressBar) activity.findViewById(R.id.details_progress_bar); viewAreaToggleEditMode = view.findViewById(R.id.files_area_toggleditmode); tvScrollTitle = (TextView) view.findViewById(R.id.files_scrolltitle); btnEditMode = (CompoundButton) view.findViewById(R.id.files_editmode); if (btnEditMode != null) { btnEditMode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (adapter == null) { return; } adapter.setInEditMode(btnEditMode.isChecked()); } }); } final SwipeRefreshLayoutExtra swipeRefresh = (SwipeRefreshLayoutExtra) view .findViewById(R.id.swipe_container); if (swipeRefresh != null) { swipeRefresh.setExtraLayout(R.layout.swipe_layout_extra); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (sessionInfo == null) { return; } showProgressBar(); sessionInfo.executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.getTorrentFileInfo(TAG, torrentID, null, new TorrentListReceivedListener() { @Override public void rpcTorrentListReceived(String callID, List<?> addedTorrentMaps, List<?> removedTorrentIDs) { AndroidUtils.runOnUIThread(FilesFragment.this, new Runnable() { @Override public void run() { swipeRefresh.setRefreshing(false); } }); } }); } }); } }); swipeRefresh.setOnExtraViewVisibilityChange(this); } listview = (RecyclerView) view.findViewById(R.id.files_list); listview.setLayoutManager(new PreCachingLayoutManager(getContext())); listview.setAdapter(adapter); listview.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: { // expand int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (!((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = true; adapter.getFilter().filter(""); return true; } } break; } case KeyEvent.KEYCODE_DPAD_LEFT: { // collapse int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = false; adapter.getFilter().filter(""); return true; } } break; } case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: { launchOrStreamFile(); return true; } } return false; } } }); listview.setOnScrollListener(new RecyclerView.OnScrollListener() { int firstVisibleItem = 0; @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LinearLayoutManager lm = (LinearLayoutManager) listview.getLayoutManager(); int firstVisibleItem = lm.findFirstCompletelyVisibleItemPosition(); if (firstVisibleItem != this.firstVisibleItem) { this.firstVisibleItem = firstVisibleItem; FilesAdapterDisplayObject itemAtPosition = adapter.getItem(firstVisibleItem); // Log.d(TAG, "itemAt" + firstVisibleItem + " is " + itemAtPosition); // Log.d(TAG, "tvScrollTitle=" + tvScrollTitle); // Log.d(TAG, "viewAreaToggleEditMode=" + viewAreaToggleEditMode); if (itemAtPosition == null) { return; } if (itemAtPosition.parent != null) { if (viewAreaToggleEditMode != null) { viewAreaToggleEditMode.setVisibility(View.GONE); } if (tvScrollTitle != null) { tvScrollTitle.setVisibility(View.VISIBLE); tvScrollTitle.setText(itemAtPosition.parent.folder); } } else { if (viewAreaToggleEditMode != null) { viewAreaToggleEditMode.setVisibility(View.VISIBLE); } if (tvScrollTitle != null) { if (viewAreaToggleEditMode != null) { tvScrollTitle.setVisibility(View.INVISIBLE); } tvScrollTitle.setText(""); } } } } }); FlexibleRecyclerSelectionListener rs = new FlexibleRecyclerSelectionListener<FilesTreeAdapter, FilesAdapterDisplayObject>() { @Override public void onItemSelected(FilesTreeAdapter adapter, final int position, boolean isChecked) { } @Override public void onItemClick(FilesTreeAdapter adapter, int position) { if (AndroidUtils.usesNavigationControl()) { FilesAdapterDisplayObject oItem = adapter.getItem(position); if (adapter.isInEditMode()) { adapter.flipWant(oItem); return; } if (oItem instanceof FilesAdapterDisplayFolder) { FilesAdapterDisplayFolder oFolder = (FilesAdapterDisplayFolder) oItem; oFolder.expand = !oFolder.expand; adapter.getFilter().filter(""); } else { showFileContextMenu(); } } } @Override public boolean onItemLongClick(FilesTreeAdapter adapter, int position) { if (AndroidUtils.usesNavigationControl()) { if (showFileContextMenu()) { return true; } } return false; } @Override public void onItemCheckedChanged(FilesTreeAdapter adapter, FilesAdapterDisplayObject item, boolean isChecked) { if (adapter.getCheckedItemCount() == 0) { finishActionMode(); } else { // Update the subtitle with file name showContextualActions(); } AndroidUtils.invalidateOptionsMenuHC(getActivity(), mActionMode); } }; adapter = new FilesTreeAdapter(this.getActivity(), rs); adapter.setSessionInfo(sessionInfo); adapter.setMultiCheckModeAllowed(false); adapter.setCheckOnSelectedAfterMS(100); listview.setAdapter(adapter); return view; }
From source file:com.mstar.tv.tvplayer.philips.setting.SettingFirstFragment.java
public boolean onKeyDown(int keyCode, KeyEvent event) { int position = getSelectedItemPosition(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: break;/* www .ja v a 2s. com*/ case KeyEvent.KEYCODE_DPAD_RIGHT: if (TvSettingMenuActivity.firstSelectPositon == SettingKarrays.SETTING_ECO) { if (getSelectedItemPosition() != 2) { mCallback.onFirstSelectedData(dataArray, getSelectedItemPosition()); } } else if (TvSettingMenuActivity.firstSelectPositon == SettingKarrays.SETTING_TV) { if (position != 0 && position != 6) {//yzh:5-->6 mCallback.onFirstSelectedData(dataArray, getSelectedItemPosition()); } } else if (TvSettingMenuActivity.firstSelectPositon == SettingKarrays.SETTING_CHANNEL) { if (position != 0 && position != 1) { mCallback.onFirstSelectedData(dataArray, getSelectedItemPosition()); } } else { mCallback.onFirstSelectedData(dataArray, getSelectedItemPosition()); } break; } return false; }
From source file:com.mstar.tv.tvplayer.philips.setting.SettingSliderFragment.java
public void updateView(String data, int dataPositon, boolean isPicShift) { firstSelect = TvSettingMenuActivity.firstSelectPositon; mIsPicShift = isPicShift;/*from w w w . j a v a 2 s. c o m*/ if (firstSelect == SettingKarrays.SETTING_PHOTO) { if (mIsPicShift) { //??? 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; } } else { switch (dataPositon) { case 1: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_CONTRAST); break; case 2: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_BRIGHTNESS); break; case 3: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_SATURATION); break; case 4: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_SHARPNESS); break; default: break; } } } else if (firstSelect == SettingKarrays.SETTING_SOUND) { switch (dataPositon) { case 1: currentIndex = K_TvAudioManager.getInstance().K_getBass(); break; case 2: currentIndex = K_TvAudioManager.getInstance().K_getTreble(); ; break; case 3: currentIndex = K_TvAudioManager.getInstance().K_getBalance(); break; default: break; } } else if (firstSelect == SettingKarrays.SETTING_ECO) { switch (dataPositon) { case 1: currentIndex = K_SettingModel.getInstance().K_getAjustBacklightIndex(mCotext); break; default: break; } } else if (firstSelect == SettingKarrays.SETTING_TV) { switch (dataPositon) { case 4: currentIndex = getSleepModeProgressIndex(); break; default: break; } } if (firstSelect == SettingKarrays.SETTING_TV && dataPositon == 4) { vseekbar_title.setText(data + mCotext.getResources().getString(R.string.minute)); seekBar.setMax(240); cursor_top.setText(240 + ""); cursor_center.setText(120 + ""); cursor_button.setText("0"); } else if (firstSelect == SettingKarrays.SETTING_SOUND && dataPositon == 3) { vseekbar_title.setText(data); seekBar.setMax(100); cursor_top.setText("R50"); cursor_center.setText("0"); cursor_button.setText("L50"); } else { vseekbar_title.setText(data); seekBar.setMax(100); cursor_top.setText(100 + ""); cursor_center.setText(50 + ""); cursor_button.setText("0"); } seekBar.setProgress(currentIndex); if (firstSelect == SettingKarrays.SETTING_SOUND && dataPositon == 3) { if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else { 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: if (firstSelect == SettingKarrays.SETTING_SOUND && flag == 3) { seekBar.incrementProgressBy(1); if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else if (firstSelect == SettingKarrays.SETTING_TV && flag == 4) { setSleepModeProgress(true); } else { 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: if (firstSelect == SettingKarrays.SETTING_SOUND && flag == 3) { seekBar.incrementProgressBy(-1); if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else if (firstSelect == SettingKarrays.SETTING_TV && flag == 4) { setSleepModeProgress(false); } else { 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; } private void setSleepModeProgress(boolean up) { int progress = 0; if (up) { switch (seekBar.getProgress()) { case 0: sleepMode = K_Constants.SLEEP_TIME_10MIN; progress = 10; break; case 10: sleepMode = K_Constants.SLEEP_TIME_20MIN; progress = 20; break; case 20: sleepMode = K_Constants.SLEEP_TIME_30MIN; progress = 30; break; case 30: sleepMode = K_Constants.SLEEP_TIME_60MIN; progress = 60; break; case 60: sleepMode = K_Constants.SLEEP_TIME_90MIN; progress = 90; break; case 90: sleepMode = K_Constants.SLEEP_TIME_120MIN; progress = 120; break; case 120: sleepMode = K_Constants.SLEEP_TIME_180MIN; progress = 180; break; case 180: sleepMode = K_Constants.SLEEP_TIME_240MIN; progress = 240; break; case 240: return; default: break; } } else { switch (seekBar.getProgress()) { case 240: sleepMode = K_Constants.SLEEP_TIME_180MIN; progress = 180; break; case 180: sleepMode = K_Constants.SLEEP_TIME_120MIN; progress = 120; break; case 120: sleepMode = K_Constants.SLEEP_TIME_90MIN; progress = 90; break; case 90: sleepMode = K_Constants.SLEEP_TIME_60MIN; progress = 60; break; case 60: sleepMode = K_Constants.SLEEP_TIME_30MIN; progress = 30; break; case 30: sleepMode = K_Constants.SLEEP_TIME_20MIN; progress = 20; break; case 20: sleepMode = K_Constants.SLEEP_TIME_10MIN; progress = 10; break; case 10: sleepMode = K_Constants.SLEEP_TIME_OFF; progress = 0; break; case 0: return; default: break; } } seekBar.setProgress(progress); progressVal.setText(String.valueOf(seekBar.getProgress())); } }); }
From source file:android.car.ui.provider.CarDrawerLayout.java
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent keyEvent) { int action = keyEvent.getAction(); int keyCode = keyEvent.getKeyCode(); final View drawerView = findDrawerView(); if (drawerView != null && getDrawerLockMode(drawerView) == LOCK_MODE_UNLOCKED) { if (isDrawerOpen()) { if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_SOFT_RIGHT) { closeDrawer();/*from w w w. ja va2s . com*/ return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && action == KeyEvent.ACTION_UP && mDrawerControllerListener != null) { mDrawerControllerListener.onBack(); return true; } else { return drawerView.dispatchKeyEvent(keyEvent); } } } return mContentView.dispatchKeyEvent(keyEvent); }