public void apply(List items){
  int size=items.size();
  if (size > 0) {
    if (comparator != null) {
      Collections.sort(items,comparator);
    }
    for (int i=-1; i < size; i++) {
      HeaderItem headerItem;
      if (i == -1) {
        headerItem=groupingFunction.group(null,(Item)items.get(i + 1),i);
      }
 else       if (i == items.size() - 1) {
        headerItem=groupingFunction.group((Item)items.get(i),null,i);
      }
 else {
        headerItem=groupingFunction.group((Item)items.get(i),(Item)items.get(i + 1),i);
      }
      if (headerItem != null) {
        items.add(i + 1,headerItem);
        i=i + 1;
      }
    }
  }
  if (itemAdapter != null) {
    itemAdapter.set(items);
  }
  if (genericItemAdapter != null) {
    genericItemAdapter.setModel(items);
  }
}

public void apply ( List items ) { int size = items . size ( ) ; if ( size > 0 ) { if ( comparator != null ) { Collections . sort ( items , comparator ) ; } for ( int i = - 1 ; i < size ; i ++ ) { HeaderItem headerItem ; if ( i == - 1 ) { headerItem = groupingFunction . group ( null , ( Item ) items . get ( i + 1 ) , i ) ; } else if ( i == items . size ( ) - 1 ) { headerItem = groupingFunction . group ( ( Item ) items . get ( i ) , null , i ) ; } else { headerItem = groupingFunction . group ( ( Item ) items . get ( i ) , ( Item ) items . get ( i + 1 ) , i ) ; } if ( headerItem != null ) { items . add ( i + 1 , headerItem ) ; i = i + 1 ; } } } if ( itemAdapter != null ) { itemAdapter . set ( items ) ; } if ( genericItemAdapter != null ) { genericItemAdapter . setModel ( items ) ; } }
call this when your list order has changed or was updated , and you have to readd the headres
