package kz.arta.synergy.workflow.mobile.android.works.adapters;

/**
 * Created by neox on 22.04.14.
 * Адаптер списка комментариев для завершения работы с формой завершения комментарий
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import kz.arta.synergy.workflow.mobile.android.R;
import kz.arta.synergy.workflow.mobile.android.common.utils.Fonts;
import kz.arta.synergy.workflow.mobile.android.works.models.ResultWorkItem;

public class AdapterCompletionWorkComment extends ArrayAdapter<ResultWorkItem> {

    private List<ResultWorkItem> works;
    private Context context;

    public AdapterCompletionWorkComment(Context context, List<ResultWorkItem> works) {
        super(context, R.layout.user_chooser_activity, works);
        this.works = works;
        this.context = context;
    }

    @Override
    public View getView(int i, View someView, ViewGroup arg2) {

        LayoutInflater inflater = LayoutInflater.from(context);
        if (someView == null) {
            someView = inflater.inflate(R.layout.item_completion_work_comment_list, arg2, false);
        }

        TextView name = (TextView) someView.findViewById(R.id.completion_work_comment_comment_name);
        name.setText(works.get(i).getUser_name());
        name.setTypeface(Fonts.getRoman(context));

        TextView textComment = (TextView) someView.findViewById(R.id.completion_work_comment_comment_text);
        textComment.setText(works.get(i).getComment());
        textComment.setTypeface(Fonts.getRoman(context));

        TextView time = (TextView) someView.findViewById(R.id.completion_work_comment_comment_time);
        time.setText(works.get(i).getCreated());
        time.setTypeface(Fonts.getMedium(context));

        return someView;
    }
}