MsgViewHolderReceivedMoney.java 3.08 KB
Newer Older
konghaorui committed
1 2 3 4 5 6 7 8 9 10
package com.yidianling.im.session.viewholder;

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

import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.yidianling.im.R;
11
import com.yidianling.im.config.constants.ImConstants;
konghaorui committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import com.yidianling.im.session.extension.CustomAttachReceivedMoney;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;


/**
 * 收款消息拓展
 * Created by wi1ls on 2017/1/10.
 */

public class MsgViewHolderReceivedMoney extends MsgViewHolderBase {

    private String num;//订单金额
    private String title;//订单标题题
    private int orPay;//支付状态 0未支付1已支付
    private String orderid;//订单id
28
    private Boolean isNewOrder;//是否是新订单
konghaorui committed
29 30

    private View message_received;
31
    private TextView tit, content;
konghaorui committed
32 33 34 35 36 37 38 39 40
    private ImageView img;

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


    @Override
    protected int getContentResId() {
konghaorui committed
41
        return R.layout.im_ui_message_received_money;
konghaorui committed
42 43 44 45
    }

    @Override
    protected void inflateContentView() {
46
        message_received = findViewById(R.id.message_received);
konghaorui committed
47 48 49 50 51 52 53
        tit = findViewById(R.id.packet_title);
        content = findViewById(R.id.text_content);
        img = findViewById(R.id.packte_im);
    }

    @Override
    protected void bindContentView() {
54 55
        CustomAttachReceivedMoney customAttachReceivedMoney = (CustomAttachReceivedMoney) message.getAttachment();
        orderid = customAttachReceivedMoney.getOrderId();
konghaorui committed
56 57 58 59
        num = customAttachReceivedMoney.getNum();
        title = customAttachReceivedMoney.getTitle();
        orPay = customAttachReceivedMoney.getOrPay();
        num = customAttachReceivedMoney.getNum();
60
        isNewOrder = customAttachReceivedMoney.getNewOrder();
konghaorui committed
61

62 63 64
        if (title != null) {
            tit.setText(title);
        }
konghaorui committed
65 66
        if (orPay == 1) {
            //支付成功
67 68 69
            if (num != null) {
                content.setText("您支付了" + num + "元");
            }
konghaorui committed
70
            img.setImageDrawable(view.getResources().getDrawable(R.mipmap.im_zhifu));
71
        } else {
72 73 74
            if (num != null) {
                content.setText("您需要支付" + num + "元");
            }
konghaorui committed
75
            img.setImageDrawable(view.getResources().getDrawable(R.mipmap.im_weifu));
konghaorui committed
76 77 78 79 80 81 82 83
        }

        hideItemBg();
    }

    @Override
    protected void onItemClick() {
        if (isReceivedMessage()) {
84
            if (isNewOrder != null && isNewOrder) {
85
                H5Params orderParams = new H5Params(
霍志良 committed
86
                        ImConstants.Companion.getPAY_DETAIL() + (orderid.isEmpty() ? "" : orderid), null);
87 88 89 90
                NewH5Activity.start(context, orderParams);
            } else {
                NewH5Activity.start(view.getContext(), new H5Params(HttpConfig.Companion.getH5_URL() + "receipt/order?oid=" + orderid, null));
            }
konghaorui committed
91 92 93 94
        }
    }

}