Java 类android.view.KeyEvent 实例源码

项目:buildAPKsApps    文件:CalibrateActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
      // Don't allow this value to go to 0. It shuts the screen off.
      if (minBrightness > 1) {
        minBrightness -= 1;
        updateDisplay();
        Util.setActivityBrightness(getWindow(), minBrightness);
      }
      return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
      if (minBrightness < 255) {
        minBrightness += 1;
        updateDisplay();
        Util.setActivityBrightness(getWindow(), minBrightness);
      }
      return true;
    default:
      return super.onKeyDown(keyCode, event);
  }
}
项目:FreeStreams-TVLauncher    文件:MainActivity.java   
/**
 * 顶部焦点获取
 *
 * @param keyCode
 * @param event
 * @return
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean focusFlag = false;
    for (View v : mViews) {
        if (v.isFocused()) {
            focusFlag = true;
        }
    }
    Log.d(TAG, "code:" + keyCode + " flag:" + focusFlag);
    if (focusFlag) {
        if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) {
            if (mCurrentIndex > 0) {
                mViews[--mCurrentIndex].requestFocus();
            }
            return true;
        } else if (KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
            if (mCurrentIndex < 2) {
                mViews[++mCurrentIndex].requestFocus();
            }
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}
项目:airboard    文件:AirBoard.java   
@Override
  public void onKey(int primaryCode, int[] keyCodes) {
      InputConnection ic = getCurrentInputConnection() ;
      playclick(primaryCode);
      switch (primaryCode) {
          case Keyboard.KEYCODE_DELETE:
              ic.deleteSurroundingText(1, 0);
              break;
          case Keyboard.KEYCODE_SHIFT:
              caps = !caps;
              keyboard.setShifted(caps);
              kv.invalidateAllKeys();
              break;
          case Keyboard.KEYCODE_DONE:
              ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
              break;
          default:
              char code = (char) primaryCode;
              if(Character.isLetter(code) && caps) {
                  code = Character.toUpperCase(code);
              }

              ic.commitText(String.valueOf(code), 1);
break;
      }
  }
项目:Bigbang    文件:KeyPressedTipViewController.java   
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
        String reason = intent.getStringExtra(SYSTEM_REASON);
        if (TextUtils.equals(reason, SYSTEM_HOME_KEY)) {
            //表示按了home键,程序到了后台
            if (currentKeyCode==KeyEvent.KEYCODE_HOME && isLongPressedHome){
                isLongPressedHome=false;
                return;
            }
        }else if(TextUtils.equals(reason, SYSTEM_HOME_KEY_LONG)){
            //表示长按home键,显示最近使用的程序列表
            if (currentKeyCode==KeyEvent.KEYCODE_APP_SWITCH && isLongPressedRecent){
                isLongPressedRecent=false;
                return;
            }
        }else {
            return;
        }
        refreshViewState(false);
    }
}
项目:keemob    文件:CordovaWebViewImpl.java   
@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_MENU:
            // TODO: Why are search and menu buttons handled separately?
            if (override) {
                boundKeyCodes.add(keyCode);
            } else {
                boundKeyCodes.remove(keyCode);
            }
            return;
        default:
            throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
    }
}
项目:mpr121-androidthings    文件:Mpr121InputDriver.java   
@Override
public void run() {
    try {
        int data = peripheralDevice.getTouched();

        for (int i = 0; i < Mpr121.NB_ELECTRODES; i++) {
            if ((data & (1 << i)) != 0) {
                if (!inputStatus[i]) {
                    Log.d(TAG, "#" + i + " touched");
                    inputStatus[i] = true;
                    emitInputEvents(keycodes[i], KeyEvent.ACTION_DOWN);
                }
            } else {
                if (inputStatus[i]) {
                    Log.d(TAG, "#" + i + " released");
                    inputStatus[i] = false;
                    emitInputEvents(keycodes[i], KeyEvent.ACTION_UP);
                }
            }
        }
    } catch (IOException e) {
        Log.e(TAG, "Error getting data from peripheral device", e);
    } finally {
        inputHandler.postDelayed(this, SOFTWAREPOLL_DELAY_MS);
    }
}
项目:Runnest    文件:ChallengeTest.java   
@Test
public void challengePressBackAndQuit() {
    onView(withId(R.id.search)).perform(click());
    onView(isRoot()).perform(waitForMatch(withId(R.id.empty_layout), UI_TEST_TIMEOUT));
    onView(isAssignableFrom(EditText.class)).perform(typeText("R"), pressKey(KeyEvent.KEYCODE_ENTER));

    tryIsDisplayed(withText("Runnest IHL"), UI_TEST_TIMEOUT);
    onView(withText("Runnest IHL")).perform(click());

    //Create challenge
    onView(isRoot()).perform(waitForMatch(withId(R.id.main_layout), UI_TEST_TIMEOUT));
    onView(withText(R.string.challenge)).perform(click());
    tryIsDisplayed(withId(R.id.define_challenge), UI_TEST_TIMEOUT);
    onView(withId(R.id.customize_positive_btn)).perform(click());

    //Wait
    Espresso.pressBack();
    tryIsDisplayed(withId(android.R.id.button1), UI_TEST_TIMEOUT);
    onView(withText(R.string.quit)).perform(click());
}
项目:cleaninsights-android-sdk    文件:PlaybackOverlayActivity.java   
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    PlaybackOverlayFragment playbackOverlayFragment = (PlaybackOverlayFragment) getFragmentManager().findFragmentById(R.id.playback_controls_fragment);
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY:
            playbackOverlayFragment.togglePlayback(false);
            return true;
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
            playbackOverlayFragment.togglePlayback(false);
            return true;
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            if (mPlaybackState == LeanbackPlaybackState.PLAYING) {
                playbackOverlayFragment.togglePlayback(false);
            } else {
                playbackOverlayFragment.togglePlayback(true);
            }
            return true;
        default:
            return super.onKeyUp(keyCode, event);
    }
}
项目:keemob    文件:CordovaWebViewImpl.java   
@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_MENU:
            // TODO: Why are search and menu buttons handled separately?
            if (override) {
                boundKeyCodes.add(keyCode);
            } else {
                boundKeyCodes.remove(keyCode);
            }
            return;
        default:
            throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
    }
}
项目:Sega    文件:ViewPagerEx.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.
 *
 * @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;
}
项目:yyox    文件:EmoticonsKeyBoard.java   
public boolean dispatchKeyEventInFullScreen(KeyEvent event) {

        if (event == null) return false;
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_BACK:
                if (EmoticonsKeyboardUtils.isFullScreen((Activity) getContext()) && mLayoutKVML.isShown()) {
                    reset();
                    return true;
                }
            default:
                if (event.getAction() == KeyEvent.ACTION_DOWN) {
                    boolean isFocused;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        isFocused = mIMLayout.getETChat().getShowSoftInputOnFocus();
                    } else {
                        isFocused = mIMLayout.getETChat().isFocused();
                    }
                    if (isFocused)
                        mIMLayout.getETChat().onKeyDown(event.getKeyCode(), event);
                }
        }
        return false;
    }
项目:AliZhiBoHao    文件:WebActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
        if (mWebView.getUrl().equals(INDEXURL)) {
            if (System.currentTimeMillis() - exitTime > 2000) {
                CommonUtils.showToast(this, getString(R.string.w_exit_app));
                exitTime = System.currentTimeMillis();
            } else {
                for (int i = 0; i < MyApplication.list.size(); i++) {
                    MyApplication.list.get(i).finish();
                }
            }
        } else {
            mWebView.goBack();
        }
    }
    return true;
}
项目:aos-Video    文件:Browser.java   
public boolean onKeyUp(int keyCode, KeyEvent event) {
    boolean ret = false;
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            // if (isChild() == true) {
            // final VideoBrowserActivity parent = (VideoBrowserActivity)
            // getParent();
            // parent.launchGlobalResume();
            // }
            ret = true;
    }

    // if (!ret)
    // ret = super.onKeyUp(keyCode, event);

    return ret;
}
项目:IdealMedia    文件:DiscreteSeekBar.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    //TODO: Should we reverse the keys for RTL? The framework's SeekBar does NOT....
    boolean handled = false;
    if (isEnabled()) {
        int progress = getAnimatedProgress();
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
                handled = true;
                if (progress <= mMin) break;
                animateSetProgress(progress - mKeyProgressIncrement);
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                handled = true;
                if (progress >= mMax) break;
                animateSetProgress(progress + mKeyProgressIncrement);
                break;
        }
    }

    return handled || super.onKeyDown(keyCode, event);
}
项目:AndroidOpen    文件:BottomPopup.java   
@Override
public final boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        return onKeyDown(keyCode, event);
    }
    return false;
}
项目:OSchina_resources_android    文件:TopicTweetActivity.java   
@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
//                if (!mDelegation.onTurnBack()) return true;
                break;
        }
        return super.onKeyDown(keyCode, event);
    }
项目:COB    文件:SystemWebView.java   
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    Boolean ret = parentEngine.client.onDispatchKeyEvent(event);
    if (ret != null) {
        return ret.booleanValue();
    }
    return super.dispatchKeyEvent(event);
}
项目:GitHub    文件:TechDetailActivity.java   
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && wvTechContent.canGoBack()) {
        wvTechContent.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:aos-Video    文件:ListingActivity.java   
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {

    // Quit file browsing on BACK long press
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        MultiBackHintManager.getInstance(this).onBackLongPressed();
        finish();
        return true;
    }
    else return super.onKeyLongPress(keyCode, event);
}
项目:BLPlayer    文件:IjkVideoView.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
            keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
            keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
            keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
            keyCode != KeyEvent.KEYCODE_MENU &&
            keyCode != KeyEvent.KEYCODE_CALL &&
            keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisiblity();
        }
    }

    return super.onKeyDown(keyCode, event);
}
项目:yyox    文件:OrderPaySuccessActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK
            && event.getRepeatCount() == 0) {
        setResult(CodeDefine.ORDER_PAY_RESULT);
        this.finish();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:boohee_v5.6    文件:MenuPopupHelper.java   
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() != 1 || keyCode != 82) {
        return false;
    }
    dismiss();
    return true;
}
项目:android-image-classification    文件:MainActivity.java   
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        debug = !debug;
        requestRender();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:CSipSimple    文件:ActionBarSherlockCompat.java   
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event);

    final int keyCode = event.getKeyCode();

    // Not handled by the view hierarchy, does the action bar want it
    // to cancel out of something special?
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        final int action = event.getAction();
        // Back cancels action modes first.
        if (mActionMode != null) {
            if (action == KeyEvent.ACTION_UP) {
                mActionMode.finish();
            }
            if (ActionBarSherlock.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
            return true;
        }

        // Next collapse any expanded action views.
        if (wActionBar != null && wActionBar.hasExpandedActionView()) {
            if (action == KeyEvent.ACTION_UP) {
                wActionBar.collapseActionView();
            }
            if (ActionBarSherlock.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
            return true;
        }
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning false");
    return false;
}
项目:cordova-vuetify    文件:SystemWebView.java   
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    Boolean ret = parentEngine.client.onDispatchKeyEvent(event);
    if (ret != null) {
        return ret.booleanValue();
    }
    return super.dispatchKeyEvent(event);
}
项目:androidtv-sample    文件:SearchActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // If there are no results found, press the left key to reselect the microphone
    if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && !mFragment.hasResults()) {
        mFragment.focusOnSearch();
    }
    return super.onKeyDown(keyCode, event);
}
项目:Underlined    文件:PopUpActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if (keyCode == KeyEvent.KEYCODE_BACK ) {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }

    return false;
}
项目:GearVRf-template    文件:Gvr.java   
@Override
                public void onEvent(GVRCursorController gvrCursorController) {
                    KeyEvent keyEvent = gvrCursorController.getKeyEvent();
                    if(keyEvent != null){
//                        mPickHandler.setClicked(keyEvent.getAction() == KeyEvent.ACTION_DOWN);
                    }
                }
项目:ceji_android    文件:ReadingFragment.java   
private boolean simulateButtonPress(int action, int idToSend, ImageButton buttonToClick ) {
    if ( action == KeyEvent.ACTION_DOWN ) {
        buttonToClick.setPressed(true);
    } else {
        buttonToClick.setPressed(false);
    }

    buttonToClick.invalidate();
    return true;
}
项目:VRPlayer    文件:PlayerView.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
            keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
            keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
            keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
            keyCode != KeyEvent.KEYCODE_MENU &&
            keyCode != KeyEvent.KEYCODE_CALL &&
            keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisiblity();
        }
    }
    return super.onKeyDown(keyCode, event);
}
项目:LaunchEnr    文件:PagedView.java   
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_SCROLL: {
                // Handle mouse (or ext. device) by shifting the page depending on the scroll
                final float vscroll;
                final float hscroll;
                if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                    vscroll = 0;
                    hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                } else {
                    vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                    hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
                }
                if (hscroll != 0 || vscroll != 0) {
                    boolean isForwardScroll = mIsRtl ? (hscroll < 0 || vscroll < 0)
                                                     : (hscroll > 0 || vscroll > 0);
                    if (isForwardScroll) {
                        scrollRight();
                    } else {
                        scrollLeft();
                    }
                    return true;
                }
            }
        }
    }
    return super.onGenericMotionEvent(event);
}
项目:eyeRS    文件:LoginActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
            && keyCode == KeyEvent.KEYCODE_BACK
            && event.getRepeatCount() == 0) {
        onBackPressed();
    }

    return super.onKeyDown(keyCode, event);
}
项目:TakeRest    文件:WebActivity.java   
public boolean onKeyDown(int keyCoder, KeyEvent event) {
    if (webview.canGoBack() && keyCoder == KeyEvent.KEYCODE_BACK) {
        webview.goBack();
        return true;
    } else if (!webview.canGoBack() && keyCoder == KeyEvent.KEYCODE_BACK) {
        onBackPressed();
    }
    return false;
}
项目:ChatExchange-old    文件:SpotlightView.java   
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (dismissOnBackPress && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            dismiss();
        }
        return true;
    }
    return super.dispatchKeyEvent(event);
}
项目:HiBangClient    文件:FriendActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if ((System.currentTimeMillis() - mExitTime) > 2000) {
            Toast.makeText(getApplicationContext(), "再按一次退出程序",
                    Toast.LENGTH_SHORT).show();
            mExitTime = System.currentTimeMillis();
        } else {
            this.finish();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:decoy    文件:InputPanel.java   
/**
 * *************** IEmojiSelectedListener ***************
 */
@Override
public void onEmojiSelected(String key) {
    Editable mEditable = messageEditText.getText();
    if (key.equals("/DEL")) {
        messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
    } else {
        int start = messageEditText.getSelectionStart();
        int end = messageEditText.getSelectionEnd();
        start = (start < 0 ? 0 : start);
        end = (start < 0 ? 0 : end);
        mEditable.replace(start, end, key);
    }
}
项目:PlusGram    文件:ChatAttachAlert.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (cameraOpened && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        shutterButton.getDelegate().shutterReleased();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:EpisodeListView    文件:EpisodeListView.java   
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (mParentView.hasFocus()) {
                    mChildrenView.requestFocus();
                    return true;
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (mChildrenView.hasFocus()) {
                    mParentView.requestFocus();
                    return true;
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (mChildrenView.hasFocus()
                        && mChildrenAdapter.getCurrentPosition() >= mChildrenAdapter.getData().size() - 1) {
                    return true;
                }
                if (mParentView.hasFocus()
                        && mParentAdapter.getCurrentPosition() >= mParentAdapter.getDatas().size() - 1) {
                    return true;
                }
        }
    }
    return super.dispatchKeyEvent(event);
}
项目:anyRTC-RTCP-Android    文件:LiveActivity.java   
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (!isPublish){
            rtcpKit.unSubscribe(strPeerId);
        }else {
            rtcpKit.unPublish();
        }
        finishAnimActivity();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
项目:xlight_android_native    文件:SoftKeyboardVisibilityDetectingLinearLayout.java   
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        // Keyboard is hidden
        if (isKeyboardShown) {
            isKeyboardShown = false;
            listener.onSoftKeyboardHidden();
        }
    }
    return super.dispatchKeyEventPreIme(event);
}