Java 类android.view.SubMenu 实例源码

项目:euphoria-vk-client    文件:BasicActivity.java   
private void applyTypefaces() {
    Menu m = navigationView.getMenu();
    for (int i = 0; i < m.size(); i++) {
        MenuItem item = m.getItem(i);

        //for applying a font to subMenu...
        SubMenu subMenu = item.getSubMenu();
        if (subMenu != null && subMenu.size() > 0) {
            for (int j = 0; j < subMenu.size(); j++) {
                MenuItem subMenuItem = subMenu.getItem(j);
                applyTypeface(subMenuItem);
            }
        }

        //the method we have create in activity
        applyTypeface(item);
    }
}
项目:Kandroid    文件:MainActivity.java   
private void populateProjectsMenu() {
    if (mProjectList == null) {
        if (BuildConfig.DEBUG) Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null");
        return;
    }
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext());
    List<KanboardProject> projList = mProjectList;
    if (preferences.getBoolean("projects_sort_alphabetic", false))
        Collections.sort(projList);
    NavigationView nav = (NavigationView) findViewById(R.id.nav_view);
    SubMenu projMenu = nav.getMenu().findItem(R.id.projects).getSubMenu();
    projMenu.clear();
    for (KanboardProject item: projList)
        projMenu.add(Menu.NONE, item.getId(), Menu.NONE, item.getName())
                .setIcon(R.drawable.project);
}
项目:OpenHub    文件:ViewUtils.java   
public static void selectMenuItem(@NonNull Menu menu, @IdRes int itemId, boolean findSub) {
    boolean find = false;
    for (int i = 0; i < menu.size(); i++) {
        if (!findSub) {
            menu.getItem(i).setChecked(menu.getItem(i).getItemId() == itemId);
        } else {
            if (menu.getItem(i).getItemId() == itemId) {
                find = true;
            }
        }
    }

    if (!findSub) {
        return;
    } else if (find) {
        selectMenuItem(menu, itemId, false);
    } else {
        for (int i = 0; i < menu.size(); i++) {
            SubMenu subMenu = menu.getItem(i).getSubMenu();
            if(subMenu != null)
                selectMenuItem(subMenu, itemId, true);
        }
    }
}
项目:boohee_v5.6    文件:BaseMenuWrapper.java   
final SubMenu getSubMenuWrapper(SubMenu subMenu) {
    if (!(subMenu instanceof SupportSubMenu)) {
        return subMenu;
    }
    SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;
    if (this.mSubMenus == null) {
        this.mSubMenus = new ArrayMap();
    }
    SubMenu wrappedMenu = (SubMenu) this.mSubMenus.get(supportSubMenu);
    if (wrappedMenu != null) {
        return wrappedMenu;
    }
    wrappedMenu = MenuWrapperFactory.wrapSupportSubMenu(this.mContext, supportSubMenu);
    this.mSubMenus.put(supportSubMenu, wrappedMenu);
    return wrappedMenu;
}
项目:boohee_v5.6    文件:ShareActionProvider.java   
public void onPrepareSubMenu(SubMenu subMenu) {
    int i;
    subMenu.clear();
    ActivityChooserModel dataModel = ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
    PackageManager packageManager = this.mContext.getPackageManager();
    int expandedActivityCount = dataModel.getActivityCount();
    int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
    for (i = 0; i < collapsedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(this.mOnMenuItemClickListener);
    }
    if (collapsedActivityCount < expandedActivityCount) {
        SubMenu expandedSubMenu = subMenu.addSubMenu(0, collapsedActivityCount, collapsedActivityCount, this.mContext.getString(R.string.abc_activity_chooser_view_see_all));
        for (i = 0; i < expandedActivityCount; i++) {
            activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(this.mOnMenuItemClickListener);
        }
    }
}
项目:RetroMusicPlayer    文件:AlbumsFragment.java   
private void setUpSortOrderMenu(SubMenu subMenu) {
    subMenu.removeItem(R.id.action_sort_order_title_desc);
    subMenu.removeItem(R.id.action_sort_order_title);
    subMenu.removeItem(R.id.action_sort_order_date);
    subMenu.removeItem(R.id.action_sort_order_duration);
    subMenu.removeItem(R.id.action_sort_order_year);
    subMenu.removeItem(R.id.action_sort_order_artist_desc);

    switch (getSavedSortOrder()) {
        case AlbumSortOrder.ALBUM_A_Z:
            subMenu.findItem(R.id.action_sort_order_album).setChecked(true);
            break;
        case AlbumSortOrder.ALBUM_Z_A:
            subMenu.findItem(R.id.action_sort_order_album_desc).setChecked(true);
            break;
        case AlbumSortOrder.ALBUM_ARTIST:
            subMenu.findItem(R.id.action_sort_order_artist).setChecked(true);
            break;
    }

}
项目:RetroMusicPlayer    文件:ArtistsFragment.java   
private void setUpSortOrderMenu(SubMenu subMenu) {
    subMenu.removeItem(R.id.action_sort_order_title_desc);
    subMenu.removeItem(R.id.action_sort_order_title);
    subMenu.removeItem(R.id.action_sort_order_date);
    subMenu.removeItem(R.id.action_sort_order_duration);
    subMenu.removeItem(R.id.action_sort_order_year);
    subMenu.removeItem(R.id.action_sort_order_album);
    subMenu.removeItem(R.id.action_sort_order_album_desc);

    switch (getSavedSortOrder()) {
        case ArtistSortOrder.ARTIST_A_Z:
            subMenu.findItem(R.id.action_sort_order_artist).setChecked(true);
            break;
        case ArtistSortOrder.ARTIST_Z_A:
            subMenu.findItem(R.id.action_sort_order_artist_desc).setChecked(true);
            break;
    }
}
项目:RetroMusicPlayer    文件:ArtistDetailActivity.java   
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) {
    switch (getSavedSortOrder()) {
        case ArtistSongSortOrder.SONG_A_Z:
            sortOrder.findItem(R.id.action_sort_order_title).setChecked(true);
            break;
        case ArtistSongSortOrder.SONG_Z_A:
            sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true);
            break;
        case ArtistSongSortOrder.SONG_ALBUM:
            sortOrder.findItem(R.id.action_sort_order_album).setChecked(true);
            break;
        case ArtistSongSortOrder.SONG_YEAR:
            sortOrder.findItem(R.id.action_sort_order_year).setChecked(true);
            break;
        case ArtistSongSortOrder.SONG_DURATION:
            sortOrder.findItem(R.id.action_sort_order_artist_song_duration).setChecked(true);
            break;
        case ArtistSongSortOrder.SONG_DATE:
            sortOrder.findItem(R.id.action_sort_order_date).setChecked(true);
            break;
    }
}
项目:RetroMusicPlayer    文件:AlbumDetailsActivity.java   
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) {
    switch (getSavedSortOrder()) {
        case AlbumSongSortOrder.SONG_A_Z:
            sortOrder.findItem(R.id.action_sort_order_title).setChecked(true);
            break;
        case AlbumSongSortOrder.SONG_Z_A:
            sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true);
            break;
        case AlbumSongSortOrder.SONG_TRACK_LIST:
            sortOrder.findItem(R.id.action_sort_order_track_list).setChecked(true);
            break;
        case AlbumSongSortOrder.SONG_DURATION:
            sortOrder.findItem(R.id.action_sort_order_artist_song_duration).setChecked(true);
            break;
    }
}
项目:nmud-demo    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 0, "Local").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    SubMenu subDebug = menu.addSubMenu(100, 100, 100, "Dev tools...");
    subDebug.add(2, 2, 2, "TEST!");
    subDebug.add(8, 8, 8, "Override inet address");
    subDebug.add(9, 9, 9, "Save logs");

    SubMenu subDomain = menu.addSubMenu(101, 101, 101, "Domain...");
    subDomain.add(3, 3, 3, "Save our world now");

    SubMenu subDb = menu.addSubMenu(102, 102, 102, "Database...");
    subDb.add(5, 5, 5, "Import file to db");
    subDb.add(6, 6, 6, "Export from db");

    menu.add(7, 7, 7, "Kill myself with pleasure");
    return true;
}
项目:in-sangbok    文件:SongbookFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem filterItem = menu.findItem(R.id.songbook_filter_category);
    if (null != filterItem) {
        SubMenu subMenu = filterItem.getSubMenu();
        subMenu.clear();

        if (null != mSongbook) {
            subMenu.add(Menu.NONE, MENU_CLEAR_FILTER_ID, Menu.NONE, R.string.songbook_show_all);

            List<String> categories = mSongbook.categories();
            for (int i = 0; i < categories.size(); i++) {
                subMenu.add(MENU_CATEGORIES_ID, MENU_CATEGORIES_ID + i, Menu.NONE, categories.get(i));
            }
        }
    }
}
项目:solved-hacking-problem    文件:C0263e.java   
final SubMenu m2088a(SubMenu subMenu) {
    if (!(subMenu instanceof C0091c)) {
        return subMenu;
    }
    C0091c c0091c = (C0091c) subMenu;
    if (this.f956d == null) {
        this.f956d = new C0107a();
    }
    SubMenu subMenu2 = (SubMenu) this.f956d.get(c0091c);
    if (subMenu2 != null) {
        return subMenu2;
    }
    subMenu2 = ab.m2086a(this.f954a, c0091c);
    this.f956d.put(c0091c, subMenu2);
    return subMenu2;
}
项目:Reader    文件:MainActivity.java   
/**
 * Setups the navigation drawer's menu to include the given collection of subreddits.
 * The subreddit portion of this menu is rebuilt each time.
 *
 * @param subreddits the collection of subreddits to add to the menu
 */
private void setupNavMenu(Collection<String> subreddits) {
    NavigationView mNavView = (NavigationView) findViewById(R.id.nav_view);
    if (subreddits.isEmpty() || mNavView == null) return;
    Menu menu = mNavView.getMenu();
    menu.removeGroup(SUBREDDIT_MENU_GRP);
    SubMenu subMenu = menu.addSubMenu(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, "Subreddit");
    for (String subreddit : subreddits) {
        subMenu.add(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, subreddit);
    }
    subMenu.setGroupCheckable(SUBREDDIT_MENU_GRP, true, true);
    mNavView.setNavigationItemSelectedListener(item -> {
        selectNavItem(item);
        return true;
    });
}
项目:Material-Design-Companion    文件:MainActivity.java   
private Index populateIndex(NavigationView navigationView) {
    Index specIndex = mSpecReader.getIndex(getAssets());
    Menu menu = navigationView.getMenu();
    @IdRes final int STARTING_MENU_ITEM_ID = 1;
    @IdRes int menuItemId = STARTING_MENU_ITEM_ID;
    for (IndexSection section : specIndex.sections) {
        String sectionTitle = section.title;
        SubMenu submenu = menu.addSubMenu(sectionTitle);
        for (IndexSubsection subsection : section.sections) {
            String subsectionTitle = subsection.title;
            submenu
                    .add(Menu.NONE, menuItemId, Menu.NONE, subsectionTitle)
                    .setCheckable(true);
            mMenuItemIdToIndexSubsection.put(menuItemId, subsection);
            mIndexSubsectionToMenuItemId.put(subsection, menuItemId);
            mRelativeHrefToIndexSubsection.put(specHrefToRelativeHref(subsection.href), subsection);
            ++menuItemId;
        }
    }
    navigationView.setCheckedItem(STARTING_MENU_ITEM_ID);
    return specIndex;
}
项目:MemoryCleaner    文件:IgnoreSetting.java   
@Override public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_ignore_setting, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 3, 2, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
项目:userhook-sdk-android    文件:MainActivity.java   
public void loadStaticPages() {
    UserHook.fetchPageNames(new UHOperation.UHArrayListener<UHPage>() {
        @Override
        public void onSuccess(List<UHPage> items) {

            SubMenu staticMenu = navigationView.getMenu().addSubMenu("Static Pages");
            for (UHPage page : items) {
                // add page to menu
                staticMenu.add(page.getName());

                // store the page item for use in the click listener
                staticPages.put(page.getName(), page);
            }

            // hack to refresh menu
            MenuItem mi = navigationView.getMenu().getItem(navigationView.getMenu().size() - 1);
            mi.setTitle(mi.getTitle());
        }
    });
}
项目:MemoryCleaner    文件:MemoryClean.java   
@Override public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_memory_clean, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "大小");
    subMenu.add(GROUP_ID + 1, BASE_ID + 3, 2, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 4, 3, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
项目:TaskApp    文件:MenuColorizer.java   
/** Sets a color filter on all menu icons, including the overflow button (if it exists) */
public static void colorMenu(final Activity activity, final Menu menu, final int color,
                             final int alpha) {
    for (int i = 0, size = menu.size(); i < size; i++) {
        final MenuItem menuItem = menu.getItem(i);
        colorMenuItem(menuItem, color, alpha);
        if (menuItem.hasSubMenu()) {
            final SubMenu subMenu = menuItem.getSubMenu();
            for (int j = 0; j < subMenu.size(); j++) {
                colorMenuItem(subMenu.getItem(j), color, alpha);
            }
        }
    }
    final View home = activity.findViewById(android.R.id.home);
    if (home != null) {
        home.post(new Runnable() {

            @Override
            public void run() {
                colorOverflow(activity, color, alpha);
            }
        });
    }
}
项目:PortalApp    文件:SubjectDetailsActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.subject_details_menu, menu);

    SubMenu branches = menu.addSubMenu(12, 100, 0, "Branch");
    branches.setHeaderTitle(Html.fromHtml("<font color = '#03A9F4'>Select Branch</font>"));
    branches.setGroupCheckable(1, true, true);

    String division = "<font color = '#757575'>" + divisionNames.get(0) + "</font>";
    String branch = " " + branchNames.get(0);

    currentBranchItem = branches.add(1, 0, 0, Html.fromHtml(division + branch)).setCheckable(true).setChecked(true);
    for (int i = 1; i < branchNames.size(); i++) {
        division = "<font color = '#757575'>" + divisionNames.get(i) + "</font>";
        branch = " " + branchNames.get(i);
        branches.add(1, i, i, Html.fromHtml(division + branch)).setCheckable(true).setChecked(false);
    }

    return true;
}
项目:HightCopyWX    文件:PlusActionProvider.java   
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    subMenu.clear();
    subMenu.add(Menu.NONE,0,Menu.NONE,mContext.getString(R.string.multi_chat))
            .setIcon(R.drawable.multi_chat)
            .setOnMenuItemClickListener(this);
    subMenu.add(Menu.NONE,1,Menu.NONE,mContext.getString(R.string.add_friends))
            .setIcon(R.drawable.add_friends)
            .setOnMenuItemClickListener(this);
    subMenu.add(Menu.NONE,2,Menu.NONE,mContext.getString(R.string.scan))
            .setIcon(R.drawable.scan)
            .setOnMenuItemClickListener(this);
    subMenu.add(Menu.NONE,3,Menu.NONE,mContext.getString(R.string.pay_money))
            .setIcon(R.drawable.pay_money)
            .setOnMenuItemClickListener(this);
    subMenu.add(Menu.NONE,4,Menu.NONE,mContext.getString(R.string.help_devise))
            .setIcon(R.drawable.help_advise)
            .setOnMenuItemClickListener(this);
}
项目:Kandroid    文件:MainActivity.java   
private void populateProjectsMenu() {
    if (mProjectList == null) {
        if (BuildConfig.DEBUG) Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null");
        return;
    }
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext());
    List<KanboardProject> projList = mProjectList;
    if (preferences.getBoolean("projects_sort_alphabetic", false))
        Collections.sort(projList);
    NavigationView nav = (NavigationView) findViewById(R.id.nav_view);
    SubMenu projMenu = nav.getMenu().findItem(R.id.projects).getSubMenu();
    projMenu.clear();
    for (KanboardProject item: projList)
        projMenu.add(Menu.NONE, item.getId(), Menu.NONE, item.getName())
                .setIcon(R.drawable.project);
}
项目:BigApp_Discuz_Android    文件:ForumFilterProvider.java   
/**
 * {@inheritDoc}
 */
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    if (replayItem != null) {
        return;
    }

    subMenu.clear();
    replayItem = subMenu.add(0, 1, 1, R.string.newly_reply).setIcon(R.drawable.ic_new_replay_checked);
    publishItem = subMenu.add(0, 2, 2, R.string.newly_publish).setIcon(R.drawable.ic_new_publish_unchecked);
    if (mListener != null) {
        replayItem.setOnMenuItemClickListener(mListener);
        publishItem.setOnMenuItemClickListener(mListener);
    }

}
项目:foursquared    文件:FriendsActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(MENU_GROUP_SEARCH, MENU_REFRESH, Menu.NONE, R.string.refresh)
            .setIcon(R.drawable.ic_menu_refresh);
    menu.add(Menu.NONE, MENU_SHOUT, Menu.NONE, R.string.shout_action_label)
            .setIcon(R.drawable.ic_menu_shout);

    SubMenu menuMore = menu.addSubMenu(Menu.NONE, MENU_MORE, Menu.NONE, "More");
    menuMore.setIcon(android.R.drawable.ic_menu_more);
    for (Map.Entry<Integer, String> it : mMenuMoreSubitems.entrySet()) {
        menuMore.add(it.getValue());
    }

    MenuUtils.addPreferencesToMenu(this, menu);

    return true;
}
项目:LaravelNewsApp    文件:MenuTint.java   
/**
 * <p>Sets a ColorFilter and/or alpha on all the {@link MenuItem}s in the menu, including the
 * OverflowMenuButton.</p>
 * <p>
 * <p>This should only be called after calling {@link #apply(Activity)}. It is useful for when
 * {@link MenuItem}s might be re-arranged due to an action view being collapsed or expanded.</p>
 */
public void reapply() {

    for (int i = 0, size = menu.size(); i < size; i++) {
        MenuItem item = menu.getItem(i);
        if (isActionButton(item)) {
            colorMenuItem(menu.getItem(i), menuItemIconColor, menuItemIconAlpha);
        }
    }

    if (actionBarView == null) {
        return;
    }

    actionBarView.post(new Runnable() {

        @Override
        public void run() {
            for (int i = 0, size = menu.size(); i < size; i++) {
                MenuItem menuItem = menu.getItem(i);
                if (isInOverflow(menuItem)) {
                    colorMenuItem(menuItem, subMenuIconColor, subMenuIconAlpha);
                } else {
                    colorMenuItem(menu.getItem(i), menuItemIconColor, menuItemIconAlpha);
                }
                if (menuItem.hasSubMenu()) {
                    SubMenu subMenu = menuItem.getSubMenu();
                    for (int j = 0; j < subMenu.size(); j++) {
                        colorMenuItem(subMenu.getItem(j), subMenuIconColor, subMenuIconAlpha);
                    }
                }
            }
            if (menuItemIconColor != null || menuItemIconAlpha != null) {
                colorOverflowMenuItem(overflowButton);
            }
        }

    });
}
项目:orgzly-android    文件:SearchFragment.java   
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);

    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            displayScheduleTimestampDialog(R.id.query_cab_schedule, mSelection.getIds());
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    mListener.onStateChangeRequest(mSelection.getIds(), menuItem.getTitle().toString());
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
项目:orgzly-android    文件:AgendaFragment.java   
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
    TreeSet<Long> selectionIds;
    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            selectionIds = originalSelectedIds();
            if (!selectionIds.isEmpty()) {
                displayScheduleTimestampDialog(R.id.query_cab_schedule, selectionIds);
            }
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    selectionIds = originalSelectedIds();
                    if (!selectionIds.isEmpty()) {
                        mListener.onStateChangeRequest(selectionIds, menuItem.getTitle().toString());
                    }
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
项目:MTweaks-KernelAdiutorMOD    文件:NavigationActivity.java   
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", true, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
项目:KernelAdiutor-Mod    文件:NavigationActivity.java   
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", false, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
项目:robird-reborn    文件:UserProfileActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.user_profile, menu);

    if (mUser != null && TextUtils.equals(mAccount.screenName(), mUser.getScreenName())) {
        menu.findItem(R.id.menu_direct).setVisible(false);
        menu.findItem(R.id.menu_reply).setVisible(false);
        menu.findItem(R.id.menu_spam).setVisible(false);
        menu.findItem(R.id.menu_block).setVisible(false);
        menu.findItem(R.id.menu_follow).setVisible(false);
    }

    List<UserList> userLists = mUserListsModel.lists().toBlocking().first();
    if (mUser != null && !userLists.isEmpty()) {
        final SubMenu listSubMenu = menu.addSubMenu(R.string.add_to_list);
        for (UserList userList : userLists) {
            listSubMenu.add(0, (int) userList.listId(), Menu.NONE, userList.name());
        }
    }

    if (mRelationship != null) {
        boolean isFollowing = mRelationship.isSourceFollowingTarget();
        boolean isBlocking = mRelationship.isSourceBlockingTarget();

        menu.findItem(R.id.menu_follow)
                .setIcon(isFollowing ? R.drawable.ic_account_remove : R.drawable.ic_person_add)
                .setTitle(isFollowing ? R.string.unfollow : R.string.follow);

        menu.findItem(R.id.menu_block)
                .setTitle(isBlocking ? R.string.unblock : R.string.block);
    }

    return super.onCreateOptionsMenu(menu);
}
项目:Rey-MusicPlayer    文件:SearchActivity.java   
public void onAlbumPopUpMenuClickListener(View v, final int position) {
    mSelectedPosition = position;
    final PopupMenu menu = new PopupMenu(SearchActivity.this, v);
    SubMenu sub = (menu.getMenu()).addSubMenu(0, ADD_TO_PLAYLIST, 1, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(mContext, sub, 0);
    mSelectedId = ((Album) mSearchResults.get(position))._Id;
    menu.setOnMenuItemClickListener(item -> {
        switch (item.getItemId()) {
            case R.id.popup_album_play_next:
                new AsyncAddTo(((Album) mSearchResults.get(position))._albumName, false, CursorHelper.getTracksForSelection("ALBUMS", "" + ((Album) mSearchResults.get(position))._Id)).execute();
                return true;
            case R.id.popup_album_add_to_queue:
                new AsyncAddTo(((Album) mSearchResults.get(position))._albumName, true, CursorHelper.getTracksForSelection("ALBUMS", "" + ((Album) mSearchResults.get(position))._Id)).execute();
                return true;
            case NEW_PLAYLIST:
                PlaylistDialog playlistDialog = new PlaylistDialog();
                Bundle bundle = new Bundle();
                bundle.putLongArray("PLAYLIST_IDS", MusicUtils.getPlayListIds(CursorHelper.getTracksForSelection("ALBUMS", "" + ((Album) mSearchResults.get(position))._Id)));
                playlistDialog.setArguments(bundle);
                playlistDialog.show(getSupportFragmentManager(), "FRAGMENT_TAG");

                return true;
            case PLAYLIST_SELECTED:
                MusicUtils.insertIntoPlayList(mContext, item, CursorHelper.getTracksForSelection("ALBUMS", "" + ((Album) mSearchResults.get(position))._Id));
                return true;
            case R.id.popup_album_delete:
                try {
                    MusicUtils.deleteFile(SearchActivity.this, CursorHelper.getTracksForSelection("ALBUMS", "" + ((Album) mSearchResults.get(position))._Id), this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return true;
            default:
                break;
        }
        return false;
    });
    menu.inflate(R.menu.popup_album);
    menu.show();
}
项目:Rey-MusicPlayer    文件:MusicUtils.java   
public static void makePlaylistMenu(Context context, SubMenu sub, int groupdId) {
    String[] cols = new String[]{
            MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME
    };
    ContentResolver resolver = context.getContentResolver();
    if (resolver == null) {
        System.out.println("resolver = null");
    } else {
        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
        Cursor cur = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                cols, whereclause, null,
                MediaStore.Audio.Playlists.NAME);
        sub.clear();
        sub.add(groupdId, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
        if (cur != null && cur.getCount() > 0) {
            //sub.addSeparator(1, 0);
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                Intent intent = new Intent();
                intent.putExtra("playlist", cur.getLong(0));
                sub.add(groupdId, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
项目:Rey-MusicPlayer    文件:MusicUtils.java   
public static void overflowsubmenu(Context context, SubMenu subMenu) {
    String[] cols = new String[]{
            MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME
    };
    ContentResolver resolver = context.getContentResolver();
    if (resolver == null) {
        System.out.println("resolver = null");
    } else {
        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
        Cursor cur = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                cols, whereclause, null,
                MediaStore.Audio.Playlists.NAME);
        subMenu.clear();
        subMenu.add(0, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
        if (cur != null && cur.getCount() > 0) {
            //sub.addSeparator(1, 0);
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                Intent intent = new Intent();
                intent.putExtra("playlist", cur.getLong(0));
                subMenu.add(0, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
项目:SSTVEncoder2    文件:MainActivity.java   
private void createModesMenu(Menu menu) {
    SubMenu modesSubMenu = menu.findItem(R.id.action_modes).getSubMenu();
    IModeInfo[] modeInfoList = mEncoder.getModeInfoList();
    for (IModeInfo modeInfo : modeInfoList) {
        MenuItem item = modesSubMenu.add(modeInfo.getModeName());
        Intent intent = new Intent();
        intent.putExtra(CLASS_NAME, modeInfo.getModeClassName());
        item.setIntent(intent);
    }
}
项目:ThunderMusic    文件:MusicUtils.java   
/**
 * Same as makePlaylistMenu, but only for online provides
 *
 * @param context The context to use for creating the menu items
 * @param sub     The submenu to add the items to.
 */
public static void makePlaylistMenuOnline(Context context, SubMenu sub) {
    String[] cols = new String[]{MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME};
    ContentResolver resolver = context.getContentResolver();
    if (resolver == null) {
    } else {
        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
        Cursor cur = resolver.query(
                MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, cols,
                whereclause, null, MediaStore.Audio.Playlists.NAME);
        sub.clear();
        sub.add(1, Defs.QUEUE, 0, R.string.queue);
        sub.add(1, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
        if (cur != null && cur.getCount() > 0) {
            // sub.addSeparator(1, 0);
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                if (cur.getLong(0) == MusicUtils.getPlaylistiD(cur
                        .getString(1))) {
                    Intent intent = new Intent();
                    intent.putExtra("playlist", cur.getLong(0));
                    intent.putExtra("name", cur.getString(1));
                    // if (cur.getInt(0) == mLastPlaylistSelected) {
                    // sub.add(0, MusicBaseActivity.PLAYLIST_SELECTED,
                    // cur.getString(1)).setIntent(intent);
                    // } else {
                    sub.add(1, Defs.PLAYLIST_SELECTED, 0, cur.getString(1))
                            .setIntent(intent);
                    // }
                }
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
项目:ThunderMusic    文件:MediaPlaybackActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.starred, menu);

    MenuInflater inflater2 = getMenuInflater();
    inflater2.inflate(R.menu.share, menu);

    Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
    if (getPackageManager().resolveActivity(i, 0) != null) {
        MenuInflater inflater1 = getMenuInflater();
        inflater1.inflate(R.menu.equalizer, menu);
    }

    MenuInflater inflater3 = getMenuInflater();
    inflater3.inflate(R.menu.settings, menu);
    if (!MusicUtils.getBooleanPref(this, "radiomode", false)) {
        SubMenu menu1 = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
                R.string.add_to_playlist);
        if (!MusicUtils.getBooleanPref(this, "radiomode", false)) {
            MusicUtils.makePlaylistMenuOnline(this, menu1);
        }
        menu.add(1, SEARCH_LYRICS, 0, R.string.search_lyrics_menu_short);
    }
    menu.add(1, ABOUT + 2, 0, R.string.carmode_menu_short);

    if (mSettings.getBoolean(PreferencesActivity.POPUP_ON, false))
        menu.add(1, ABOUT + 1, 0, R.string.go_popup);
    menu.add(1, ABOUT, 0, R.string.about_menu_short);
    menu.add(1, EXIT, 0, R.string.exit_menu);

    return true;
}
项目:RetroMusicPlayer    文件:SongsFragment.java   
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) {
    sortOrder.removeItem(R.id.action_sort_order_album_desc);
    sortOrder.removeItem(R.id.action_sort_order_artist_desc);

    switch (getSavedSortOrder()) {
        case SongSortOrder.SONG_ALBUM:
            sortOrder.findItem(R.id.action_sort_order_album).setChecked(true);
            break;
        case SongSortOrder.SONG_A_Z:
            sortOrder.findItem(R.id.action_sort_order_title).setChecked(true);
            break;
        case SongSortOrder.SONG_ARTIST:
            sortOrder.findItem(R.id.action_sort_order_artist).setChecked(true);
            break;
        case SongSortOrder.SONG_DATE:
            sortOrder.findItem(R.id.action_sort_order_date).setChecked(true);
            break;
        case SongSortOrder.SONG_DURATION:
            sortOrder.findItem(R.id.action_sort_order_duration).setChecked(true);
            break;
        case SongSortOrder.SONG_YEAR:
            sortOrder.findItem(R.id.action_sort_order_year).setChecked(true);
            break;
        case SongSortOrder.SONG_Z_A:
            sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true);
            break;
    }
}
项目:Face-detect-framework    文件:MultipleZoomCanny.java   
public void initMenuCameraChoice(Menu menu){
    List<String> effects = cameraView.getEffectList();

    if (effects == null) {
        Log.e(TAG, "Color effects are not supported by device!");
        return;
    }

    SubMenu mColorEffectsMenu = menu.addSubMenu("Color Effect");
    MenuItem[] mEffectMenuItems = new MenuItem[effects.size()];
    Log.i(TAG, "After Add Color Effect");
    int idx = 0;
    for (String element : effects) {
        mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element);
        idx++;
    }

    SubMenu mAlphaMenu = menu.addSubMenu("Alpha");

    MenuItem[] mAlphaItems = new MenuItem[6];
    mAlphaItems[0] = mAlphaMenu.add(3, 0, Menu.NONE, "1");
    mAlphaItems[1] = mAlphaMenu.add(3, 0, Menu.NONE, "1.2");
    mAlphaItems[2] = mAlphaMenu.add(3, 0, Menu.NONE, "1.3");
    mAlphaItems[3] = mAlphaMenu.add(3, 0, Menu.NONE, "1.5");
    mAlphaItems[4] = mAlphaMenu.add(3, 0, Menu.NONE, "1.7");
    mAlphaItems[5] = mAlphaMenu.add(3, 0, Menu.NONE, "2");
    //  mAlphaItems[0]= mAlphaMenu.add(3,0,Menu.NONE,"");

    SubMenu mBetaMenu = menu.addSubMenu("Beta");
    MenuItem[] mBetaItems = new MenuItem[5];
    mBetaItems[0] = mBetaMenu.add(4, 0, Menu.NONE, "-50");
    mBetaItems[1] = mBetaMenu.add(4, 0, Menu.NONE, "-25");
    mBetaItems[2] = mBetaMenu.add(4, 0, Menu.NONE, "0");
    mBetaItems[3] = mBetaMenu.add(4, 0, Menu.NONE, "25");
    mBetaItems[4] = mBetaMenu.add(4, 0, Menu.NONE, "50");
}
项目:10000sentences    文件:BaseActivity.java   
private void setupCollectionsNavigation(NavigationView navigationView) {
    if (collectionNavigationSet) {
        return;
    }
    collectionNavigationSet = true;

    SubMenu submenu = navigationView.getMenu().addSubMenu(R.string.downloaded_colections);
    Map<String, Language> languages = dao.getLanguagesByLanguageID();

    for (final SentenceCollection collection : dao.getCollections()) {
        Language language = languages.get(collection.targetLanguage);
        if (language == null) {
            continue;
        }
        if (collection.todoCount == 0) {
            continue;
        }
        MenuItem menu = submenu.add(language.name).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                CollectionActivity.start(BaseActivity.this, collection.collectionID);
                return true;
            }
        });
        setupMenuIcon(menu, FontAwesomeIcons.fa_language);
    }
}
项目:bridddle-for-dribbble    文件:MenuTint.java   
/**
 * <p>Sets a ColorFilter and/or alpha on all the {@link MenuItem}s in the menu, including the
 * OverflowMenuButton.</p>
 *
 * <p>This should only be called after calling {@link #apply(Activity)}. It is useful for when
 * {@link MenuItem}s might be re-arranged due to an action view being collapsed or expanded.</p>
 */
public void reapply() {

    for (int i = 0, size = menu.size(); i < size; i++) {
        MenuItem item = menu.getItem(i);
        if (isActionButton(item)) {
            colorMenuItem(menu.getItem(i), menuItemIconColor, menuItemIconAlpha);
        }
    }

    if (actionBarView == null) {
        return;
    }

    actionBarView.post(new Runnable() {

        @Override public void run() {
            for (int i = 0, size = menu.size(); i < size; i++) {
                MenuItem menuItem = menu.getItem(i);
                if (isInOverflow(menuItem)) {
                    colorMenuItem(menuItem, subMenuIconColor, subMenuIconAlpha);
                } else {
                    colorMenuItem(menu.getItem(i), menuItemIconColor, menuItemIconAlpha);
                }
                if (menuItem.hasSubMenu()) {
                    SubMenu subMenu = menuItem.getSubMenu();
                    for (int j = 0; j < subMenu.size(); j++) {
                        colorMenuItem(subMenu.getItem(j), subMenuIconColor, subMenuIconAlpha);
                    }
                }
            }
            if (menuItemIconColor != null || menuItemIconAlpha != null) {
                colorOverflowMenuItem(overflowButton);
            }
        }

    });
}
项目:solved-hacking-problem    文件:C0264i.java   
public boolean m2118a(MenuItem menuItem, C0267x c0267x, int i) {
    C0272m c0272m = (C0272m) menuItem;
    if (c0272m == null || !c0272m.isEnabled()) {
        return false;
    }
    boolean b = c0272m.m2223b();
    C0161n a = c0272m.m2216a();
    boolean z = a != null && a.m1343e();
    boolean expandActionView;
    if (c0272m.m2238n()) {
        expandActionView = c0272m.expandActionView() | b;
        if (!expandActionView) {
            return expandActionView;
        }
        m2115a(true);
        return expandActionView;
    } else if (c0272m.hasSubMenu() || z) {
        m2115a(false);
        if (!c0272m.hasSubMenu()) {
            c0272m.m2218a(new ad(m2131e(), this, c0272m));
        }
        ad adVar = (ad) c0272m.getSubMenu();
        if (z) {
            a.m1338a((SubMenu) adVar);
        }
        expandActionView = m2096a(adVar, c0267x) | b;
        if (expandActionView) {
            return expandActionView;
        }
        m2115a(true);
        return expandActionView;
    } else {
        if ((i & 1) == 0) {
            m2115a(true);
        }
        return b;
    }
}