com.sibvisions.android.widget
Class TreeAdapter

java.lang.Object
  extended by android.widget.BaseExpandableListAdapter
      extended by com.sibvisions.android.widget.TreeAdapter
All Implemented Interfaces:
ExpandableListAdapter, IControl

public class TreeAdapter
extends BaseExpandableListAdapter
implements IControl

The TreeAdapter is a BaseExpandableListAdapter which gets data from an IDataBook implementation. It supports ExpandableListView. The adapter uses the first primary key column to identify the items. Ensure that the primary key column is set. The display values will be read from the table columns of the databook. If you didn't specify special column view resource ids, then the first column of the table columns will be set into the first found view (Text, Image, Checkbox). If you specified the column view resource ids, then the columns out of the table columns will be used in the same order as the column view resource ids were set.


Nested Class Summary
static interface TreeAdapter.ValueFormatter
          The ValueFormatter allows changing the value before it will be set to a view.
 
Constructor Summary
TreeAdapter(Context pContext, IDataBook pDataBookGroup, IDataBook pDataBookChild, int pGroupLayout, int pChildLayout)
          Creates a new instance of TreeAdapter.
TreeAdapter(Context pContext, IDataBook pDataBook, int pGroupLayout, int pChildLayout)
          Creates a new instance of TreeAdapter.
 
Method Summary
protected  void bindView(View pView, int[] pColumnViewResourceIds, IDataPage pDataPage, int pPosition)
          Binds an existing view to the data pointed to by databook.
 void cancelEditing()
          
protected  View createChildView(ViewGroup pParent)
          Creates a new child view to hold the data pointed to by databook.
protected  View createGroupView(ViewGroup pParent)
          Creates a new group view to hold the data pointed to by databook.
 IChangeableDataRow getChild(int pGroupPosition, int pChildPosition)
          
 int[] getChildColumnViewResources()
          Gets the resource ids of child views which should be filled with values from the databook.
 long getChildId(int pGroupPosition, int pChildPosition)
          
 int getChildrenCount(int pGroupPosition)
          
 View getChildView(int pGroupPosition, int pChildPosition, boolean pIsLastChild, View pConvertView, ViewGroup pParent)
          
protected  Context getContext()
          Gets the applications global information.
 IChangeableDataRow getGroup(int pGroupPosition)
          
 int[] getGroupColumnViewResources()
          Gets the resource ids of group views which should be filled with values from the databook.
 int getGroupCount()
          
 long getGroupId(int pGroupPosition)
          
 View getGroupView(int pGroupPosition, boolean isExpanded, View pConvertView, ViewGroup pParent)
          
 TranslationMap getTranslation()
          
 TreeAdapter.ValueFormatter getValueFormatter()
          Gets the current value formatter.
 boolean hasStableIds()
          
 boolean isChildSelectable(int pGroupPosition, int pChildPosition)
          
 void notifyRepaint()
          
 void saveEditing()
          
 void setChildColumnViewResources(int[] pViewResourceIds)
          Sets the resource ids of child views which should be filled with values from the databook.
 void setGroupColumnViewResources(int[] pViewResourceIds)
          Sets the resource ids of group views which should be filled with values from the databook.
 void setTranslation(TranslationMap pTranslation)
          
 void setValueFormatter(TreeAdapter.ValueFormatter pFormatter)
          Sets the formatter to change values before they will be set to a view.
 
Methods inherited from class android.widget.BaseExpandableListAdapter
areAllItemsEnabled, getCombinedChildId, getCombinedGroupId, isEmpty, notifyDataSetChanged, notifyDataSetInvalidated, onGroupCollapsed, onGroupExpanded, registerDataSetObserver, unregisterDataSetObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeAdapter

public TreeAdapter(Context pContext,
                   IDataBook pDataBook,
                   int pGroupLayout,
                   int pChildLayout)
Creates a new instance of TreeAdapter.

Parameters:
pContext - interface to application's global information
pDataBook - a self joined databook
pGroupLayout - the group layout
pChildLayout - the child layout

TreeAdapter

public TreeAdapter(Context pContext,
                   IDataBook pDataBookGroup,
                   IDataBook pDataBookChild,
                   int pGroupLayout,
                   int pChildLayout)
Creates a new instance of TreeAdapter.

Parameters:
pContext - interface to application's global information
pDataBookGroup - a databook for group data
pDataBookChild - a databook for child data
pGroupLayout - the group layout
pChildLayout - the child layout
Method Detail

notifyRepaint

public void notifyRepaint()

Specified by:
notifyRepaint in interface IControl

saveEditing

public void saveEditing()

Specified by:
saveEditing in interface IControl

cancelEditing

public void cancelEditing()

Specified by:
cancelEditing in interface IControl

setTranslation

public void setTranslation(TranslationMap pTranslation)

Specified by:
setTranslation in interface IControl

getTranslation

public TranslationMap getTranslation()

Specified by:
getTranslation in interface IControl

getGroupCount

public int getGroupCount()

Specified by:
getGroupCount in interface ExpandableListAdapter

getGroup

public IChangeableDataRow getGroup(int pGroupPosition)

Specified by:
getGroup in interface ExpandableListAdapter

getGroupId

public long getGroupId(int pGroupPosition)

Specified by:
getGroupId in interface ExpandableListAdapter

getGroupView

public View getGroupView(int pGroupPosition,
                         boolean isExpanded,
                         View pConvertView,
                         ViewGroup pParent)

Specified by:
getGroupView in interface ExpandableListAdapter

getChildrenCount

public int getChildrenCount(int pGroupPosition)

Specified by:
getChildrenCount in interface ExpandableListAdapter

getChild

public IChangeableDataRow getChild(int pGroupPosition,
                                   int pChildPosition)

Specified by:
getChild in interface ExpandableListAdapter

getChildId

public long getChildId(int pGroupPosition,
                       int pChildPosition)

Specified by:
getChildId in interface ExpandableListAdapter

getChildView

public View getChildView(int pGroupPosition,
                         int pChildPosition,
                         boolean pIsLastChild,
                         View pConvertView,
                         ViewGroup pParent)

Specified by:
getChildView in interface ExpandableListAdapter

hasStableIds

public boolean hasStableIds()

Specified by:
hasStableIds in interface ExpandableListAdapter

isChildSelectable

public boolean isChildSelectable(int pGroupPosition,
                                 int pChildPosition)

Specified by:
isChildSelectable in interface ExpandableListAdapter

getContext

protected Context getContext()
Gets the applications global information.

Returns:
the information context

setGroupColumnViewResources

public void setGroupColumnViewResources(int[] pViewResourceIds)
Sets the resource ids of group views which should be filled with values from the databook.

Parameters:
pViewResourceIds - the resource ids within a layout

getGroupColumnViewResources

public int[] getGroupColumnViewResources()
Gets the resource ids of group views which should be filled with values from the databook.

Returns:
the resource ids within a layout

setChildColumnViewResources

public void setChildColumnViewResources(int[] pViewResourceIds)
Sets the resource ids of child views which should be filled with values from the databook.

Parameters:
pViewResourceIds - the resource ids within a layout

getChildColumnViewResources

public int[] getChildColumnViewResources()
Gets the resource ids of child views which should be filled with values from the databook.

Returns:
the resource ids within a layout

createGroupView

protected View createGroupView(ViewGroup pParent)
Creates a new group view to hold the data pointed to by databook.

Parameters:
pParent - the parent to which the new view is attached to
Returns:
the newly created view.

createChildView

protected View createChildView(ViewGroup pParent)
Creates a new child view to hold the data pointed to by databook.

Parameters:
pParent - the parent to which the new view is attached to
Returns:
the newly created view.

bindView

protected void bindView(View pView,
                        int[] pColumnViewResourceIds,
                        IDataPage pDataPage,
                        int pPosition)
Binds an existing view to the data pointed to by databook.

Parameters:
pView - existing view, returned earlier by createView
pColumnViewResourceIds - a list of resource ids for specific binding of values
pDataPage - the data page
pPosition - the row position in the data page

setValueFormatter

public void setValueFormatter(TreeAdapter.ValueFormatter pFormatter)
Sets the formatter to change values before they will be set to a view.

Parameters:
pFormatter - the formatter or null to unset

getValueFormatter

public TreeAdapter.ValueFormatter getValueFormatter()
Gets the current value formatter.

Returns:
the formatter or null if no formatter will be used


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.