public void moveItem ( SubMenuItem parent , MenuItem newItem , MoveType moveType ) { synchronized ( subMenuItems ) { ArrayList < MenuItem > items = subMenuItems . get ( parent ) ; int idx = items . indexOf ( newItem ) ; if ( idx < 0 ) return ; items . remove ( idx ) ; idx = ( moveType == MoveType . MOVE_UP ) ? -- idx : ++ idx ; if ( idx < 0 ) idx = 0 ; if ( idx >= items . size ( ) ) { items . add ( newItem ) ; } else { items . add ( idx , newItem ) ; } } }
Moves the item either up or down in the list for that submenu