private int calculateIndex(int index){
  index=index - (hasHeader() ? 1 : 0);
  if (index >= items.size()) {
    throw new IllegalStateException("Index has to be defined in range from 0 to items.size() - 1!");
  }
 else {
    return index;
  }
}

private int calculateIndex ( int index ) { index = index - ( hasHeader ( ) ? 1 : 0 ) ; if ( index >= items . size ( ) ) { throw new IllegalStateException ( "Index has to be defined in range from 0 to items.size() - 1!" ) ; } else { return index ; } }
calculate the correct item index - we have to subtract the number of headers of index value as the recyclerview doesn ' t distinguish between header rows and item rows .
