List of usage examples for android.widget SectionIndexer getSectionForPosition
int getSectionForPosition(int position);
From source file:com.dm.xz.views.PinnedSectionListView.java
int findCurrentSectionPosition(int fromPosition) { ListAdapter adapter = getAdapter();/*from w w w.j a v a 2s .c o m*/ if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate if (adapter instanceof SectionIndexer) { // try fast way by asking section indexer SectionIndexer indexer = (SectionIndexer) adapter; int sectionPosition = indexer.getSectionForPosition(fromPosition); int itemPosition = indexer.getPositionForSection(sectionPosition); int typeView = adapter.getItemViewType(itemPosition); if (isItemViewTypePinned(adapter, typeView)) { return itemPosition; } // else, no luck } // try slow way by looking through to the next section item above for (int position = fromPosition; position >= 0; position--) { int viewType = adapter.getItemViewType(position); if (isItemViewTypePinned(adapter, viewType)) return position; } return -1; // no candidate found }
From source file:com.yahala.ui.Views.PinnedSectionListView.java
int findCurrentSectionPosition(int fromPosition) { ListAdapter adapter = getAdapter();/*from w w w. j a v a 2s. c o m*/ if (adapter instanceof SectionIndexer) { // try fast way by asking section indexer SectionIndexer indexer = (SectionIndexer) adapter; int sectionPosition = indexer.getSectionForPosition(fromPosition); int itemPosition = indexer.getPositionForSection(sectionPosition); int typeView = adapter.getItemViewType(itemPosition); if (isItemViewTypePinned(adapter, typeView)) { return itemPosition; } // else, no luck } // try slow way by looking through to the next section item above for (int position = fromPosition; position >= 0; position--) { int viewType = adapter.getItemViewType(position); if (isItemViewTypePinned(adapter, viewType)) return position; } return -1; // no candidate found }