package de.tudarmstadt.informatik.hostage.ui2.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.widget.TextView;
import de.tudarmstadt.informatik.hostage.R;
import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;

public class RecordListAdapter extends ExpandableListAdapter {

    public RecordListAdapter(Context context, List<String> listSectionHeaders, HashMap<String, ArrayList<ExpandableListItem>> dataMapping) {
        super(context, listSectionHeaders, dataMapping);
    }


    /*****************************
     *
     *          Required Methods
     *
     * ***************************/

    @Override
    public void configureCellView(View cell, int section, int row) {
        ExpandableListItem object = this.getDataForRow(section, row);
        for (String key : object.getId_Mapping().keySet()){
            int viewID = object.getId_Mapping().get(key);
            String textualInfo = object.getData().get(key);
            TextView tView = (TextView) cell.findViewById(viewID);
            tView.setText(textualInfo);
        }
    }

    @Override
    public void configureSectionHeaderView(View sectionHeader, int section) {
        int headerLabelID = R.id.sectionHeaderTitle;
        TextView tView = (TextView) sectionHeader.findViewById(headerLabelID);
        tView.setText(this._sectionHeader.get(section));
    }

    @Override
    public int getSectionLayoutID() {
        return R.layout.expandable_section_header;
    }

    @Override
    public int getCellLayoutID() {
        return R.layout.record_list_item;
    }
}
