@Override public int getItemViewType(int position) { Pair<ListSectionProxy, Pair<Integer, Integer>> info = getSectionInfoByEntryIndex(position); ListSectionProxy section = info.first; int sectionItemIndex = info.second.second; if (section.isHeaderTitle(sectionItemIndex) || section.isFooterTitle(sectionItemIndex)) return HEADER_FOOTER_TITLE_TYPE; if (section.isHeaderView(sectionItemIndex) || section.isFooterView(sectionItemIndex)) { return HEADER_FOOTER_VIEW_TYPE; } return section.getTemplateByIndex(sectionItemIndex).getType(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get section info from index Pair<ListSectionProxy, Pair<Integer, Integer>> info = getSectionInfoByEntryIndex(position); ListSectionProxy section = info.first; int sectionItemIndex = info.second.second; int sectionIndex = info.second.first; // check marker if (sectionIndex > marker[0] || (sectionIndex == marker[0] && sectionItemIndex >= marker[1])) { proxy.fireEvent(TiC.EVENT_MARKER, null, false); resetMarker(); } View content = convertView; // Handles header/footer views and titles. if (section.isHeaderView(sectionItemIndex) || section.isFooterView(sectionItemIndex)) { return section.getHeaderOrFooterView(sectionItemIndex); } else if (section.isHeaderTitle(sectionItemIndex) || section.isFooterTitle(sectionItemIndex)) { // No content to reuse, so we create a new view if (content == null) { content = inflater.inflate(headerFooterId, null); } TextView title = (TextView) content.findViewById(titleId); title.setText(section.getHeaderOrFooterTitle(sectionItemIndex)); return content; } // Handling templates KrollDict data = section.getListItemData(sectionItemIndex); TiListViewTemplate template = section.getTemplateByIndex(sectionItemIndex); if (content != null) { TiBaseListViewItem itemContent = (TiBaseListViewItem) content.findViewById(listContentId); section.populateViews(data, itemContent, template, sectionItemIndex, sectionIndex, content); } else { content = inflater.inflate(listItemId, null); TiBaseListViewItem itemContent = (TiBaseListViewItem) content.findViewById(listContentId); LayoutParams params = new LayoutParams(); params.autoFillsWidth = true; itemContent.setLayoutParams(params); section.generateCellContent( sectionIndex, data, template, itemContent, sectionItemIndex, content); } return content; }