Java Code Examples for android.view.KeyEvent#KEYCODE_B

The following examples show how to use android.view.KeyEvent#KEYCODE_B . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhotoPlayerActivity.java    From jellyfin-androidtv with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_B:
            if (mPopupPanelVisible) {
                hideThumbPanel();
                return true;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (!mPopupPanelVisible && MediaManager.hasNextMediaItem()) {
                if (isLoadingNext || isTransitioning)
                    return true; //swallow too fast requests
                if (isPlaying) {
                    stop();
                    play();
                } else {
                    next(750);
                }
                return true;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (!mPopupPanelVisible && MediaManager.hasPrevMediaItem()) {
                if (isLoadingPrev || isTransitioning)
                    return true; //swallow too fast requests
                if (isPlaying) stop();
                currentPhoto = MediaManager.prevMedia().getBaseItem();
                nextImage.setImageDrawable(currentImageView().getDrawable());
                nextImageView().setImageDrawable(prevImage.getDrawable());
                transition(750);
                loadPrev();
                return true;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (mPopupPanelVisible) hideThumbPanel();
            else showThumbPanel();
            return true;

        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY:
            if (handlePlayKey())
                return true;
            break;

        case KeyEvent.KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_STOP:
            stop();
            return true;
    }

    return super.onKeyUp(keyCode, event);
}