protected HeaderData[] generateHeaderList(StickyGridHeadersSimpleAdapter adapter) { Map<Long, HeaderData> mapping = new HashMap<Long, HeaderData>(); List<HeaderData> headers = new ArrayList<HeaderData>(); for (int i = 0; i < adapter.getCount(); i++) { long headerId = adapter.getHeaderId(i); HeaderData headerData = mapping.get(headerId); if (headerData == null) { headerData = new HeaderData(i); headers.add(headerData); } headerData.incrementCount(); mapping.put(headerId, headerData); } return headers.toArray(new HeaderData[headers.size()]); }
@Override public int getViewTypeCount() { return mDelegate.getViewTypeCount(); }
@Override public boolean hasStableIds() { return mDelegate.hasStableIds(); }
@Override public int getItemViewType(int position) { return mDelegate.getItemViewType(position); }
@Override public View getView(int position, View convertView, ViewGroup parent) { return mDelegate.getView(position, convertView, parent); }
@Override public long getItemId(int position) { return mDelegate.getItemId(position); }
@Override public Object getItem(int position) { return mDelegate.getItem(position); }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { return mDelegate.getHeaderView(mHeaders[position].getRefPosition(), convertView, parent); }
@Override public int getCount() { return mDelegate.getCount(); }
public StickyGridHeadersSimpleAdapterWrapper(StickyGridHeadersSimpleAdapter adapter) { mDelegate = adapter; adapter.registerDataSetObserver(new DataSetObserverExtension()); mHeaders = generateHeaderList(adapter); }