code: public static int countItems(final IItemAdapter adapter, boolean countHeaders) {
          return countItems(adapter.getAdapterItems(), countHeaders, false, null);
      }
docs: counts the items in the adapter, respecting subitems regardless of there current visibility
  
  @param adapter      the adapter instance
  @param countHeaders if true, headers will be counted as well
  @return number of items in the adapter