question: protected boolean switchProfiles ( IProfile newSelection ) { if ( newSelection == null ) { return false ; } if ( mCurrentProfile == newSelection ) { return true ; } if ( mAlternativeProfileHeaderSwitching ) { int prevSelection = - 1 ; if ( mProfileFirst == newSelection ) { prevSelection = 1 ; } else if ( mProfileSecond == newSelection ) { prevSelection = 2 ; } else if ( mProfileThird == newSelection ) { prevSelection = 3 ; } IProfile tmp = mCurrentProfile ; mCurrentProfile = newSelection ; if ( prevSelection == 1 ) { mProfileFirst = tmp ; } else if ( prevSelection == 2 ) { mProfileSecond = tmp ; } else if ( prevSelection == 3 ) { mProfileThird = tmp ; } } else { if ( mProfiles != null ) { ArrayList < IProfile > previousActiveProfiles = new ArrayList < > ( Arrays . asList ( mCurrentProfile , mProfileFirst , mProfileSecond , mProfileThird ) ) ; if ( previousActiveProfiles . contains ( newSelection ) ) { int position = - 1 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( previousActiveProfiles . get ( i ) == newSelection ) { position = i ; break ; } } if ( position != - 1 ) { previousActiveProfiles . remove ( position ) ; previousActiveProfiles . add ( 0 , newSelection ) ; mCurrentProfile = previousActiveProfiles . get ( 0 ) ; mProfileFirst = previousActiveProfiles . get ( 1 ) ; mProfileSecond = previousActiveProfiles . get ( 2 ) ; mProfileThird = previousActiveProfiles . get ( 3 ) ; } } else { mProfileThird = mProfileSecond ; mProfileSecond = mProfileFirst ; mProfileFirst = mCurrentProfile ; mCurrentProfile = newSelection ; } } } if ( mOnlySmallProfileImagesVisible ) { mProfileThird = mProfileSecond ; mProfileSecond = mProfileFirst ; mProfileFirst = mCurrentProfile ; } buildProfiles ( ) ; return false ; }
target:  helper method to switch the profiles