MsgViewHolderConsultSubScribePayment.java 4.78 KB
Newer Older
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 90 91 92 93 94 95 96 97
package com.yidianling.im.session.viewholder;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;

import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.yidianling.im.R;
import com.yidianling.im.config.constants.ImConstants;
import com.yidianling.im.session.extension.CustomAttachConsultSubScriptPayment;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;

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

public class MsgViewHolderConsultSubScribePayment 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;
    /***新订单id*/
    public String newOrderId;
    public String from_content;
    public String to_content;

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

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

    @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();
            lin_root.setBackgroundResource(R.drawable.im_bg_radius_no_topleft_white_8);
        }else {
            setAvatarLeftInVisibity();
            lin_root.setBackgroundResource(R.drawable.im_bg_radius_no_topright_white_8);
        }
    }

    @Override
    protected void bindContentView() {

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

        MsgAttachment attachment = message.getAttachment();
        if (attachment instanceof CustomAttachConsultSubScriptPayment) {
            title = ((CustomAttachConsultSubScriptPayment) attachment).title;
            productName = ((CustomAttachConsultSubScriptPayment) attachment).productName;
            consultDate = ((CustomAttachConsultSubScriptPayment) attachment).consultDate;
            consultTime = ((CustomAttachConsultSubScriptPayment) attachment).consultTime;
            consultType = ((CustomAttachConsultSubScriptPayment) attachment).consultType;
            url = ((CustomAttachConsultSubScriptPayment) attachment).url;
            flag = ((CustomAttachConsultSubScriptPayment) attachment).flag;
            isPackage = ((CustomAttachConsultSubScriptPayment) attachment).isPackage;
            newOrderId = ((CustomAttachConsultSubScriptPayment) attachment).newOrderId;
            from_content = ((CustomAttachConsultSubScriptPayment) attachment).from_content;
            to_content = ((CustomAttachConsultSubScriptPayment) attachment).to_content;

        }

98
        tv_title.setText(to_content);
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
        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);
        }else {
            img_icon.setVisibility(View.GONE);
        }

        hideItemBg();
    }

    @Override
    protected void onItemClick() {
        if (TextUtils.isEmpty(url)&& newOrderId == null){
            return;
        }

        if (newOrderId == null || newOrderId.isEmpty()) {
            NewH5Activity.start(context, new H5Params(url, null));
        } else {
            //跳转新订单详情页
            H5Params orderParams = new H5Params(
                    ImConstants.Companion.getORDER_DETAIL() + (newOrderId.isEmpty() ? "" : newOrderId), null);
            NewH5Activity.start(context, orderParams);
        }
    }
}