Example usage for android.view SubMenu removeGroup

List of usage examples for android.view SubMenu removeGroup

Introduction

In this page you can find the example usage for android.view SubMenu removeGroup.

Prototype

public void removeGroup(int groupId);

Source Link

Document

Remove all items in the given group.

Usage

From source file:org.getlantern.firetweet.menu.SupportAccountActionProvider.java

@Override
public void onPrepareSubMenu(final SubMenu subMenu) {
    subMenu.removeGroup(MENU_GROUP);
    if (mAccounts == null)
        return;/*from  www . j av  a 2s  .  c  o  m*/
    for (int i = 0, j = mAccounts.length; i < j; i++) {
        final ParcelableAccount account = mAccounts[i];
        final MenuItem item = subMenu.add(MENU_GROUP, Menu.NONE, i, account.name);
        final Intent intent = new Intent();
        intent.putExtra(EXTRA_ACCOUNT, account);
        item.setIntent(intent);
    }
    subMenu.setGroupCheckable(MENU_GROUP, true, mExclusive);
    if (mAccountIds == null)
        return;
    for (int i = 0, j = subMenu.size(); i < j; i++) {
        final MenuItem item = subMenu.getItem(i);
        if (ArrayUtils.contains(mAccountIds, mAccounts[i].account_id)) {
            item.setChecked(true);
        }
    }
}

From source file:org.mariotaku.twidere.menu.AccountToggleProvider.java

@Override
public void onPrepareSubMenu(final SubMenu subMenu) {
    subMenu.removeGroup(MENU_GROUP);
    if (mAccounts == null)
        return;//from w  w  w  .  j ava 2  s . c o  m
    for (int i = 0, j = mAccounts.length; i < j; i++) {
        final ParcelableAccount account = mAccounts[i];
        final MenuItem item = subMenu.add(MENU_GROUP, Menu.NONE, i, account.name);
        final Intent intent = new Intent();
        intent.putExtra(EXTRA_ACCOUNT, account);
        item.setIntent(intent);
    }
    subMenu.setGroupCheckable(MENU_GROUP, true, mExclusive);
    for (int i = 0, j = subMenu.size(); i < j; i++) {
        final MenuItem item = subMenu.getItem(i);
        if (mAccounts[i].is_activated) {
            item.setChecked(true);
        }
    }
}

From source file:de.vanita5.twittnuker.menu.StatusShareProvider.java

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    final Intent shareIntent = createStatusShareIntent(mContext, mStatus);
    subMenu.removeGroup(MENU_GROUP_STATUS_SHARE);
    if (mStatus != null) {
        addIntentToMenu(mContext, subMenu, shareIntent, MENU_GROUP_STATUS_SHARE);
    }/*from   w w w .ja v  a  2s  .  c o m*/
}

From source file:org.mariotaku.twidere.menu.SupportStatusShareProvider.java

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    final ParcelableStatus status = mStatus;
    if (status == null)
        return;//  w ww  . j  ava2 s.  com
    final Intent shareIntent = createStatusShareIntent(mContext, status);
    subMenu.removeGroup(MENU_GROUP_STATUS_SHARE);
    addIntentToMenu(mContext, subMenu, shareIntent, MENU_GROUP_STATUS_SHARE);
}

From source file:com.github.kanata3249.ffxieq.android.FoodSelectorActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item;//from   w ww.  j a va 2  s.  co m

    FoodListView flv;

    item = menu.findItem(R.id.FilterByType);
    SubMenu submenu = item.getSubMenu();
    submenu.removeGroup(R.id.FilterByType);

    flv = (FoodListView) findViewById(R.id.ListView);
    if (flv != null) {
        String types[] = flv.getAvailableFoodTypes();

        if (types == null || types.length == 1) {
            item.setEnabled(false);
        } else {
            item.setEnabled(true);
            submenu.add(R.id.FilterByType, -1, Menu.NONE, getString(R.string.ResetFilterByType));
            for (int i = 0; i < types.length; i++) {
                submenu.add(R.id.FilterByType, i, Menu.NONE, types[i]);
            }
        }

    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item;//from w w w  .  java  2 s  .  co  m

    item = menu.findItem(R.id.OrderByName);
    if (item != null) {
        if (mOrderByName)
            item.setTitle(getString(R.string.OrderByLevel));
        else
            item.setTitle(getString(R.string.OrderByName));
    }

    EquipmentListView elv;

    item = menu.findItem(R.id.FilterByType);
    SubMenu submenu = item.getSubMenu();
    submenu.removeGroup(R.id.FilterByType);

    elv = (EquipmentListView) findViewById(R.id.ListView);
    if (elv != null) {
        String types[] = elv.getAvailableWeaponTypes();

        if (types == null || types.length == 1) {
            item.setEnabled(false);
        } else {
            item.setEnabled(true);
            submenu.add(R.id.FilterByType, -1, Menu.NONE, getString(R.string.ResetFilterByType));
            for (int i = 0; i < types.length; i++) {
                submenu.add(R.id.FilterByType, i, Menu.NONE, types[i]);
            }
        }

    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item;//w  w w  . j  a v a 2s .c o m

    item = menu.findItem(R.id.OrderByName);
    if (item != null) {
        if (mOrderByName)
            item.setTitle(getString(R.string.OrderByLevel));
        else
            item.setTitle(getString(R.string.OrderByName));
    }

    AugmentListView lv;

    item = menu.findItem(R.id.FilterByType);
    SubMenu submenu = item.getSubMenu();
    submenu.removeGroup(R.id.FilterByType);

    lv = (AugmentListView) findViewById(R.id.ListView);
    if (lv != null) {
        String types[] = lv.getAvailableWeaponTypes();

        if (types == null || types.length == 1) {
            item.setEnabled(false);
        } else {
            item.setEnabled(true);
            submenu.add(R.id.FilterByType, -1, Menu.NONE, getString(R.string.ResetFilterByType));
            for (int i = 0; i < types.length; i++) {
                submenu.add(R.id.FilterByType, i, Menu.NONE, types[i]);
            }
        }

    }

    return super.onPrepareOptionsMenu(menu);
}