private SublimeBaseMenuItem addInternal(int group,int id,CharSequence title,CharSequence hint,SublimeBaseMenuItem.ItemType itemType,boolean valueProvidedAsync,CharSequence badgeText,boolean showsIconSpace,boolean addedByUser){
  SublimeBaseMenuItem item;
  boolean isGroupHeader=false;
switch (itemType) {
case SEPARATOR:
    item=new SublimeSeparatorMenuItem(this,group,id);
  break;
case BADGE:
item=new SublimeTextWithBadgeMenuItem(this,group,id,title,hint,valueProvidedAsync,badgeText,showsIconSpace);
break;
case SWITCH:
item=new SublimeSwitchMenuItem(this,group,id,title,hint,valueProvidedAsync,showsIconSpace);
break;
case CHECKBOX:
item=new SublimeCheckboxMenuItem(this,group,id,title,hint,valueProvidedAsync,showsIconSpace);
break;
case GROUP_HEADER:
isGroupHeader=true;
item=new SublimeGroupHeaderMenuItem(this,group,id,title,hint,valueProvidedAsync,showsIconSpace);
break;
default :
item=new SublimeTextMenuItem(this,group,id,title,hint,valueProvidedAsync,showsIconSpace);
break;
}
checkExistenceOfGroup(group);
if (isGroupHeader) {
checkIfGroupHeaderAlreadyExistsForGroup(group);
int index=findGroupIndex(group);
if (index >= 0) {
mItems.add(index,item);
}
 else {
mItems.add(item);
}
}
 else if (addedByUser) {
if (group != NO_GROUP_ID) {
int lastGroupIndex=findLastGroupIndex(group);
mItems.add(lastGroupIndex == mItems.size() ? lastGroupIndex : lastGroupIndex + 1,item);
}
 else {
mItems.add(item);
}
}
 else {
mItems.add(item);
}
onItemsChanged();
return item;
}

private SublimeBaseMenuItem addInternal ( int group , int id , CharSequence title , CharSequence hint , SublimeBaseMenuItem . ItemType itemType , boolean valueProvidedAsync , CharSequence badgeText , boolean showsIconSpace , boolean addedByUser ) { SublimeBaseMenuItem item ; boolean isGroupHeader = false ; switch ( itemType ) { case SEPARATOR : item = new SublimeSeparatorMenuItem ( this , group , id ) ; break ; case BADGE : item = new SublimeTextWithBadgeMenuItem ( this , group , id , title , hint , valueProvidedAsync , badgeText , showsIconSpace ) ; break ; case SWITCH : item = new SublimeSwitchMenuItem ( this , group , id , title , hint , valueProvidedAsync , showsIconSpace ) ; break ; case CHECKBOX : item = new SublimeCheckboxMenuItem ( this , group , id , title , hint , valueProvidedAsync , showsIconSpace ) ; break ; case GROUP_HEADER : isGroupHeader = true ; item = new SublimeGroupHeaderMenuItem ( this , group , id , title , hint , valueProvidedAsync , showsIconSpace ) ; break ; default : item = new SublimeTextMenuItem ( this , group , id , title , hint , valueProvidedAsync , showsIconSpace ) ; break ; } checkExistenceOfGroup ( group ) ; if ( isGroupHeader ) { checkIfGroupHeaderAlreadyExistsForGroup ( group ) ; int index = findGroupIndex ( group ) ; if ( index >= 0 ) { mItems . add ( index , item ) ; } else { mItems . add ( item ) ; } } else if ( addedByUser ) { if ( group != NO_GROUP_ID ) { int lastGroupIndex = findLastGroupIndex ( group ) ; mItems . add ( lastGroupIndex == mItems . size ( ) ? lastGroupIndex : lastGroupIndex + 1 , item ) ; } else { mItems . add ( item ) ; } } else { mItems . add ( item ) ; } onItemsChanged ( ) ; return item ; }
adds an item to the menu . the other add methods funnel to this .
