@Override public Object getItem(int position) { SectionAndItem<T> sectionAndItem = getSectionAndItem(position); return (sectionAndItem.getType() == SectionAndItem.Type.GRAPH_OBJECT) ? sectionAndItem.graphObject : null; }
@Override public int getSectionForPosition(int position) { SectionAndItem<T> sectionAndItem = getSectionAndItem(position); if (sectionAndItem != null && sectionAndItem.getType() != SectionAndItem.Type.ACTIVITY_CIRCLE) { return Math.max( 0, Math.min(sectionKeys.indexOf(sectionAndItem.sectionKey), sectionKeys.size() - 1)); } return 0; }
@Override public int getItemViewType(int position) { SectionAndItem<T> sectionAndItem = getSectionAndItem(position); switch (sectionAndItem.getType()) { case SECTION_HEADER: return HEADER_VIEW_TYPE; case GRAPH_OBJECT: return GRAPH_OBJECT_VIEW_TYPE; case ACTIVITY_CIRCLE: return ACTIVITY_CIRCLE_VIEW_TYPE; default: throw new FacebookException("Unexpected type of section and item."); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { SectionAndItem<T> sectionAndItem = getSectionAndItem(position); switch (sectionAndItem.getType()) { case SECTION_HEADER: return getSectionHeaderView(sectionAndItem.sectionKey, convertView, parent); case GRAPH_OBJECT: return getGraphObjectView(sectionAndItem.graphObject, convertView, parent); case ACTIVITY_CIRCLE: // If we get a request for this view, it means we need more data. assert cursor.areMoreObjectsAvailable() && (dataNeededListener != null); dataNeededListener.onDataNeeded(); return getActivityCircleView(convertView, parent); default: throw new FacebookException("Unexpected type of section and item."); } }
@Override public boolean isEnabled(int position) { SectionAndItem<T> sectionAndItem = getSectionAndItem(position); return sectionAndItem.getType() == SectionAndItem.Type.GRAPH_OBJECT; }