本文整理汇总了Java中android.view.KeyEvent.KEYCODE_VOLUME_DOWN属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_VOLUME_DOWN属性的具体用法?Java KeyEvent.KEYCODE_VOLUME_DOWN怎么用?Java KeyEvent.KEYCODE_VOLUME_DOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_VOLUME_DOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setButtonPlumbedToJs
@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);
}
}
示例2: dispatchKeyEvent
/**
* Clients can call this method to delegate handling of the volume. Clients should override
* {@code dispatchEvent} and call this method:
* <pre>
public boolean dispatchKeyEvent(KeyEvent event) {
if (mCastManager.onDispatchVolumeKeyEvent(event, VOLUME_DELTA)) {
return true;
}
return super.dispatchKeyEvent(event);
}
* </pre>
* @param event The dispatched event.
* @param volumeDelta The amount by which volume should be increased or decreased in each step
* @return <code>true</code> if volume is handled by the library, <code>false</code> otherwise.
*/
public boolean onDispatchVolumeKeyEvent(KeyEvent event, double volumeDelta) {
if (isConnected()) {
boolean isKeyDown = event.getAction() == KeyEvent.ACTION_DOWN;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (changeVolume(volumeDelta, isKeyDown)) {
return true;
}
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (changeVolume(-volumeDelta, isKeyDown)) {
return true;
}
break;
}
}
return false;
}
示例3: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
Toast.makeText(this, "Volume Up", Toast.LENGTH_LONG).show();
currentVolume += 0.1;
if (currentVolume >= 1) currentVolume = 1;
jobManager.addJobInBackground(new SetVolumeJob(currentVolume));
return true;
}
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
Toast.makeText(this, "Volume Down", Toast.LENGTH_LONG).show();
currentVolume -= 0.1;
if (currentVolume <= 0) currentVolume = 0;
jobManager.addJobInBackground(new SetVolumeJob(currentVolume));
return true;
}
return super.onKeyDown(keyCode, event);
}
示例4: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// Handle volume key usage for navigation
if (mSettings.useVolumeKeysForNavigation() && mPresenterVisible) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
onNextSlide();
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
onPrevSlide();
return true;
}
}
return super.onKeyUp(keyCode, event);
}
示例5: _isRunKey
boolean _isRunKey(int keyCode){
switch(keyCode){
case KeyEvent.KEYCODE_BUTTON_R1:
case KeyEvent.KEYCODE_BUTTON_R2:
case KeyEvent.KEYCODE_BUTTON_L1:
case KeyEvent.KEYCODE_BUTTON_L2:
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
return true;
default: return false;
}
}
示例6: 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);
}
示例7: onKeyDown
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
debug = !debug;
requestRender();
onSetDebug(debug);
return true;
}
return super.onKeyDown(keyCode, event);
}
示例8: 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_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);
}
示例9: onKeyDown
@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);
}
示例10: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_BACK:
Intent i=new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
Bundle bundle = new Bundle();
i.putExtra("currentfolder", currentfolder);
startActivity(i);
return true;
case KeyEvent.KEYCODE_MENU:
if (currentactivity == 1)
createToast(currentfolder);
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
vd_pressed = true;
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
if (volupholdur < 999999)
{
voluphold = System.currentTimeMillis();
volupholdur = 10000000;
}
return true;
}
return super.onKeyDown(keyCode, event);
}
示例11: onKeyUp
@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean navigate = defaultSharedPreferences.
getBoolean(SettingsFragment.PREF_USE_VOLUME_KEY_NAV, false);
boolean b = false;
if (navigate && keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
mTurnPageByVolumeDownKey = true;
b = true;
} else if (navigate && keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
mTurnPageByVolumeUpKey = true;
b = true;
}
return b || super.onKeyUp(keyCode, event);
}
示例12: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (mTocListPopupWindow != null && mTocListPopupWindow.isShowing()) {
mTocListPopupWindow.dismiss();
gone(mTvBookReadTocTitle);
visible(mTvBookReadReading, mTvBookReadCommunity, mTvBookReadChangeSource);
return true;
} else if (isVisible(rlReadAaSet)) {
gone(rlReadAaSet);
return true;
} else if (isVisible(mLlBookReadBottom)) {
hideReadBar();
return true;
} else if (!CollectionsManager.getInstance().isCollected(bookId)) {
showJoinBookShelfDialog(recommendBooks);
return true;
}
break;
case KeyEvent.KEYCODE_MENU:
toggleReadBar();
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (SettingManager.getInstance().isVolumeFlipEnable()) {
return true;
}
break;
case KeyEvent.KEYCODE_VOLUME_UP:
if (SettingManager.getInstance().isVolumeFlipEnable()) {
return true;
}
break;
default:
break;
}
return super.onKeyDown(keyCode, event);
}
示例13: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
if (action == KeyEvent.ACTION_DOWN) {
((AndroidCompatibility) Compatibility.get()).modifier = true;
} else if (action == KeyEvent.ACTION_UP) {
((AndroidCompatibility) Compatibility.get()).modifier = false;
}
}
return super.dispatchKeyEvent(event);
}
示例14: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
Log.d(THIS_FILE, "Key up : " + keyCode);
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_CALL:
case KeyEvent.KEYCODE_SEARCH:
return true;
case KeyEvent.KEYCODE_ENDCALL:
return inCallAnswerControls.onKeyDown(keyCode, event);
}
return super.onKeyUp(keyCode, event);
}
示例15: 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_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);
}