Example usage for android.view KeyEvent KEYCODE_MENU

List of usage examples for android.view KeyEvent KEYCODE_MENU

Introduction

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

Prototype

int KEYCODE_MENU

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

Click Source Link

Document

Key code constant: Menu key.

Usage

From source file:org.thomasamsler.android.flashcards.activity.MainActivity.java

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

    super.onKeyUp(keyCode, event);

    if (keyCode == KeyEvent.KEYCODE_MENU) {

        mMainApplication.doAction(ACTION_SHOW_OVERFLOW_ACTIONS);
    }/*  w  w w  .ja  va 2  s  .  c  o  m*/

    return true;
}

From source file:us.nineworlds.serenity.ui.browser.tv.seasons.TVShowSeasonBrowserActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean menuKeySlidingMenu = PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean("remote_control_menu", true);
    if (menuKeySlidingMenu) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            if (drawerLayout.isDrawerOpen(linearDrawerLayout)) {
                drawerLayout.closeDrawers();
            } else {
                drawerLayout.openDrawer(linearDrawerLayout);
            }//www  .  j av a2  s .  c  o m
            return true;
        }
    }

    if (keyCode == KeyEvent.KEYCODE_BACK && drawerLayout.isDrawerOpen(linearDrawerLayout)) {
        drawerLayout.closeDrawers();
        if (tvShowSeasonsGallery != null) {
            tvShowSeasonsGallery.requestFocusFromTouch();
        }
        return true;
    }

    View focusView = getCurrentFocus();

    SerenityGallery gallery = (SerenityGallery) findViewById(R.id.tvShowSeasonImageGallery);
    TwoWayGridView gridView = (TwoWayGridView) findViewById(R.id.episodeGridView);
    if (gridView == null) {
        gridView = (TwoWayGridView) findViewById(R.id.tvShowGridView);
    }

    if (gallery == null && gridView == null) {
        return super.onKeyDown(keyCode, event);
    }

    BaseAdapter adapter = null;
    if (focusView instanceof TwoWayGridView) {
        adapter = (BaseAdapter) gridView.getAdapter();
    } else {
        adapter = (BaseAdapter) gallery.getAdapter();
    }

    if (adapter != null) {
        int itemsCount = adapter.getCount();

        if (contextMenuRequested(keyCode)) {
            View view = null;
            if (focusView instanceof TwoWayGridView) {
                view = gridView.getSelectedView();
            } else if (gallery != null) {
                view = gallery.getSelectedView();
            }
            if (view == null) {
                return super.onKeyDown(keyCode, event);
            }
            view.performLongClick();
            return true;
        }

        if (gallery != null) {
            if (isKeyCodeSkipBack(keyCode)) {
                int selectedItem = gallery.getSelectedItemPosition();
                int newPosition = selectedItem - 10;
                if (newPosition < 0) {
                    newPosition = 0;
                }
                gallery.setSelection(newPosition);
                gallery.requestFocusFromTouch();
                return true;
            }
            if (isKeyCodeSkipForward(keyCode)) {
                int selectedItem = gallery.getSelectedItemPosition();
                int newPosition = selectedItem + 10;
                if (newPosition > itemsCount) {
                    newPosition = itemsCount - 1;
                }
                gallery.setSelection(newPosition);
                gallery.requestFocusFromTouch();
                return true;
            }
        }
    }

    return super.onKeyDown(keyCode, event);

}

From source file:com.bt.download.android.gui.activities.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        if (!(getCurrentFragment() instanceof SearchFragment)) {
            controller.switchFragment(R.id.menu_main_search);
        }/*w w w.j av  a2s  .c o  m*/
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
        toggleDrawer();
    } else {
        return super.onKeyDown(keyCode, event);
    }

    return true;
}

From source file:com.benlinskey.greekreference.lexicon.LexiconDetailActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_MENU == keyCode && Build.BRAND.equalsIgnoreCase("LGE")) {
        return true;
    }/*from w ww . j  a  v a 2 s .c om*/
    return super.onKeyDown(keyCode, event);
}

From source file:com.commonsware.android.arXiv.arXiv.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        if (menu != null && submenu != null) {
            menu.performIdentifierAction(submenu.getItemId(), 0);
            return true;
        }//ww w.ja  va2  s  .  c  o  m
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.benlinskey.greekreference.lexicon.LexiconDetailActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_MENU == keyCode && Build.BRAND.equalsIgnoreCase("LGE")) {
        openOptionsMenu();/*from www.j a va2 s.  c o  m*/
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:gov.cdc.epiinfo.RecordList.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        openOptionsMenu();//  www.  jav a2  s.  c o m
    } else {
        return super.onKeyDown(keyCode, event);
    }
    return true;
}

From source file:com.frostwire.android.gui.activities.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        if (!(getCurrentFragment() instanceof SearchFragment)) {
            controller.switchFragment(R.id.menu_main_search);
        }//from   w ww. j  a v a 2s .  c  o m
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
        toggleDrawer();
    } else {
        try {
            return super.onKeyDown(keyCode, event);
        } catch (NullPointerException npe) {
            return false;
        }
    }
    return true;
}

From source file:net.granoeste.scaffold.app.ScaffoldActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // WTF: LGE Bug... NullPointerException (@PhoneWindow:onKeyUpPanel:1002) {main} - Stack Overflow http://stackoverflow.com/questions/26833242/nullpointerexception-phonewindowonkeyuppanel1002-main
    if (keyCode == KeyEvent.KEYCODE_MENU && "LGE".equalsIgnoreCase(Build.BRAND)) {
        return true;
    }// ww  w. j  av  a  2 s.c  o m
    return super.onKeyDown(keyCode, event);
}

From source file:com.actionbarsherlock.internal.view.menu.MenuPopupHelper.java

public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) {
        dismiss();/*  ww w .  j a v  a 2  s .  c o  m*/
        return true;
    }
    return false;
}