package circlebinder.common.circle;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.ichigotake.common.widget.CursorAdapter;
import net.ichigotake.common.widget.CursorItemConverter;

import circlebinder.common.R;
import circlebinder.common.event.Circle;

public final class CircleAdapter extends CursorAdapter<Circle, CircleViewHolder> {



    public CircleAdapter(Context context, Cursor cursor, CursorItemConverter<Circle> converter) {
        super(context, cursor, converter);
    }

    @Override
    public CircleViewHolder generateTag(int position, Circle item, View convertView) {
        return new CircleViewHolder(convertView);
    }

    @Override
    public View generateView(int position, Circle item, LayoutInflater inflater, ViewGroup parent) {
        return inflater.inflate(R.layout.circlebinder_circle_list_item, parent, false);
    }

    @Override
    public void bindView(int position, Circle item, CircleViewHolder tag) {
        tag.getCircleName().setText(item.getName());
        tag.getPenName().setText(item.getPenName());

        tag.getSpace().setCompoundDrawablesWithIntrinsicBounds(
                0,
                item.getChecklistColor().getDrawableResource(),
                0,
                0
        );
        tag.getSpace().setText(
                String.format("%s%02d%s",
                        item.getSpace().getBlockName(), item.getSpace().getNo(), item.getSpace().getNoSub())
        );
        tag.getGenre().setText(item.getGenre().getName());
    }

}

@@ -186,16 +186,48 @@
 ewGroup;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -327,16 +327,74 @@
 nverter;
+%0Aimport net.ichigotake.common.widget.SectionHeaderAdapter;
 %0A%0Aimport
@@ -470,14 +470,8 @@
 lic 
-final 
 clas
@@ -537,12 +537,94 @@
 der%3E
- %7B%0A%0A
+%0A        implements SectionHeaderAdapter %7B%0A%0A    private final LayoutInflater inflater;
 %0A%0A  
@@ -762,16 +762,70 @@
 erter);%0A
+        this.inflater = LayoutInflater.from(context);%0A
     %7D%0A%0A 
@@ -1843,10 +1843,556 @@
 %0A    %7D%0A%0A
+    @Override%0A    public View getHeaderView(int i, View view, ViewGroup viewGroup) %7B%0A        View headerView = inflater.inflate(R.layout.circlebinder_list_sub_header, viewGroup, false);%0A        TextView subHeaderView = (TextView) headerView.findViewById(R.id.circlebinder_list_sub_header);%0A        Circle circle = getItem(i);%0A        subHeaderView.setText(circle.getSpace().getBlockName());%0A        return headerView;%0A    %7D%0A%0A    @Override%0A    public long getHeaderId(int i) %7B%0A        return  getItem(i).getSpace().getBlockName().charAt(0);%0A    %7D%0A
 %7D%0A

Implement SectionHeaderAdapter on CircleAdapter