package com.yidianling.im.session.viewholder;


import android.widget.TextView;

import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachLingxiAnswerQuestion;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;

import java.util.ArrayList;

public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
    private TextView answer_question;
    CustomAttachLingxiAnswerQuestion customattachLingxiAnswerQuestion;
    private ArrayList<QuestionItemBean> itemBeans;
    private StringBuffer sb;
    public MsgViewHolderLingxiAnswerQuestion(BaseMultiItemFetchLoadAdapter adapter) {
        super(adapter);
    }

    @Override
    protected int getContentResId() {
       return  R.layout.im_nim_lingxi_answer_question;
    }

    @Override
    protected void inflateContentView() {
        answer_question = findViewById(R.id.answer_question);

    }

    @Override
    protected boolean isReceivedMessage() {
        return false;
    }


    @Override
    protected void bindContentView() {
        customattachLingxiAnswerQuestion = ((CustomAttachLingxiAnswerQuestion) message.getAttachment());
        itemBeans=customattachLingxiAnswerQuestion.answers;
        sb=new StringBuffer();

        for (int i=0;i<itemBeans.size();i++){
            if (i==(itemBeans.size()-1)&&itemBeans.get(i).getName().contains("其他")){
                sb.append("#"+itemBeans.get(i).getName()+"\r\n ").append(itemBeans.get(i).getOther());
            }else{
                sb.append("#"+itemBeans.get(i).getName()+"  ");

            }
        }
        if (itemBeans.size()==1&&!itemBeans.get(0).getName().contains("其他")){
            answer_question.setText(itemBeans.get(0).getName());
        }else{
            answer_question.setText(sb.toString());
        }
    }
}
