// Path: ASA/src/com/thesis/asa/contacts/ContactsGroupItem.java
// public class ContactsGroupItem {	
// 	private String label;
// 	private String account;
// 	private int groupId;
// 
// 	public ContactsGroupItem(String l, String a, int id){
// 		label = l;
// 		account = a;
// 		groupId = id;
// 	}
// 
// 	public String getAccount() {
// 		return account;
// 	}
// 
// 	public String getLabel() {
// 		return label;
// 	}
// 
// 	public int getGroupId() {
// 		return groupId;
// 	}
// }


import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import java.util.LinkedHashMap;
import java.util.Map;
import com.thesis.asa.R;
import com.thesis.asa.contacts.ContactsGroupItem;
import android.content.Context;
/*******************************************************************************
 * Copyright (c) 2014 CodingBad.
 * All rights reserved.  This file is part of ASA.
 * 
 * ASA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ASA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ASA.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 * Ayelén Chavez - ashy.on.line@gmail.com
 * Joaquín Rinaudo - jmrinaudo@gmail.com
 ******************************************************************************/
 
 
package com.thesis.asa.mainui;




public class SeparatedListAdapter extends BaseAdapter
{
	public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>();
	public final ArrayAdapter<String> headers;
	public final static int TYPE_SECTION_HEADER = 0;

	public SeparatedListAdapter(Context context)
	{
		headers = new ArrayAdapter<String>(context, R.layout.separated_list_layout);
	}

	public void addSection(String section, Adapter adapter)
	{
		headers.add(section);
		sections.put(section, adapter);
	}
	
	public int getLabelIndexFor(int id) {
		int relativePosition = 0;
		for (Object section : this.sections.keySet()) {			
			Adapter ad = this.sections.get(section);					
			for(int i = 0 ; i < ad.getCount(); i++) {
// Path: ASA/src/com/thesis/asa/contacts/ContactsGroupItem.java
// public class ContactsGroupItem {	
// 	private String label;
// 	private String account;
// 	private int groupId;
// 
// 	public ContactsGroupItem(String l, String a, int id){
// 		label = l;
// 		account = a;
// 		groupId = id;
// 	}
// 
// 	public String getAccount() {
// 		return account;
// 	}
// 
// 	public String getLabel() {
// 		return label;
// 	}
// 
// 	public int getGroupId() {
// 		return groupId;
// 	}
// }


// Path: ASA/src/com/thesis/asa/mainui/SeparatedListAdapter.java
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import java.util.LinkedHashMap;
import java.util.Map;
import com.thesis.asa.R;
import com.thesis.asa.contacts.ContactsGroupItem;
import android.content.Context;

/*******************************************************************************
 * Copyright (c) 2014 CodingBad.
 * All rights reserved.  This file is part of ASA.
 * 
 * ASA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ASA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ASA.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 * Ayelén Chavez - ashy.on.line@gmail.com
 * Joaquín Rinaudo - jmrinaudo@gmail.com
 ******************************************************************************/
 
 
package com.thesis.asa.mainui;




public class SeparatedListAdapter extends BaseAdapter
{
	public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>();
	public final ArrayAdapter<String> headers;
	public final static int TYPE_SECTION_HEADER = 0;

	public SeparatedListAdapter(Context context)
	{
		headers = new ArrayAdapter<String>(context, R.layout.separated_list_layout);
	}

	public void addSection(String section, Adapter adapter)
	{
		headers.add(section);
		sections.put(section, adapter);
	}
	
	public int getLabelIndexFor(int id) {
		int relativePosition = 0;
		for (Object section : this.sections.keySet()) {			
			Adapter ad = this.sections.get(section);					
			for(int i = 0 ; i < ad.getCount(); i++) {
				ContactsGroupItem group = (ContactsGroupItem) ad.getItem(i);