package circlebinder.common.dashboard;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.ichigotake.common.app.OnClickToTrip;
import net.ichigotake.common.widget.SectionHeaderBinder;

import circlebinder.common.R;

public final class DashboardItemBinder
        implements SectionHeaderBinder<DashboardItem, DashboardItemViewHolder, DashboardHeaderViewHolder> {

    @Override
    public DashboardHeaderViewHolder generateHeaderTag(int position, DashboardItem item,
                                                       View convertView) {
        return new DashboardHeaderViewHolder(convertView);
    }

    @Override
    public View generateHeaderView(int position, DashboardItem item, LayoutInflater inflater) {
        return inflater.inflate(R.layout.circlebinder_dashboard_header, null);
    }

    @Override
    public void bindHeaderView(int position, DashboardItem item, DashboardHeaderViewHolder holder) {
        holder.getLabel().setText(item.getSectionTitle());
    }

    @Override
    public long getHeaderId(int position, DashboardItem item) {
        return item.getSectionTitleId();
    }

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

    @Override
    public View generateView(int position, DashboardItem item, LayoutInflater inflater, ViewGroup parent) {
        return inflater.inflate(R.layout.circlebinder_dashboard_item, null);
    }

    @Override
    public void bindView(int position, DashboardItem item, DashboardItemViewHolder tag) {
        tag.getLabel().setText(item.getLabel());
        tag.getLabel().setOnClickListener(new OnClickToTrip(item.getTripper()));
    }
}

@@ -1693,24 +1693,139 @@
 etLabel());%0A
+        if (item.getTripper() == null) %7B%0A            tag.getLabel().setOnClickListener(null);%0A        %7D else %7B%0A    
         tag.
@@ -1889,20 +1889,30 @@
 ripper()));%0A
+        %7D%0A
     %7D%0A%7D%0A

fix bug on Dashboard item click when Tripper is null