question: 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 ) ) ; }
target:  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.