material/src/main/java/com/rey/material/util/ToolbarManager.java
public void onPrepareMenu(){
        if(mGroupChanged || mMenuDataChanged){
            mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);

            Menu menu = mToolbar.getMenu();
            for(int i = 0, count = menu.size(); i < count; i++){
                MenuItem item = menu.getItem(i);
                item.setVisible(item.getGroupId() == mCurrentGroup || item.getGroupId() == 0);
            }

            mMenuDataChanged = false;
        }
    }
/**
     * This function should be called in onPrepareOptionsMenu(Menu) of Activity that use
     * Toolbar as ActionBar, or after inflating menu.
     */
This function should be called in onPrepareOptionsMenu(Menu) of Activity that use
Toolbar as ActionBar, or after inflating menu.
This function should be called in onPrepareOptionsMenu ( Menu ) of Activity that use Toolbar as ActionBar or after inflating menu .
public void onPrepareMenu(){
        if(mGroupChanged || mMenuDataChanged){
            mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
            Menu menu = mToolbar.getMenu();
            for(int i = 0, count = menu.size(); i < count; i++){
                MenuItem item = menu.getItem(i);
                item.setVisible(item.getGroupId() == mCurrentGroup || item.getGroupId() == 0);
            }
            mMenuDataChanged = false;
        }
    }
public void onPrepareMenu ( ) { if ( mGroupChanged || mMenuDataChanged ) { mToolbar . getViewTreeObserver ( ) . addOnGlobalLayoutListener ( mOnGlobalLayoutListener ) ; Menu menu = mToolbar . getMenu ( ) ; for ( int i = 0 , count = menu . size ( ) ; i < count ; i ++ ) { MenuItem item = menu . getItem ( i ) ; item . setVisible ( item . getGroupId ( ) == mCurrentGroup || item . getGroupId ( ) == 0 ) ; } mMenuDataChanged = false ; } }
This function should be called in onPrepareOptionsMenu(Menu) of Activity that use
 Toolbar as ActionBar, or after inflating menu.
This function should be called in onPrepareOptionsMenu ( Menu ) of Activity that use Toolbar as ActionBar or after inflating menu .