@Override public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) { List<IHolderSource> holderSources = new ArrayList<IHolderSource>(); LinkedHashMap<String, List<IHolderSource>> tableData = getIndexableContactsList(cursor); HashMap<String, Integer> sectionIndex = new HashMap<String, Integer>(); int index = 0; for (LinkedHashMap.Entry<String, List<IHolderSource>> entry : tableData.entrySet()) { holderSources.addAll(entry.getValue()); if (!entry.getValue().isEmpty()) { AlphabeticalCaption header = new AlphabeticalCaption(entry.getKey()); holderSources.add(index, header); // Increment index to account for section header index++; sectionIndex.put(entry.getKey(), index); index += entry.getValue().size(); } } mList.setFastScrollAlwaysVisible(ALPHABETICAL_PANEL_SHOW_ALWAYS); mList.setFastScrollEnabled(ALPHABETICAL_PANEL_ENABLED); mList.setVerticalScrollBarEnabled(false); if (ALPHABETICAL_PANEL_ENABLED) { mAdapter.setPositionMap(sectionIndex); ((IndexableListView) mList).setSearchView(((MainActivity) getActivity()).getSearchView()); } mAdapter.updateSours(holderSources); }
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); // hide index scroller to prevent sticky central letter effect if (mList != null && ALPHABETICAL_PANEL_ENABLED && !ALPHABETICAL_PANEL_SHOW_ALWAYS) { ((IndexableListView) mList).hideIndexScroller(); } }