MsgViewHolderConsultSubScribe.java 4.63 KB
Newer Older
konghaorui committed
1 2
package com.yidianling.im.session.viewholder;

YKai committed
3
import androidx.core.content.ContextCompat;
konghaorui committed
4 5 6 7 8 9 10 11 12
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.yidianling.im.R;
刘鹏 committed
13
import com.yidianling.im.config.constants.ImConstants;
konghaorui committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
import com.yidianling.im.session.extension.CustomAttachConsultSubScript;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;

/**
 * author : harvie
 * 确认咨询预约消息
 */

public class MsgViewHolderConsultSubScribe extends MsgViewHolderBase {

    private TextView tv_title,tv_content,tv_date,tv_time_long,tv_type,tv_package;
    private ImageView img_icon;
    private View lin_root;

    public String title; //自定义消息标题
    public String productName;//商品名称
    public String consultDate;//咨询时间
    public String consultTime;//咨询时长
    public String consultType;//咨询方式
    public String url;//跳转url
    public int flag;//0 未确认 1已确认
    public byte isPackage;
刘鹏 committed
37
    /***新订单id*/
刘鹏 committed
38
    public String newOrderId;
konghaorui committed
39 40 41 42 43 44 45

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

    @Override
    protected int getContentResId() {
konghaorui committed
46
        return R.layout.im_ui_message_custom_consult_subscribe;
konghaorui committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    }

    @Override
    protected void inflateContentView() {
        lin_root = view.findViewById(R.id.lin_root);
        tv_title = view.findViewById(R.id.tv_title);
        tv_content = view.findViewById(R.id.tv_content);
        tv_date = view.findViewById(R.id.tv_date);
        tv_time_long = view.findViewById(R.id.tv_time_long);
        tv_type = view.findViewById(R.id.tv_type);
        img_icon = view.findViewById(R.id.img_icon);
        tv_package = view.findViewById(R.id.tv_package);

        if (isReceivedMessage()){
            setAvatarRightInVisibity();
konghaorui committed
62
            lin_root.setBackgroundResource(R.drawable.im_bg_radius_no_topleft_white_8);
konghaorui committed
63 64
        }else {
            setAvatarLeftInVisibity();
konghaorui committed
65
            lin_root.setBackgroundResource(R.drawable.im_bg_radius_no_topright_white_8);
konghaorui committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
        }
    }

    @Override
    protected void bindContentView() {

        if (isReceivedMessage()){
            setAvatarRightInVisibity();
        }else {
            setAvatarLeftInVisibity();
        }

        MsgAttachment attachment = message.getAttachment();
        if (attachment instanceof CustomAttachConsultSubScript) {
            title = ((CustomAttachConsultSubScript) attachment).title;
            productName = ((CustomAttachConsultSubScript) attachment).productName;
            consultDate = ((CustomAttachConsultSubScript) attachment).consultDate;
            consultTime = ((CustomAttachConsultSubScript) attachment).consultTime;
            consultType = ((CustomAttachConsultSubScript) attachment).consultType;
            url = ((CustomAttachConsultSubScript) attachment).url;
            flag = ((CustomAttachConsultSubScript) attachment).flag;
            isPackage = ((CustomAttachConsultSubScript) attachment).isPackage;
刘鹏 committed
88
            newOrderId = ((CustomAttachConsultSubScript) attachment).newOrderId;
konghaorui committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
        }

        tv_title.setText(title);
        tv_date.setText(consultDate);
        tv_time_long.setText(consultTime);
        tv_type.setText(consultType);

        if (isPackage == 2){
            tv_package.setVisibility(View.VISIBLE);
            tv_content.setText("\u3000\u3000"+productName);
        }else {
            tv_package.setVisibility(View.GONE);
            tv_content.setText(productName);
        }

        if (flag==1){
            img_icon.setVisibility(View.VISIBLE);
konghaorui committed
106
            tv_title.setTextColor(ContextCompat.getColor(context,R.color.im_color_00CC88));
konghaorui committed
107 108 109 110 111 112 113 114 115 116
        }else {
            img_icon.setVisibility(View.GONE);
            tv_title.setTextColor(ContextCompat.getColor(context,R.color.platform_color_242424));
        }

        hideItemBg();
    }

    @Override
    protected void onItemClick() {
刘鹏 committed
117
        if (TextUtils.isEmpty(url)&& newOrderId == null){
konghaorui committed
118 119
            return;
        }
刘鹏 committed
120

刘鹏 committed
121
        if (newOrderId == null || newOrderId.isEmpty()) {
刘鹏 committed
122 123 124 125
            NewH5Activity.start(context, new H5Params(url, null));
        } else {
            //跳转新订单详情页
            H5Params orderParams = new H5Params(
刘鹏 committed
126
                    ImConstants.Companion.getORDER_DETAIL() + (newOrderId.isEmpty() ? "" : newOrderId), null);
刘鹏 committed
127 128
            NewH5Activity.start(context, orderParams);
        }
konghaorui committed
129 130
    }
}