@Test public void testCorrectPosition() { final TestModule module = new TestModule(); final int headersCount = 5; final int itemsCount = 10; final int dataSetSize = itemsCount + headersCount; for (int i = 0; i < dataSetSize; i++) { if (i % 2 == 0) module.putHeader(i, createTestHeader()); } for (int i = 0; i < dataSetSize; i++) { assertThat(module.correctPosition(i), is(i - (i / 2 + (i % 2 == 1 ? 1 : 0)))); } }
public int correctPosition(final int position) { return position - countHeadersBeforePosition(position); }
HeadersModule extends AdapterModule { public int correctPosition(final int position) { return position - countHeadersBeforePosition(position); } }
HeadersModule extends AdapterModule { public int correctPosition(final int position) { return position - countHeadersBeforePosition(position); }  }
HeadersModule extends AdapterModule { public int correctPosition(final int position) { return position - countHeadersBeforePosition(position); }  boolean isEmpty(); int size(); boolean isHeaderAt(final int position); @Nullable H getHeader(final int position); @NonNull SparseArray<H> getHeaders(); void clearHeaders(); int correctPosition(final int position); int countHeadersBeforePosition(final int position); void setHeaderStyleAttr(@AttrRes final int styleAttr); @AttrRes int getHeaderStyleAttr(); @NonNull abstract VH createViewHolder(@NonNull ViewGroup parent, int viewType); @NonNull final SimpleHeaderHolder createSimpleHeaderHolder(@NonNull ViewGroup parent); abstract void bindViewHolder(@NonNull VH viewHolder, int position); }
HeadersModule extends AdapterModule { public int correctPosition(final int position) { return position - countHeadersBeforePosition(position); }  boolean isEmpty(); int size(); boolean isHeaderAt(final int position); @Nullable H getHeader(final int position); @NonNull SparseArray<H> getHeaders(); void clearHeaders(); int correctPosition(final int position); int countHeadersBeforePosition(final int position); void setHeaderStyleAttr(@AttrRes final int styleAttr); @AttrRes int getHeaderStyleAttr(); @NonNull abstract VH createViewHolder(@NonNull ViewGroup parent, int viewType); @NonNull final SimpleHeaderHolder createSimpleHeaderHolder(@NonNull ViewGroup parent); abstract void bindViewHolder(@NonNull VH viewHolder, int position);  }