@Override public int getItemViewType(int position) { if (pattern.insertForIndex(position)) { return super.getViewTypeCount(); } return super.getItemViewType(position); }
private int getOffsetForIndex(int index) { int offset = 0; for (int i = 0; i < index; i++) { if (pattern.insertForIndex(i)) { offset++; } } return offset; }
private int getTotalCount(int countWrappedAdapter) { int offset = 0; int totalListSize = countWrappedAdapter; for (int i = 0; i < totalListSize; i++) { if (pattern.insertForIndex(i)) { offset++; totalListSize++; } } return countWrappedAdapter + offset; }
@Override public View getView(int i, View view, ViewGroup viewGroup) { if (pattern.insertForIndex(i)) return viewProvider.getView(i, view, viewGroup); return wrappedAdapter.getView(i - getOffsetForIndex(i), view, viewGroup); }
@Override public long getItemId(int i) { if (pattern.insertForIndex(i)) return -1L; return wrappedAdapter.getItemId(i - getOffsetForIndex(i)); }
@Override public Object getItem(int i) { if (pattern.insertForIndex(i)) return null; return wrappedAdapter.getItem(i - getOffsetForIndex(i)); }