package com.bokecc.room.ui.view.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.bokecc.room.ui.R;
import com.bokecc.room.ui.model.NamedTime;
import com.bokecc.sskt.base.bean.AnswerUser;
import com.bokecc.sskt.base.bean.CCQuestionAnswerBean;


/**
 * 作者 ${CC视频}.<br/>
 */

public class QuestionAnswerListAdapter extends BaseRecycleAdapter<QuestionAnswerListAdapter.QuestionListViewHolder, CCQuestionAnswerBean> {

    public QuestionAnswerListAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindViewHolder(QuestionListViewHolder holder, int position) {
        if (mDatas.size() - 1 == position){
            holder.answer_divide.setVisibility(View.GONE);
        }

        CCQuestionAnswerBean questionAnswerBean = mDatas.get(position);
        holder.tv_question_answer_content.setText(questionAnswerBean.getContent());
        if (questionAnswerBean.getIsPrivate() == 1){
            holder.tv_answer_is_public.setVisibility(View.VISIBLE);
        } else {
            holder.tv_answer_is_public.setVisibility(View.GONE);
        }

        holder.tv_question_answer_time.setText(String.valueOf(questionAnswerBean.getTime()));
        holder.tv_answer_number.setText(questionAnswerBean.getAnswerUser().getName());

    }

    @Override
    public int getItemView(int viewType) {
        return R.layout.cc_item_question_answer_list;
    }

    @Override
    public QuestionListViewHolder getViewHolder(View itemView, int viewType) {
        return new QuestionListViewHolder(itemView);
    }

    static class QuestionListViewHolder extends BaseRecycleAdapter.BaseViewHolder {
        TextView tv_answer_number;
        TextView tv_answer_is_public;
        TextView tv_question_answer_time;
        TextView tv_question_answer_content;
        View answer_divide;


        QuestionListViewHolder(View itemView) {
            super(itemView);
            tv_answer_number = itemView.findViewById(R.id.tv_answer_number);
            tv_answer_is_public = itemView.findViewById(R.id.tv_answer_is_public);
            tv_question_answer_time = itemView.findViewById(R.id.tv_question_answer_time);
            tv_question_answer_content = itemView.findViewById(R.id.tv_question_answer_content);
            answer_divide = itemView.findViewById(R.id.answer_divide);
        }
    }

}
