es.ugr.swad.swadroid.modules.groups
Class GroupsCursorTreeAdapter

java.lang.Object
  extended by CursorTreeAdapter
      extended by es.ugr.swad.swadroid.modules.groups.GroupsCursorTreeAdapter

public class GroupsCursorTreeAdapter
extends CursorTreeAdapter

Adapter to populate with cursors data an expandable list. The groups represent group types and their child represent every group of this group type. There are two kind of layout: one for the groups and one for the childs

Author:
Helena Rodriguez Gijon

Field Summary
private  java.util.HashMap<java.lang.Long,java.lang.Integer> childChecked
           
private  java.util.HashMap<java.lang.Long,Cursor> childCursors
           
private  int childLayout
           
private  java.util.HashMap<java.lang.Long,java.lang.Integer> childMultiple
           
private  int groupLayout
           
private  Cursor groupsCursor
           
private  LayoutInflater mInflater
           
 
Constructor Summary
GroupsCursorTreeAdapter(Context context, Cursor groupsCursor, java.util.HashMap<java.lang.Long,Cursor> childCursors, int groupLayout, int childlayout)
          Constructor
 
Method Summary
protected  void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild)
           
protected  void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded)
           
 boolean checkItem(int groupPosition, int childPosition)
          The implementation of expandable list recycle the view.
protected  Cursor getChildrenCursor(Cursor groupCursor)
           
 java.lang.String getChosenGroupCodes()
           
private  void getMultipleGroups()
           
 boolean isChildSelectable(int groupPosition, int childPosition)
           
protected  View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent)
           
protected  View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent)
           
 void resetChecked()
          Set the initial selected items to groups to which the user is actually enrolled.
private  void setCheckedStateToDB()
          Until the user clicks on any groups, the selected items are the groups to which the user is actually enrolled, like the database shows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mInflater

private LayoutInflater mInflater

groupLayout

private int groupLayout

childLayout

private int childLayout

groupsCursor

private Cursor groupsCursor

childCursors

private java.util.HashMap<java.lang.Long,Cursor> childCursors

childChecked

private java.util.HashMap<java.lang.Long,java.lang.Integer> childChecked

childMultiple

private java.util.HashMap<java.lang.Long,java.lang.Integer> childMultiple
Constructor Detail

GroupsCursorTreeAdapter

public GroupsCursorTreeAdapter(Context context,
                               Cursor groupsCursor,
                               java.util.HashMap<java.lang.Long,Cursor> childCursors,
                               int groupLayout,
                               int childlayout)
Constructor

Parameters:
context - The context
groupsCursor - cursor over the database with data of group types.
childCursors - Map the group types id and the cursor that contains all the groups of this group type.
groupLayout - Layout for groups
childLayou - Layout for child's
Method Detail

getMultipleGroups

private void getMultipleGroups()

setCheckedStateToDB

private void setCheckedStateToDB()
Until the user clicks on any groups, the selected items are the groups to which the user is actually enrolled, like the database shows. This method set the initial check state of every child


resetChecked

public void resetChecked()
Set the initial selected items to groups to which the user is actually enrolled.


bindChildView

protected void bindChildView(View view,
                             Context context,
                             Cursor cursor,
                             boolean isLastChild)

bindGroupView

protected void bindGroupView(View view,
                             Context context,
                             Cursor cursor,
                             boolean isExpanded)

getChildrenCursor

protected Cursor getChildrenCursor(Cursor groupCursor)

newChildView

protected View newChildView(Context context,
                            Cursor cursor,
                            boolean isLastChild,
                            ViewGroup parent)

newGroupView

protected View newGroupView(Context context,
                            Cursor cursor,
                            boolean isExpanded,
                            ViewGroup parent)

checkItem

public boolean checkItem(int groupPosition,
                         int childPosition)
The implementation of expandable list recycle the view. Therefore the selected items should be stored. This method stores that information and maintains mutual exclusion between the radio buttons. NOTE: It is necessary to call to notifyDataSetChanged to update the views.


isChildSelectable

public boolean isChildSelectable(int groupPosition,
                                 int childPosition)

getChosenGroupCodes

public java.lang.String getChosenGroupCodes()