MsgViewHolderRecommendAssistant.java 3.46 KB
Newer Older
konghaorui committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
package com.yidianling.im.session.viewholder;

import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseApp;
import com.yidianling.im.R;
import com.yidianling.im.helper.IMUtil;
import com.yidianling.im.session.extension.CustomAttachmentRecommendAssistant;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;


/**
 * Created by Wi1ls on 2016/12/14;
 */
public class MsgViewHolderRecommendAssistant extends MsgViewHolderBase {
    private String touid;//userType=1,表示助手uid;type=2表示用户uid
    private String img;//头像
    private String name;//用户名
    private String usertype;//1表示用户收到,2表示助手收到 3咨询师名片
    private String title;//用以消息列表展示

    private ImageView recommend_head;
    private TextView recommend_title;
    private TextView recommend_content;
    private TextView recommend_type;

    private String custom_receiver = "ta会协助你解决咨询相关的问题";
    private String assistant_receiver = "ta需要你协助解决咨询相关的问题";

    public MsgViewHolderRecommendAssistant(BaseMultiItemFetchLoadAdapter adapter) {
        super(adapter);
    }

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

    @Override
    protected void inflateContentView() {
        recommend_head = (ImageView) view.findViewById(R.id.recommend_head);
        recommend_title = (TextView) view.findViewById(R.id.recommend_title);
        recommend_content = (TextView) view.findViewById(R.id.recommend_content);
        recommend_type = (TextView) view.findViewById(R.id.recommend_type);
    }

    @Override
    protected void bindContentView() {
        CustomAttachmentRecommendAssistant customAttachmentRecommendAssistant = (CustomAttachmentRecommendAssistant) message.getAttachment();
        touid = customAttachmentRecommendAssistant.getTouid();
        img = customAttachmentRecommendAssistant.getImg();
        name = customAttachmentRecommendAssistant.getName();
        usertype = customAttachmentRecommendAssistant.getUser_type();
        title = customAttachmentRecommendAssistant.getTitle();
        GlideApp.with(BaseApp.Companion.getInstance()).load(img).into(recommend_head);
        if (usertype != null) {
            switch (usertype) {
                case "1":
                    recommend_title.setText("这是我的助理名片");
                    recommend_content.setText(name);
                    recommend_type.setText("助理名片");
                    break;
                case "2":
                    recommend_title.setText("这是我的客户名片");
                    recommend_content.setText(name);
                    recommend_type.setText("用户名片");
                    break;
                case "3":
                    recommend_title.setText("这是我的咨询师名片");
                    recommend_content.setText(name);
                    recommend_type.setText("咨询师名片");
                    break;
            }
        }
    }

    @Override
    protected void onItemClick() {
        try {
            IMUtil.startChat((AppCompatActivity) context, touid, 0, 0, null, 0, false);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
}