当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.KEYCODE_SPACE属性代码示例

本文整理汇总了Java中android.view.KeyEvent.KEYCODE_SPACE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_SPACE属性的具体用法?Java KeyEvent.KEYCODE_SPACE怎么用?Java KeyEvent.KEYCODE_SPACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_SPACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0
            && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
        doPauseResume();
        show(sDefaultTimeout);
        if (mPauseButton != null)
            mPauseButton.requestFocus();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
        if (mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK
            || keyCode == KeyEvent.KEYCODE_MENU) {
        hide();
        return true;
    } else {
        show(sDefaultTimeout);
    }
    return super.dispatchKeyEvent(event);
}
 
开发者ID:pili-engineering,项目名称:PLDroidShortVideo,代码行数:26,代码来源:MediaController.java

示例2: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  int keyCode = event.getKeyCode();
  if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
    doPauseResume();
    show(sDefaultTimeout);
    if (mPauseButton != null)
      mPauseButton.requestFocus();
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
    if (mPlayer.isPlaying()) {
      mPlayer.pause();
      updatePausePlay();
    }
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
    hide();
    return true;
  } else {
    show(sDefaultTimeout);
  }
  return super.dispatchKeyEvent(event);
}
 
开发者ID:Leavessilent,项目名称:QuanMinTV,代码行数:23,代码来源:MediaController.java

示例3: onKeyDown

@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_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
        || keyCode == KeyEvent.KEYCODE_SPACE) {
      if (mMediaPlayer.isPlaying()) {
        pause();
        mMediaController.show();
      } else {
        start();
        mMediaController.hide();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
        && mMediaPlayer.isPlaying()) {
      pause();
      mMediaController.show();
    } else {
      toggleMediaControlsVisiblity();
    }
  }

  return super.onKeyDown(keyCode, event);
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:33,代码来源:VideoPlayerView.java

示例4: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

  int keyCode = event.getKeyCode();
  if (event.getRepeatCount() == 0
      && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
      || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
    doPauseResume();
    show(sDefaultTimeout);
    if (mPauseButton != null && mTvPlay != null) {
      mPauseButton.requestFocus();
      mTvPlay.requestFocus();
    }
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
    if (mPlayer.isPlaying()) {
      mPlayer.pause();
      updatePausePlay();
    }
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_BACK
      || keyCode == KeyEvent.KEYCODE_MENU) {
    hide();
    return true;
  } else {
    show(sDefaultTimeout);
  }
  return super.dispatchKeyEvent(event);
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:29,代码来源:MediaController.java

示例5: onKeyDown

@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_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
                || keyCode == KeyEvent.KEYCODE_SPACE){
            if (mMediaPlayer.isPlaying()){
                pause();
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP && mMediaPlayer.isPlaying()){
            pause();
            mMediaController.show();
        } else
            toggleMediaControlsVisibility();
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:28,代码来源:VideoPlayerView.java

示例6: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SPACE) {
        // Turn on the LED
        setLedValue(true);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
开发者ID:googlecodelabs,项目名称:androidthings-peripherals,代码行数:10,代码来源:HomeActivity.java

示例7: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SPACE) {
        // Turn off the LED
        setLedValue(false);
        return true;
    }

    return super.onKeyUp(keyCode, event);
}
 
开发者ID:googlecodelabs,项目名称:androidthings-peripherals,代码行数:10,代码来源:HomeActivity.java

示例8: executeKeyEvent

@Override
public boolean executeKeyEvent(KeyEvent event) {
    // Ignore all key events except arrow keys and spacebar. Otherwise, the ScrollView consumes
    // unwanted events (including the hardware menu button and app-level keyboard shortcuts).
    // http://crbug.com/308322
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_SPACE:
            return super.executeKeyEvent(event);
        default:
            return false;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:NewTabPageScrollView.java

示例9: onKeyDown

@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_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 || keyCode == KeyEvent.KEYCODE_SPACE) {
      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);
}
 
开发者ID:Leavessilent,项目名称:QuanMinTV,代码行数:32,代码来源:VideoView.java

示例10: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayerCtrl == null) {
        return true;
    }

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0
            && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode ==  KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(DEFTIMEOUT);
            if (mBtnPause != null) {
                mBtnPause.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayerCtrl.isPlaying()) {
            mPlayerCtrl.start();
            updatePausePlay();
            show(DEFTIMEOUT);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayerCtrl.isPlaying()) {
            mPlayerCtrl.pause();
            updatePausePlay();
            show(DEFTIMEOUT);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(DEFTIMEOUT);
    return super.dispatchKeyEvent(event);
}
 
开发者ID:natjs,项目名称:nat-media-video,代码行数:50,代码来源:Controller.java

示例11: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayer == null) {
        return true;
    }

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0
            && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(sDefaultTimeout);
            if (mPauseButton != null) {
                mPauseButton.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayer.isPlaying()) {
            mPlayer.start();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:50,代码来源:VideoControllerView.java

示例12: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayer == null) {
        return true;
    }

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0
            && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode ==  KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(sDefaultTimeout);
            if (mPauseButton != null) {
                mPauseButton.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayer.isPlaying()) {
            mPlayer.start();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
}
 
开发者ID:mo3rfan,项目名称:syncplayer,代码行数:50,代码来源:VideoControllerView.java

示例13: isTab

private static boolean isTab(KeyEvent event){
	return (event.isShiftPressed() &&
				(event.getKeyCode() == KeyEvent.KEYCODE_SPACE)) ||
			(event.getKeyCode() == KeyEvent.KEYCODE_TAB);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:5,代码来源:KeysInterpreter.java

示例14: isSpace

private static boolean isSpace(KeyEvent event) {
	return (event.getKeyCode() == KeyEvent.KEYCODE_SPACE);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:3,代码来源:KeysInterpreter.java

示例15: decodeHardwareKey

@Override
public Event decodeHardwareKey(final KeyEvent keyEvent) {
    // KeyEvent#getUnicodeChar() does not exactly returns a unicode char, but rather a value
    // that includes both the unicode char in the lower 21 bits and flags in the upper bits,
    // hence the name "codePointAndFlags". {@see KeyEvent#getUnicodeChar()} for more info.
    final int codePointAndFlags = keyEvent.getUnicodeChar();
    // The keyCode is the abstraction used by the KeyEvent to represent different keys that
    // do not necessarily map to a unicode character. This represents a physical key, like
    // the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
    final int keyCode = keyEvent.getKeyCode();
    final boolean isKeyRepeat = (0 != keyEvent.getRepeatCount());
    if (KeyEvent.KEYCODE_DEL == keyCode) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE,
                null /* next */, isKeyRepeat);
    }
    if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode
            || KeyEvent.KEYCODE_ENTER == keyCode) {
        if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
            // A dead key.
            return Event.createDeadEvent(
                    codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, keyCode,
                    null /* next */);
        }
        if (KeyEvent.KEYCODE_ENTER == keyCode) {
            // The Enter key. If the Shift key is not being pressed, this should send a
            // CODE_ENTER to trigger the action if any, or a carriage return otherwise. If the
            // Shift key is being pressed, this should send a CODE_SHIFT_ENTER and let
            // Latin IME decide what to do with it.
            if (keyEvent.isShiftPressed()) {
                return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,
                        Constants.CODE_SHIFT_ENTER, null /* next */, isKeyRepeat);
            }
            return Event.createHardwareKeypressEvent(Constants.CODE_ENTER, keyCode,
                    null /* next */, isKeyRepeat);
        }
        // If not Enter, then this is just a regular keypress event for a normal character
        // that can be committed right away, taking into account the current state.
        return Event.createHardwareKeypressEvent(codePointAndFlags, keyCode, null /* next */,
                isKeyRepeat);
    }
    return Event.createNotHandledEvent();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:42,代码来源:HardwareKeyboardEventDecoder.java


注:本文中的android.view.KeyEvent.KEYCODE_SPACE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。