MsgViewHolderReceivedStatus.java 3.06 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
package com.yidianling.im.session.viewholder;

import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import com.ydl.ydlcommon.base.config.HttpConfig;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachmentReceivedSuccess;
import com.yidianling.im.session.extension.CustomAttachmentReceivedTimeout;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;

/**
 * 后台推送到收款状态,比如超时未支付或者已经支付到拓展
 * Created by harvie on 2017/1/13.
 */

public class MsgViewHolderReceivedStatus extends MsgViewHolderBase {
    private TextView message_receive_tv;
    private String from_content;
    private String from_uid;
    private String touid;
    private String orderid;

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

    @Override
    protected int getContentResId() {
konghaorui committed
35
        return R.layout.im_ui_message_received_status;
konghaorui committed
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
    }
    @Override
    protected void inflateContentView() {
        message_receive_tv=findViewById(R.id.message_receive_tv);
    }

    @Override
    protected void bindContentView() {
        if (message.getAttachment() instanceof CustomAttachmentReceivedSuccess){
            CustomAttachmentReceivedSuccess customAttachmentRedStatus= (CustomAttachmentReceivedSuccess) message.getAttachment();
            orderid=customAttachmentRedStatus.getOrderid();
            from_content=customAttachmentRedStatus.getFrom_content();
            int redIndex=from_content.indexOf("收款");
            SpannableStringBuilder  ssb=new SpannableStringBuilder(from_content);
            ForegroundColorSpan fcs=new ForegroundColorSpan(0xFF3e82f7);
            ssb.setSpan(fcs,redIndex,redIndex+2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            message_receive_tv.setText(
                    ssb
            );
        }else if (message.getAttachment() instanceof CustomAttachmentReceivedTimeout){
            CustomAttachmentReceivedTimeout customAttachmentReceivedTimeout= (CustomAttachmentReceivedTimeout) message.getAttachment();
            orderid=customAttachmentReceivedTimeout.getOrderid();
            from_content=customAttachmentReceivedTimeout.getFrom_content();
            int redIndex=from_content.indexOf("收款");
            SpannableStringBuilder  ssb=new SpannableStringBuilder(from_content);
            ForegroundColorSpan fcs=new ForegroundColorSpan(0xFF3e82f7);
            ssb.setSpan(fcs,redIndex,redIndex+2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            message_receive_tv.setText(
                    ssb
            );
        }

        hideItemBg();
        hideHead();
    }

    @Override
    protected void onItemClick() {

        NewH5Activity.start(view.getContext(),new H5Params(HttpConfig.Companion.getH5_URL()+"receipt/order?oid="+orderid,null));
    }
}