question: int findGroupPosition ( long groupIdToMatch , int seedGroupPosition ) { int count = mExpandableListAdapter . getGroupCount ( ) ; if ( count == 0 ) { return android . widget . AdapterView . INVALID_POSITION ; } if ( groupIdToMatch == android . widget . AdapterView . INVALID_ROW_ID ) { return android . widget . AdapterView . INVALID_POSITION ; } seedGroupPosition = Math . max ( 0 , seedGroupPosition ) ; seedGroupPosition = Math . min ( count - 1 , seedGroupPosition ) ; long endTime = SystemClock . uptimeMillis ( ) + AdapterView . SYNC_MAX_DURATION_MILLIS ; long rowId ; int first = seedGroupPosition ; int last = seedGroupPosition ; boolean next = false ; boolean hitFirst ; boolean hitLast ; ExpandableListAdapter adapter = getAdapter ( ) ; if ( adapter == null ) { return android . widget . AdapterView . INVALID_POSITION ; } while ( SystemClock . uptimeMillis ( ) <= endTime ) { rowId = adapter . getGroupId ( seedGroupPosition ) ; if ( rowId == groupIdToMatch ) { return seedGroupPosition ; } hitLast = last == count - 1 ; hitFirst = first == 0 ; if ( hitLast && hitFirst ) { break ; } if ( hitFirst || ( next && ! hitLast ) ) { last ++ ; seedGroupPosition = last ; next = false ; } else if ( hitLast || ( ! next && ! hitFirst ) ) { first -- ; seedGroupPosition = first ; next = true ; } } return android . widget . AdapterView . INVALID_POSITION ; }
target:  Searches the expandable list adapter for a group position matching the given group ID. The search starts at the given seed position and then alternates between moving up and moving down until 1) we find the right position, or 2) we run out of time, or 3) we have looked at every position