public void registerOnToolbarGroupChangedListener(OnToolbarGroupChangedListener listener){
  for (int i=mListeners.size() - 1; i >= 0; i--) {
    WeakReference<OnToolbarGroupChangedListener> ref=mListeners.get(i);
    if (ref.get() == null)     mListeners.remove(i);
 else     if (ref.get() == listener)     return;
  }
  mListeners.add(new WeakReference<OnToolbarGroupChangedListener>(listener));
}

public void registerOnToolbarGroupChangedListener ( OnToolbarGroupChangedListener listener ) { for ( int i = mListeners . size ( ) - 1 ; i >= 0 ; i -- ) { WeakReference < OnToolbarGroupChangedListener > ref = mListeners . get ( i ) ; if ( ref . get ( ) == null ) mListeners . remove ( i ) ; else if ( ref . get ( ) == listener ) return ; } mListeners . add ( new WeakReference < OnToolbarGroupChangedListener > ( listener ) ) ; }
register a listener for current group changed event . note that it doesn ' t hold any strong reference to listener , so don ' t use anonymous listener .
