Example usage for android.view KeyEvent KEYCODE_PROG_GREEN

List of usage examples for android.view KeyEvent KEYCODE_PROG_GREEN

Introduction

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

Prototype

int KEYCODE_PROG_GREEN

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

Click Source Link

Document

Key code constant: Green "programmable" key.

Usage

From source file:com.vuze.android.remote.activity.TorrentViewActivity.java

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

    if (AndroidUtilsUI.sendOnKeyToFragments(this, keyCode, event)) {
        return true;
    }/*from w w w  . ja v  a2 s. c o m*/

    switch (keyCode) {
    case KeyEvent.KEYCODE_MEDIA_PLAY:
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: {

        TorrentDetailsFragment detailFrag = (TorrentDetailsFragment) getSupportFragmentManager()
                .findFragmentById(R.id.frag_torrent_details);
        View fragmentView = findViewById(R.id.frag_details_container);

        if (detailFrag != null && fragmentView != null && fragmentView.getVisibility() == View.VISIBLE) {
            detailFrag.playVideo();

        } else {
            TorrentListFragment frag = (TorrentListFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.frag_torrent_list);
            if (frag != null) {
                frag.startStopTorrents();
            }
        }
        return true;
    }

    case KeyEvent.KEYCODE_PROG_YELLOW: {
        getDrawerLayout().openDrawer(Gravity.LEFT);
        return true;
    }

    case KeyEvent.KEYCODE_PROG_GREEN: {
        Log.d(TAG, "CurrentFocus is " + getCurrentFocus());
        break;
    }

    default:
        if (AndroidUtilsUI.handleCommonKeyDownEvents(this, keyCode, event)) {
            return true;
        }
        if (DEBUG) {
            Log.d(TAG, "Didn't handle key " + keyCode + ";" + event + ";focus=" + getCurrentFocus());
        }

        if (AndroidUtilsUI.handleBrokenListViewScrolling(this, keyCode)) {
            return true;
        }

        break;
    }
    return super.onKeyDown(keyCode, event);
}