Java Code Examples for android.widget.HeaderViewListAdapter#getWrappedAdapter()

The following examples show how to use android.widget.HeaderViewListAdapter#getWrappedAdapter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PinnedHeaderListView.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
    SectionedBaseAdapter adapter;
    if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) {
        HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
        adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
    } else {
        adapter = (SectionedBaseAdapter) adapterView.getAdapter();
    }
    int section = adapter.getSectionForPosition(rawPosition);
    int position = adapter.getPositionInSectionForPosition(rawPosition);

    if (position == -1) {
        onSectionClick(adapterView, view, section, id);
    } else {
        onItemClick(adapterView, view, section, position, id);
    }
}
 
Example 2
Source File: PinnedHeaderListView.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
    SectionedBaseAdapter adapter;
    if (adapterView.getAdapter() instanceof HeaderViewListAdapter) {
        HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
        adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
    } else {
        adapter = (SectionedBaseAdapter) adapterView.getAdapter();
    }
    int section = adapter.getSectionForPosition(rawPosition);
    int position = adapter.getPositionInSectionForPosition(rawPosition);

    if (position == -1) {
        onSectionClick(adapterView, view, section, id);
    } else {
        onItemClick(adapterView, view, section, position, id);
    }
}
 
Example 3
Source File: Sidebar.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private void setHeaderTextAndscroll(MotionEvent event){
		 if (mListView == null) {
		        //check the mListView to avoid NPE. but the mListView shouldn't be null
		        //need to check the call stack later
		        return;
		    }
		String headerString = sections[sectionForPoint(event.getY())];
		header.setText(headerString);
		  HeaderViewListAdapter ha = (HeaderViewListAdapter) mListView.getAdapter();
		  ContactAdapter  adapter = (ContactAdapter) ha.getWrappedAdapter();
//		ContactAdapter adapter = (ContactAdapter) mListView.getAdapter();
		String[] adapterSections = (String[]) adapter.getSections();
		try {
			for (int i = adapterSections.length - 1; i > -1; i--) {
				if(adapterSections[i].equals(headerString)){
					mListView.setSelection(adapter.getPositionForSection(i));
					break;
				}
			}
		} catch (Exception e) {
			Log.e("setHeaderTextAndscroll", e.getMessage());
		}
		
	}
 
Example 4
Source File: FolderFragment.java    From filemanager with MIT License 6 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
		int visibleItemCount, int totalItemCount)
{		
	if (firstVisibleItem < this.topVisibleItem - DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(true);
		this.topVisibleItem = firstVisibleItem;
	}
	else if (firstVisibleItem > this.topVisibleItem + DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(false);
		this.topVisibleItem = firstVisibleItem;
	}
	
	ListAdapter adapter = view.getAdapter();
	if (adapter instanceof HeaderViewListAdapter)
	{
		HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter;
		if (headerViewListAdapter.getWrappedAdapter() instanceof FileCardAdapter)
		{
			int startPrefetch = firstVisibleItem + visibleItemCount-headerViewListAdapter.getHeadersCount();
			((FileCardAdapter) headerViewListAdapter.getWrappedAdapter()).prefetchImages(startPrefetch, visibleItemCount);
		}
	}
}
 
Example 5
Source File: AdapterUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static CacheAdapter<?> getCacheAdapter(Adapter adapter) {
	if (adapter == null) {
		return null;
	}
	CacheAdapter<?> cacheAdapter = null;
	if (adapter instanceof CacheAdapter<?>) {
        cacheAdapter = (CacheAdapter<?>)adapter;
	} else if (adapter instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter;
		if (headerViewAdapter.getWrappedAdapter() instanceof CacheAdapter<?>) {
			cacheAdapter = (CacheAdapter<?>)headerViewAdapter.getWrappedAdapter();
		}
	}
	
	return cacheAdapter;
}
 
Example 6
Source File: AdapterUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static BaseListAdapter<?> getBaseListAdapter(Adapter adapter) {
	if (adapter == null) {
		return null;
	}
	
	BaseListAdapter<?> baseListAdapter = null;
	if (adapter instanceof BaseListAdapter<?>) {
        baseListAdapter = (BaseListAdapter<?>)adapter;
	} else if (adapter instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter;
		if (headerViewAdapter.getWrappedAdapter() instanceof BaseListAdapter<?>) {
			baseListAdapter = (BaseListAdapter<?>)headerViewAdapter.getWrappedAdapter();
		}
	}
	
	return baseListAdapter;
}
 
Example 7
Source File: HomePageHeaderDoubleClickListener.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private CacheAdapter<?> getCacheAdapter(ListAdapter adapter) {
	CacheAdapter<?> cacheAdapter = null;
	if (adapter instanceof CacheAdapter) {
        cacheAdapter = (CacheAdapter<?>)adapter;
	} else if (adapter instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter;
		if (headerViewAdapter.getWrappedAdapter() instanceof CacheAdapter<?>) {
			cacheAdapter = (CacheAdapter<?>)headerViewAdapter.getWrappedAdapter();
		}
	}
	return cacheAdapter;
}
 
Example 8
Source File: Utilities.java    From rss with GNU General Public License v3.0 4 votes vote down vote up
static
void setTitlesAndDrawerAndPage(Fragment fragment, int absolutePos)
{
    String[] navTitles = s_resources.getStringArray(R.array.navigation_titles);

    if(null != fragment)
    {
        switchToFragment(fragment, false);
    }

    ListView list = s_fragmentDrawer.m_listView;
    HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) list.getAdapter();
    int headers = headerAdapter.getHeadersCount();

    int listPosition = -10 == absolutePos ? s_viewPager.getCurrentItem() + headers : absolutePos;
    int viewPagerPos = -10 == absolutePos ? s_viewPager.getCurrentItem() : absolutePos - headers;

    // Check the drawer item.
    String title = PagerAdapterTags.s_tagList.get(0);
    String subTitle = null;
    int imageRes = R.drawable.ic_action_labels;

    if(s_fragmentFavourites.isVisible())
    {
        listPosition = 0;
        title = navTitles[0];
        imageRes = R.drawable.ic_action_important;
    }
    else if(s_fragmentManage.isVisible())
    {
        listPosition = 1;
        title = navTitles[1];
        imageRes = R.drawable.ic_action_storage;
    }
    else if(s_fragmentSettings.isVisible())
    {
        listPosition = 2;
        title = navTitles[2];
        imageRes = R.drawable.ic_action_settings;
    }
    else
    {
        ArrayAdapter<String[]> adapter = (ArrayAdapter<String[]>) headerAdapter.getWrappedAdapter();

        if(null != adapter && 0 < adapter.getCount())
        {
            String[] item = adapter.getItem(viewPagerPos);
            title = item[0];
            int count = null == item[1] || item[1].isEmpty() ? 0 : Integer.parseInt(item[1]);
            String countString = s_resources.getQuantityString(R.plurals.actionbar_subtitle_unread, count, count);
            subTitle = 0 == count ? null : countString;
        }
    }
    s_actionBar.setTitle(title);
    s_actionBar.setSubtitle(subTitle);
    s_actionBar.setIcon(imageRes);

    list.setItemChecked(listPosition, true);

    // If we must change the view pager page.
    if(0 <= viewPagerPos)
    {
        // Switch the view pager page if different.
        if(s_viewPager.getCurrentItem() != viewPagerPos)
        {
            s_viewPager.setCurrentItem(viewPagerPos);
        }
    }
}