Example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN

List of usage examples for android.view KeyEvent KEYCODE_VOLUME_DOWN

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Prototype

int KEYCODE_VOLUME_DOWN

To view the source code for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Click Source Link

Document

Key code constant: Volume Down key.

Usage

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (useVolButtonChangePage) {
        //??/*  w  w w.j  av  a  2s .com*/
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (mViewPagerAdapter != null) {
                if (mViewPager.getCurrentItem() - 1 >= 0) {
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, false);
                } else {
                    openPrevChapter();
                }
            }
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (mViewPagerAdapter != null) {
                if (mViewPager.getCurrentItem() + 1 < mComicChapter.getPageCount()) {
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, false);
                } else {
                    openNextChapter();
                }
            }
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    final boolean result;

    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        // For onKeyLongPress to work
        event.startTracking();//from w  w w .j  av  a 2  s.  co  m
        result = !mApp.isLocalAudible();
    } else {
        result = super.onKeyDown(keyCode, event);
    }

    return result;
}

From source file:CookieVideoView.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();/*ww w . j a v a2  s.co m*/
                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);
}

From source file:com.BibleQuote.BibleQuoteAndroid.ui.ReaderActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == 0) {
        keyCode = event.getScanCode();/*from w  w  w. ja v  a2s  .c om*/
    }

    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP && PreferenceHelper.volumeButtonsToScroll())
            || DevicesKeyCodes.KeyCodeUp(keyCode)) {
        vWeb.pageUp(false);
        viewChapterNav();
        return true;
    } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && PreferenceHelper.volumeButtonsToScroll())
            || DevicesKeyCodes.KeyCodeDown(keyCode)) {
        vWeb.pageDown(false);
        viewChapterNav();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:cx.ring.fragments.CallFragment.java

public void onKeyUp(int keyCode, KeyEvent event) {
    try {//w  ww. j  a  va  2s .co  m

        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
            break;
        default:
            String toSend = Character.toString(event.getDisplayLabel());
            toSend = toSend.toUpperCase(Locale.getDefault());
            Log.d(TAG, "toSend " + toSend);
            mCallbacks.getRemoteService().playDtmf(toSend);
            break;
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (useVolButtonChangePage) {
        //??// www. j a va 2  s  .  co m
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (mViewPagerAdapter != null) {
                return true;
            }
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (mViewPagerAdapter != null) {
                return true;
            }
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
public boolean onKeyLongPress(final int keyCode, final KeyEvent event) {
    boolean result = true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        MPDControl.run(MPDControl.ACTION_NEXT);
        break;/*from   w w  w . ja  va2  s .  c  o  m*/
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        MPDControl.run(MPDControl.ACTION_PREVIOUS);
        break;
    default:
        result = super.onKeyLongPress(keyCode, event);
        break;
    }
    return result;
}

From source file:de.spiritcroc.modular_remote.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        return pages.get(viewPager.getCurrentItem()).onKeyUp(keyCode) || super.onKeyDown(keyCode, event);
    }//from w w w. j ava2s  .  c om

    return super.onKeyUp(keyCode, event);
}

From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();

    if (isAnimating() && action == KeyEvent.ACTION_DOWN) {
        stopAnimating();/*www  . j a v  a 2s  .  c o  m*/
        return true;
    }

    switch (keyCode) {

    case KeyEvent.KEYCODE_VOLUME_DOWN:
        // Yes, this is nasty: if the setting is true, we fall through to
        // the next case.
        if (!config.isVolumeKeyNavEnabled()) {
            return false;
        }

    case KeyEvent.KEYCODE_DPAD_RIGHT:

        if (action == KeyEvent.ACTION_DOWN) {
            pageDown(Orientation.HORIZONTAL);
        }

        return true;

    case KeyEvent.KEYCODE_VOLUME_UP:
        // Same dirty trick.
        if (!config.isVolumeKeyNavEnabled()) {
            return false;
        }

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (action == KeyEvent.ACTION_DOWN) {
            pageUp(Orientation.HORIZONTAL);
        }

        return true;

    case KeyEvent.KEYCODE_BACK:
        if (action == KeyEvent.ACTION_DOWN) {

            if (titleBarLayout.getVisibility() == View.VISIBLE) {
                hideTitleBar();
            } else if (bookView.hasPrevPosition()) {
                bookView.goBackInHistory();

                return true;
            } else {
                this.finish();
            }
        }

    }

    return false;
}

From source file:com.mobilevue.vod.VideoControllerView.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayer == null) {
        return true;
    }//w ww .j  a  v a2s .c  o  m

    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);
}