de.msponer.android.yac.adapter
Class SectionedWorkListAdapter

java.lang.Object
  extended by android.widget.BaseAdapter
      extended by de.msponer.android.yac.adapter.SectionedWorkListAdapter
All Implemented Interfaces:
Adapter, ListAdapter, SpinnerAdapter

public abstract class SectionedWorkListAdapter
extends BaseAdapter

A sectioned work item adapter. Based on ideas presented in "The Busy Coder's Guide to Advanced Android Development" (see http://commonsware.com/AdvAndroid)

Author:
msponer

Field Summary
 
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
 
Constructor Summary
SectionedWorkListAdapter()
          Constructor.
 
Method Summary
 void addSection(String caption, Adapter adapter)
          Adds a new section.
 boolean areAllItemsSelectable()
          Returns true, if all items are selectable.
 int getCount()
          The section count.
protected abstract  View getHeaderView(String caption, int index, View convertView, ViewGroup parent)
          The header view.
 Object getItem(int position)
          Returns item object located at the given position.
 long getItemId(int position)
           
 int getItemViewType(int position)
          The view type count located at the given position.
 Adapter getSectionAdapter(int section)
          Returns the section adapter located at the given position.
 View getView(int position, View convertView, ViewGroup parent)
           
 int getViewTypeCount()
          The view type count.
 boolean isEnabled(int position)
          Returns true if item at the given position is enabled.
 
Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getDropDownView, hasStableIds, isEmpty, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SectionedWorkListAdapter

public SectionedWorkListAdapter()
Constructor.

Method Detail

getHeaderView

protected abstract View getHeaderView(String caption,
                                      int index,
                                      View convertView,
                                      ViewGroup parent)
The header view.

Parameters:
caption - The caption.
index - The index.
convertView - The view to convert.
parent - The parent view.
Returns:
The resulting header view.

addSection

public void addSection(String caption,
                       Adapter adapter)
Adds a new section.

Parameters:
caption - The section caption.
adapter - The adapter to add.

getItem

public Object getItem(int position)
Returns item object located at the given position.

Parameters:
position - The position.
Returns:
The item object.

getCount

public int getCount()
The section count.

Returns:
The section count.

getViewTypeCount

public int getViewTypeCount()
The view type count.

Specified by:
getViewTypeCount in interface Adapter
Overrides:
getViewTypeCount in class BaseAdapter
Returns:
The view type count.

getItemViewType

public int getItemViewType(int position)
The view type count located at the given position.

Specified by:
getItemViewType in interface Adapter
Overrides:
getItemViewType in class BaseAdapter
Parameters:
position - The position.
Returns:
The view type count.

areAllItemsSelectable

public boolean areAllItemsSelectable()
Returns true, if all items are selectable.

Returns:
true, if all items are selectable.

isEnabled

public boolean isEnabled(int position)
Returns true if item at the given position is enabled.

Specified by:
isEnabled in interface ListAdapter
Overrides:
isEnabled in class BaseAdapter
Parameters:
position - The position to check.
Returns:
true if item at the given position is enabled.

getView

public View getView(int position,
                    View convertView,
                    ViewGroup parent)

getItemId

public long getItemId(int position)

getSectionAdapter

public Adapter getSectionAdapter(int section)
Returns the section adapter located at the given position.

Parameters:
section - The section number to return.
Returns:
The section adapter.