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

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

import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachPleaseSubscribeConsultDate;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;

/**
 * author : harvie
 * 请预约咨询时间提醒消息
 */

public class MsgViewHolderPleaseSubscribeConsultDate extends MsgViewHolderBase {

    private TextView tv_content;

    private String url;
    private String title;


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

    @Override
    protected int getContentResId() {
konghaorui committed
34
        return R.layout.im_ui_message_custom_consult_subscribe_date;
konghaorui committed
35 36 37 38 39 40 41
    }

    @Override
    protected void inflateContentView() {
        View rela_root = view.findViewById(R.id.rela_root);
        tv_content = view.findViewById(R.id.tv_content);
        if (isReceivedMessage()){
konghaorui committed
42
            rela_root.setBackgroundResource(R.drawable.im_bg_radius_no_topleft_white_8);
konghaorui committed
43
        }else {
konghaorui committed
44
            rela_root.setBackgroundResource(R.drawable.im_bg_radius_no_topright_white_8);
konghaorui committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
        }
    }

    @Override
    protected void bindContentView() {
        MsgAttachment attachment = message.getAttachment();
        if (attachment instanceof CustomAttachPleaseSubscribeConsultDate){
            url = ((CustomAttachPleaseSubscribeConsultDate) attachment).url;
            title = ((CustomAttachPleaseSubscribeConsultDate) attachment).title;
        }

        tv_content.setText(title);

        hideItemBg();
    }

    @Override
    protected void onItemClick() {
        if (TextUtils.isEmpty(url)){
            return;
        }
        NewH5Activity.start(context,new H5Params(url,null));
    }
}