List of usage examples for android.view KeyEvent KEYCODE_DPAD_LEFT
int KEYCODE_DPAD_LEFT
To view the source code for android.view KeyEvent KEYCODE_DPAD_LEFT.
Click Source Link
From source file:com.vuze.android.remote.AndroidUtilsUI.java
public static boolean handleCommonKeyDownEvents(Activity a, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; }/* ww w . j a v a 2 s . co m*/ switch (keyCode) { case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: { ViewGroup vg = (ViewGroup) a.findViewById(android.R.id.content); ArrayList list = AndroidUtilsUI.findByClass(vg, ViewPager.class, new ArrayList<View>(0)); if (list.size() > 0) { ViewPager viewPager = (ViewPager) list.get(0); viewPager.arrowScroll(View.FOCUS_RIGHT); } break; } case KeyEvent.KEYCODE_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_REWIND: { ViewGroup vg = (ViewGroup) a.findViewById(android.R.id.content); ArrayList list = AndroidUtilsUI.findByClass(vg, ViewPager.class, new ArrayList<View>(0)); if (list.size() > 0) { ViewPager viewPager = (ViewPager) list.get(0); viewPager.arrowScroll(View.FOCUS_LEFT); } break; } case KeyEvent.KEYCODE_DPAD_LEFT: { if (a instanceof DrawerActivity) { DrawerActivity da = (DrawerActivity) a; DrawerLayout drawerLayout = da.getDrawerLayout(); View viewFocus = a.getCurrentFocus(); boolean canOpenDrawer = viewFocus != null && "leftmost".equals(viewFocus.getTag()); if (canOpenDrawer) { drawerLayout.openDrawer(Gravity.LEFT); drawerLayout.requestFocus(); return true; } } break; } } return false; }
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./*from ww w . j a v a 2 s .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;/*from w ww . ja v a2 s . com*/ case KeyEvent.KEYCODE_DPAD_RIGHT: mCallback.onMainClick(listView.getSelectedItemPosition()); settingAdapter.setSelectViewPosition(-1); break; } return false; }
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 www .j a va 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; }//from w ww .j a v a 2 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.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); }//w w w .j av a2s . com 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.mstar.tv.tvplayer.philips.option.OptionThirdFragment.java
public void updateView(String data, int dataPositon) { vseekbar_title.setText(data);//from w w w . j a va 2 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.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 .ja v a2 s.c om*/ 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:ar.rulosoft.custompref.SeekBarCustomPreference.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (isEnabled()) { if (event.getAction() != KeyEvent.ACTION_UP) { int increment = mKeyProgressIncrement; switch (keyCode) { case KeyEvent.KEYCODE_PLUS: case KeyEvent.KEYCODE_EQUALS: setProgress(getProgress() + increment); return true; case KeyEvent.KEYCODE_MINUS: setProgress(getProgress() - increment); return true; case KeyEvent.KEYCODE_DPAD_LEFT: increment = -increment;/*from w ww .ja v a 2 s. c om*/ // fallthrough case KeyEvent.KEYCODE_DPAD_RIGHT: increment = ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL ? -increment : increment; setProgress(getProgress() + increment); return true; } } } return false; }
From source file:com.vuze.android.remote.fragment.OpenOptionsFilesFragment.java
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {// www.ja va2 s .c om if (AndroidUtils.DEBUG) { Log.d(TAG, "onCreateview " + this); } FragmentActivity activity = getActivity(); Intent intent = activity.getIntent(); final Bundle extras = intent.getExtras(); if (extras == null) { Log.e(TAG, "No extras!"); } else { String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY); if (remoteProfileID != null) { sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, activity); } torrentID = extras.getLong("TorrentID"); } Map<?, ?> torrent = sessionInfo.getTorrent(torrentID); if (torrent == null) { // In theory TorrentOpenOptionsActivity handled this NPE already return null; } View topView = inflater.inflate(R.layout.frag_fileselection, container, false); tvScrollTitle = (TextView) topView.findViewById(R.id.files_scrolltitle); tvSummary = (TextView) topView.findViewById(R.id.files_summary); listview = (RecyclerView) topView.findViewById(R.id.files_list); listview.setLayoutManager(new PreCachingLayoutManager(getContext())); listview.setAdapter(adapter); FlexibleRecyclerSelectionListener rs = new FlexibleRecyclerSelectionListener<FilesTreeAdapter, FilesAdapterDisplayObject>() { @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(""); } } } @Override public boolean onItemLongClick(FilesTreeAdapter adapter, int position) { return false; } @Override public void onItemSelected(FilesTreeAdapter adapter, int position, boolean isChecked) { } @Override public void onItemCheckedChanged(FilesTreeAdapter adapter, FilesAdapterDisplayObject item, boolean isChecked) { } }; adapter = new FilesTreeAdapter(this.getActivity(), rs); adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeChanged(int positionStart, int itemCount) { if (tvSummary != null) { tvSummary.setText(DisplayFormatters.formatByteCountToKiBEtc(adapter.getTotalSizeWanted())); } } @Override public void onChanged() { super.onChanged(); if (tvSummary != null) { tvSummary.setText(DisplayFormatters.formatByteCountToKiBEtc(adapter.getTotalSizeWanted())); } } }); adapter.setInEditMode(true); adapter.setSessionInfo(sessionInfo); adapter.setCheckOnSelectedAfterMS(0); 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; } } 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); if (itemAtPosition == null) { return; } if (itemAtPosition.parent != null) { if (tvScrollTitle != null) { tvScrollTitle.setText(itemAtPosition.parent.folder); } } else { if (tvScrollTitle != null) { tvScrollTitle.setText(""); } } } } }); if (torrent.containsKey("files")) { adapter.setTorrentID(torrentID); } else { 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(OpenOptionsFilesFragment.this, new Runnable() { @Override public void run() { adapter.setTorrentID(torrentID); } }); } }); } }); } if (AndroidUtils.DEBUG) { Log.d(TAG, "set " + adapter + " for " + listview + " to " + sessionInfo + "/" + torrentID); } return topView; }