Search in sources :

Example 16 with SectionIndexer

use of android.widget.SectionIndexer in project ABPlayer by winkstu.

the class XStickyListHeadersView method wrapAdapter.

private AdapterWrapper wrapAdapter(ListAdapter adapter) {
    AdapterWrapper wrapper;
    if (adapter instanceof SectionIndexer) {
        wrapper = new SectionIndexerAdapterWrapper(getContext(), (StickyListHeadersAdapter) adapter);
    } else {
        wrapper = new AdapterWrapper(getContext(), (StickyListHeadersAdapter) adapter);
    }
    wrapper.setDivider(mDivider);
    wrapper.setDividerHeight(mDividerHeight);
    wrapper.registerDataSetObserver(mDataSetChangedObserver);
    wrapper.setOnHeaderClickListener(mAdapterHeaderClickListener);
    return wrapper;
}
Also used : SectionIndexerAdapterWrapper(com.emilsjolander.components.stickylistheaders.SectionIndexerAdapterWrapper) SectionIndexer(android.widget.SectionIndexer) StickyListHeadersAdapter(com.emilsjolander.components.stickylistheaders.StickyListHeadersAdapter) SectionIndexerAdapterWrapper(com.emilsjolander.components.stickylistheaders.SectionIndexerAdapterWrapper) AdapterWrapper(com.emilsjolander.components.stickylistheaders.AdapterWrapper)

Example 17 with SectionIndexer

use of android.widget.SectionIndexer in project bdcodehelper by boredream.

the class PinnedSectionListView method findCurrentSectionPosition.

int findCurrentSectionPosition(int fromPosition) {
    ListAdapter adapter = getAdapter();
    // dataset has changed, no candidate
    if (fromPosition >= adapter.getCount())
        return -1;
    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;
    }
    // no candidate found
    return -1;
}
Also used : SectionIndexer(android.widget.SectionIndexer) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter)

Aggregations

SectionIndexer (android.widget.SectionIndexer)17 ListAdapter (android.widget.ListAdapter)10 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)7 Paint (android.graphics.Paint)3 Adapter (android.widget.Adapter)2 BaseAdapter (android.widget.BaseAdapter)2 ExpandableListAdapter (android.widget.ExpandableListAdapter)1 WrapperListAdapter (android.widget.WrapperListAdapter)1 AdapterWrapper (com.emilsjolander.components.stickylistheaders.AdapterWrapper)1 SectionIndexerAdapterWrapper (com.emilsjolander.components.stickylistheaders.SectionIndexerAdapterWrapper)1 StickyListHeadersAdapter (com.emilsjolander.components.stickylistheaders.StickyListHeadersAdapter)1