Example usage for android.view MenuItem getGroupId

List of usage examples for android.view MenuItem getGroupId

Introduction

In this page you can find the example usage for android.view MenuItem getGroupId.

Prototype

public int getGroupId();

Source Link

Document

Return the group identifier that this menu item is part of.

Usage

From source file:org.openintents.shopping.ui.ShoppingActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (debug) {//from  w  w w. jav  a  2s  .  c o  m
        Log.d(TAG, "onOptionsItemSelected getItemId: " + item.getItemId());
    }
    Intent intent;
    switch (item.getItemId()) {
    case MENU_NEW_LIST:
        showDialog(DIALOG_NEW_LIST);
        return true;

    case MENU_CLEAN_UP_LIST:
        cleanupList();
        return true;

    case MENU_RENAME_LIST:
        showDialog(DIALOG_RENAME_LIST);
        return true;

    case MENU_DELETE_LIST:
        deleteListConfirm();
        return true;

    case MENU_PICK_ITEMS:
        pickItems();
        return true;

    case MENU_SHARE:
        setShareSettings();
        return true;

    case MENU_THEME:
        setThemeSettings();
        return true;

    case MENU_ADD_LOCATION_ALERT:
        addLocationAlert();
        return true;

    case MENU_PREFERENCES:
        intent = new Intent(this, PreferenceActivity.class);
        startActivity(intent);
        return true;
    case MENU_SEND:
        sendList();
        return true;
    case MENU_INSERT_FROM_EXTRAS:
        insertItemsFromExtras();
        return true;
    case MENU_MARK_ALL_ITEMS:
        mItemsView.toggleAllItems(true);
        return true;
    case MENU_UNMARK_ALL_ITEMS:
        mItemsView.toggleAllItems(false);
        return true;
    case MENU_SYNC_WEAR:
        mItemsView.pushItemsToWear();
        return true;
    }
    if (debug) {
        Log.d(TAG, "Start intent group id : " + item.getGroupId());
    }
    if (Menu.CATEGORY_ALTERNATIVE == item.getGroupId()) {
        // Start alternative cateogory intents with option to return a
        // result.
        if (debug) {
            Log.d(TAG, "Start alternative intent for : " + item.getIntent().getDataString());
        }
        startActivityForResult(item.getIntent(), REQUEST_CODE_CATEGORY_ALTERNATIVE);
        return true;
    }
    if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }
    return super.onOptionsItemSelected(item);

}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (DEBUG)/*from   ww  w.ja  va2s .  c o m*/
        Logger.LogDebug("OpenExplorer.onOptionsItemSelected(" + item + ")");
    if (item.getItemId() == R.id.menu_more && isGTV()) {
        showMenu(mOptsMenu, findViewById(item.getItemId()), false);
        return true;
    }

    if (item.getSubMenu() != null) {
        onPrepareOptionsMenu(item.getSubMenu());
        if (!USE_PRETTY_MENUS)
            return false;
        else {
            View anchor = findViewById(item.getItemId());
            if (anchor == null && !BEFORE_HONEYCOMB && item.getActionView() != null)
                anchor = item.getActionView();
            if (anchor == null && !BEFORE_HONEYCOMB) {
                anchor = getActionBar().getCustomView();
                if (anchor.findViewById(item.getItemId()) != null)
                    anchor = anchor.findViewById(item.getItemId());
            }
            if (anchor == null)
                anchor = mToolbarButtons;
            if (anchor == null)
                anchor = findViewById(android.R.id.home);
            if (anchor == null && !BEFORE_HONEYCOMB && USE_ACTION_BAR)
                anchor = getActionBar().getCustomView().findViewById(android.R.id.home);
            if (anchor == null)
                anchor = getCurrentFocus().getRootView();
            OpenFragment f = getSelectedFragment();
            if (f != null)
                if (f.onClick(item.getItemId(), anchor))
                    return true;
        }
    }

    if (item.isCheckable())
        item.setChecked(item.getGroupId() > 0 ? true : !item.isChecked());

    OpenFragment f = getSelectedFragment();
    if (f != null && f.onOptionsItemSelected(item))
        return true;

    if (DEBUG)
        Logger.LogDebug("OpenExplorer.onOptionsItemSelected(0x" + Integer.toHexString(item.getItemId()) + ")");

    return onClick(item.getItemId(), item, null);
}