@SuppressWarnings("unchecked") private void refreshExpGroupMetadataList(boolean forceChildrenCountRefresh,boolean syncGroupPositions){
  final ArrayList<GroupMetadata> egml=mExpGroupMetadataList;
  int egmlSize=egml.size();
  int curFlPos=0;
  mTotalExpChildrenCount=0;
  if (syncGroupPositions) {
    boolean positionsChanged=false;
    for (int i=egmlSize - 1; i >= 0; i--) {
      GroupMetadata curGm=egml.get(i);
      int newGPos=findGroupPosition(curGm.gId,curGm.gPos);
      if (newGPos != curGm.gPos) {
        if (newGPos == android.widget.AdapterView.INVALID_POSITION) {
          egml.remove(i);
          egmlSize--;
        }
        curGm.gPos=newGPos;
        if (!positionsChanged)         positionsChanged=true;
      }
    }
    if (positionsChanged) {
      Collections.sort(egml);
    }
  }
  int gChildrenCount;
  int lastGPos=0;
  for (int i=0; i < egmlSize; i++) {
    GroupMetadata curGm=egml.get(i);
    if ((curGm.lastChildFlPos == GroupMetadata.REFRESH) || forceChildrenCountRefresh) {
      gChildrenCount=mExpandableListAdapter.getChildrenCount(curGm.gPos);
    }
 else {
      gChildrenCount=curGm.lastChildFlPos - curGm.flPos;
    }
    mTotalExpChildrenCount+=gChildrenCount;
    curFlPos+=(curGm.gPos - lastGPos);
    lastGPos=curGm.gPos;
    curGm.flPos=curFlPos;
    curFlPos+=gChildrenCount;
    curGm.lastChildFlPos=curFlPos;
  }
}

@ SuppressWarnings ( "unchecked" ) private void refreshExpGroupMetadataList ( boolean forceChildrenCountRefresh , boolean syncGroupPositions ) { final ArrayList < GroupMetadata > egml = mExpGroupMetadataList ; int egmlSize = egml . size ( ) ; int curFlPos = 0 ; mTotalExpChildrenCount = 0 ; if ( syncGroupPositions ) { boolean positionsChanged = false ; for ( int i = egmlSize - 1 ; i >= 0 ; i -- ) { GroupMetadata curGm = egml . get ( i ) ; int newGPos = findGroupPosition ( curGm . gId , curGm . gPos ) ; if ( newGPos != curGm . gPos ) { if ( newGPos == android . widget . AdapterView . INVALID_POSITION ) { egml . remove ( i ) ; egmlSize -- ; } curGm . gPos = newGPos ; if ( ! positionsChanged ) positionsChanged = true ; } } if ( positionsChanged ) { Collections . sort ( egml ) ; } } int gChildrenCount ; int lastGPos = 0 ; for ( int i = 0 ; i < egmlSize ; i ++ ) { GroupMetadata curGm = egml . get ( i ) ; if ( ( curGm . lastChildFlPos == GroupMetadata . REFRESH ) || forceChildrenCountRefresh ) { gChildrenCount = mExpandableListAdapter . getChildrenCount ( curGm . gPos ) ; } else { gChildrenCount = curGm . lastChildFlPos - curGm . flPos ; } mTotalExpChildrenCount += gChildrenCount ; curFlPos += ( curGm . gPos - lastGPos ) ; lastGPos = curGm . gPos ; curGm . flPos = curFlPos ; curFlPos += gChildrenCount ; curGm . lastChildFlPos = curFlPos ; } }
traverses the expanded group metadata list and fills in the flat list positions .
