public int getIndexWithinSections ( int listPosition ) { boolean isSection = false ; int numPrecedingSections = 0 ; for ( Integer sectionPosition : mSections . keySet ( ) ) { if ( listPosition > sectionPosition ) numPrecedingSections ++ ; else if ( listPosition == sectionPosition ) isSection = true ; else break ; } return isSection ? numPrecedingSections : Math . max ( numPrecedingSections - 1 , 0 ) ; }
Finds the section index for a given list position .