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:eu.kanade.tachiyomi.ui.reader.viewer.pager.vertical.VerticalViewPagerImpl.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.//from w ww .ja va 2 s . c o m * * @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; default: break; } } return handled; }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Collect.getInstance().getActivityLogger().logInstanceAction(this, "onKeyDown.KEYCODE_BACK", "quit"); createQuitDialog();//from w w w .j a v a 2s . com return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (event.isAltPressed() && !mBeenSwiped) { mBeenSwiped = true; Collect.getInstance().getActivityLogger().logInstanceAction(this, "onKeyDown.KEYCODE_DPAD_RIGHT", "showNext"); showNextView(); return true; } break; case KeyEvent.KEYCODE_DPAD_LEFT: if (event.isAltPressed() && !mBeenSwiped) { mBeenSwiped = true; Collect.getInstance().getActivityLogger().logInstanceAction(this, "onKeyDown.KEYCODE_DPAD_LEFT", "showPrevious"); showPreviousView(); return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
public void testBug27258366() throws Throwable { mInstrumentation = getInstrumentation(); Intent intent = new Intent(mInstrumentation.getContext(), GridActivity.class); intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.vertical_linear_with_button_onleft); intent.putExtra(GridActivity.EXTRA_CHILD_LAYOUT_ID, R.layout.horizontal_item); intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, 10); intent.putExtra(GridActivity.EXTRA_STAGGERED, false); intent.putExtra(GridActivity.EXTRA_UPDATE_SIZE, false); initActivity(intent);//from ww w . jav a 2 s. c o m mOrientation = BaseGridView.VERTICAL; mNumRows = 1; // move item1 500 pixels right, when focus is on item1, default focus finder will pick // item0 and item2 for the best match of focusSearch(FOCUS_LEFT). The grid widget // must override default addFocusables(), not to add item0 or item2. mActivity.mAdapterListener = new GridActivity.AdapterListener() { public void onBind(RecyclerView.ViewHolder vh, int position) { if (position == 1) { vh.itemView.setPaddingRelative(500, 0, 0, 0); } else { vh.itemView.setPaddingRelative(0, 0, 0, 0); } } }; runTestOnUiThread(new Runnable() { @Override public void run() { mGridView.getAdapter().notifyDataSetChanged(); } }); Thread.sleep(100); final ViewGroup secondChild = (ViewGroup) mGridView.getChildAt(1); runTestOnUiThread(new Runnable() { @Override public void run() { secondChild.requestFocus(); } }); sendKeys(KeyEvent.KEYCODE_DPAD_LEFT); Thread.sleep(100); final View button = mActivity.findViewById(R.id.button); assertTrue(button.isFocused()); }
From source file:cn.androidy.materialdesignsample.ryanharterviewpager.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.//from w ww.j a va2 s . c om * * @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; }
From source file:com.guide.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.// w w w .j a v a2 s .c o m * * @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; }
From source file:android.improving.utils.views.cardsview.OrientedViewPager.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./*from w ww . ja v a2 s.c o m*/ * * @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; }
From source file:com.glview.widget.AbsListView.java
/** * Sends a key to the text filter window * * @param keyCode The keycode for the event * @param event The actual key event/*w ww . ja va2 s .com*/ * * @return True if the text filter handled the event, false otherwise. */ boolean sendToTextFilter(int keyCode, int count, KeyEvent event) { if (!acceptFilter()) { return false; } boolean handled = false; boolean okToSend = true; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: okToSend = false; break; case KeyEvent.KEYCODE_BACK: okToSend = false; break; case KeyEvent.KEYCODE_SPACE: // Only send spaces once we are filtered okToSend = mFiltered; break; } if (okToSend) { KeyEvent forwardEvent = event; if (forwardEvent.getRepeatCount() > 0) { forwardEvent = KeyEvent.changeTimeRepeat(event, event.getEventTime(), 0); } int action = event.getAction(); switch (action) { case KeyEvent.ACTION_DOWN: break; case KeyEvent.ACTION_UP: break; case KeyEvent.ACTION_MULTIPLE: break; } } return handled; }
From source file:com.appunite.list.AbsHorizontalListView.java
/** * Sends a key to the text filter window * * @param keyCode The keycode for the event * @param event The actual key event//w ww. j av a 2 s. c o m * * @return True if the text filter handled the event, false otherwise. */ boolean sendToTextFilter(int keyCode, int count, KeyEvent event) { if (!acceptFilter()) { return false; } boolean handled = false; boolean okToSend = true; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: okToSend = false; break; case KeyEvent.KEYCODE_BACK: if (mFiltered && mPopup != null && mPopup.isShowing()) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { state.startTracking(event, this); } handled = true; } else if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking() && !event.isCanceled()) { handled = true; mTextFilter.setText(""); } } okToSend = false; break; case KeyEvent.KEYCODE_SPACE: // Only send spaces once we are filtered okToSend = mFiltered; break; } if (okToSend) { createTextFilter(true); KeyEvent forwardEvent = event; if (forwardEvent.getRepeatCount() > 0) { forwardEvent = KeyEvent.changeTimeRepeat(event, event.getEventTime(), 0); } int action = event.getAction(); switch (action) { case KeyEvent.ACTION_DOWN: handled = mTextFilter.onKeyDown(keyCode, forwardEvent); break; case KeyEvent.ACTION_UP: handled = mTextFilter.onKeyUp(keyCode, forwardEvent); break; case KeyEvent.ACTION_MULTIPLE: handled = mTextFilter.onKeyMultiple(keyCode, count, event); break; } } return handled; }