Back to project page PodioPuzzle.
The source code is released under:
Apache License
If you think the Android project PodioPuzzle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.podio.podiopuzzle.ui; /*from www. ja v a 2 s . c om*/ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListView; import android.widget.TextView; import com.podio.podiopuzzle.R; import com.podio.podiopuzzle.model.Organization; import com.podio.podiopuzzle.model.Space; import com.podio.podiopuzzle.util.Utility; import java.util.List; import java.util.Map; /** * Created by goman on 30/10/14. */ public class OrganizationExpandAdapter extends BaseExpandableListAdapter { private Context mContext; private List<Organization> listOrganizations; private LayoutInflater mInflater; private ExpandableListView mExpandableList; public OrganizationExpandAdapter(Context context, ExpandableListView expandableListView) { this(context, expandableListView, null); } public OrganizationExpandAdapter(Context context, ExpandableListView expandableListView, List<Organization> listOrganizations) { this.mContext = context; mInflater = LayoutInflater.from(mContext); this.listOrganizations = listOrganizations; this.mExpandableList = expandableListView; } public void setData(List<Organization> listOrganizations) { this.listOrganizations = listOrganizations; notifyDataSetChanged(); } @Override public int getGroupCount() { return Utility.isListNullOrEmpty(listOrganizations) ? 0 : listOrganizations.size() ; } @Override public int getChildrenCount(int groupPosition) { List<?> l = listOrganizations.get(groupPosition).getSpaces(); return Utility.isListNullOrEmpty(l) ? 0 : l.size(); } @Override public String getGroup(int groupPosition) { return Utility.isListNullOrEmpty(listOrganizations) ? null : listOrganizations.get(groupPosition).getName() ; } @Override public String getChild(int groupPosition, int childPosition) { List<Space> l = listOrganizations.get(groupPosition).getSpaces(); return Utility.isListNullOrEmpty(l) ? null : l.get(childPosition).getName(); } @Override public long getGroupId(int groupPosition) { return 0; } @Override public long getChildId(int groupPosition, int childPosition) { return 0; } @Override public boolean hasStableIds() { return false; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { TitleHolder holder; if (convertView == null){ holder = new TitleHolder(); convertView = mInflater.inflate(R.layout.simple_title_item, parent, false); holder.textTitle = (TextView) convertView.findViewById(R.id.text1); convertView.setTag(holder); } else{ holder = (TitleHolder) convertView.getTag(); } mExpandableList.expandGroup(groupPosition); holder.textTitle.setText(getGroup(groupPosition)); return convertView; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { BodyHolder holder; if (convertView == null){ holder = new BodyHolder(); convertView = mInflater.inflate(R.layout.simple_body_item, parent, false); holder.textBody = (TextView) convertView.findViewById(R.id.text1); convertView.setTag(holder); } else{ holder = (BodyHolder) convertView.getTag(); } holder.textBody.setText(getChild(groupPosition, childPosition)); return convertView; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } static class TitleHolder{ public TextView textTitle; } static class BodyHolder{ public TextView textBody; } }