File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -469,6 +469,11 @@ public static final Formatter getTwoDigitFormatter() {
469469 */
470470 private final PressedStateHelper mPressedStateHelper ;
471471
472+ /**
473+ * The keycode of the last handled DPAD down event.
474+ */
475+ private int mLastHandledDownDpadKeyCode = -1 ;
476+
472477 /**
473478 * Interface to listen for changes of the current value.
474479 */
@@ -936,6 +941,31 @@ public boolean dispatchKeyEvent(KeyEvent event) {
936941 case KeyEvent .KEYCODE_ENTER :
937942 removeAllCallbacks ();
938943 break ;
944+ case KeyEvent .KEYCODE_DPAD_DOWN :
945+ case KeyEvent .KEYCODE_DPAD_UP :
946+ if (!mHasSelectorWheel ) {
947+ break ;
948+ }
949+ switch (event .getAction ()) {
950+ case KeyEvent .ACTION_DOWN :
951+ if (mWrapSelectorWheel || (keyCode == KeyEvent .KEYCODE_DPAD_UP )
952+ ? getValue () < getMaxValue () : getValue () > getMinValue ()) {
953+ requestFocus ();
954+ mLastHandledDownDpadKeyCode = keyCode ;
955+ removeAllCallbacks ();
956+ if (mFlingScroller .isFinished ()) {
957+ changeValueByOne (keyCode == KeyEvent .KEYCODE_DPAD_UP );
958+ }
959+ return true ;
960+ }
961+ break ;
962+ case KeyEvent .ACTION_UP :
963+ if (mLastHandledDownDpadKeyCode == keyCode ) {
964+ mLastHandledDownDpadKeyCode = -1 ;
965+ return true ;
966+ }
967+ break ;
968+ }
939969 }
940970 return super .dispatchKeyEvent (event );
941971 }
You can’t perform that action at this time.
0 commit comments