private void updateNavigationPreferences ( ) { List < NavigationPreference > oldNavigationPreferences = new ArrayList <> ( navigationPreferences ) ; navigationPreferences . clear ( ) ; boolean selectedNavigationPreferenceFound = selectedNavigationPreference == null ; for ( int i = 0 ; i < getItemCount ( ) ; i ++ ) { Preference item = getItem ( i ) ; if ( item instanceof NavigationPreference ) { NavigationPreference navigationPreference = ( NavigationPreference ) item ; navigationPreferences . add ( navigationPreference ) ; if ( selectedNavigationPreference == navigationPreference ) { selectedNavigationPreferenceFound = true ; } if ( ! oldNavigationPreferences . contains ( navigationPreference ) ) { notifyOnNavigationPreferenceAdded ( navigationPreference ) ; oldNavigationPreferences . remove ( navigationPreference ) ; } } } for ( NavigationPreference removedNavigationPreference : oldNavigationPreferences ) { notifyOnNavigationPreferenceRemoved ( removedNavigationPreference ) ; } if ( ! selectedNavigationPreferenceFound ) { if ( getNavigationPreferenceCount ( ) > 0 ) { selectNavigationPreference ( Math . min ( selectedNavigationPreferenceIndex , getNavigationPreferenceCount ( ) - 1 ) , null ) ; } else { selectNavigationPreference ( null , null ) ; } } }
Updates the navigation preferences which are contained by the adapter .