MsgViewHolderConsultCallStatus.java 2.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package com.yidianling.im.session.viewholder;

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

import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachConsultCallStatus;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;

/**
 * Created by zhoujianghua on 2015/8/6.
 */
public class MsgViewHolderConsultCallStatus extends MsgViewHolderBase {

17 18
    private ImageView typeImageLeft;
    private ImageView typeImageRight;
19 20 21 22 23 24 25 26 27 28 29 30 31
    private TextView statusLabel;

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

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

    @Override
    protected void inflateContentView() {
32 33
        typeImageLeft = findViewById(R.id.type_img_left);
        typeImageRight = findViewById(R.id.type_img_right);
34 35 36 37 38 39 40 41 42 43 44 45 46
        statusLabel = findViewById(R.id.tv_state);
    }

    @Override
    protected void bindContentView() {
        CustomAttachConsultCallStatus customAttachTipMsg = (CustomAttachConsultCallStatus) message.getAttachment();
        layoutByDirection(customAttachTipMsg);

    }

    private void layoutByDirection(CustomAttachConsultCallStatus customAttachTipMsg) {

        if (isReceivedMessage()) {
47 48
            typeImageLeft.setVisibility(View.VISIBLE);
            typeImageRight.setVisibility(View.GONE);
49
        } else {
50 51
            typeImageLeft.setVisibility(View.GONE);
            typeImageRight.setVisibility(View.VISIBLE);
52 53
        }

54 55 56

        if (isReceivedMessage()) {
            statusLabel.setText(customAttachTipMsg.getCallee());
57
        } else {
58
            statusLabel.setText(customAttachTipMsg.getCaller());
59
        }
ydl committed
60 61 62 63 64 65
    }

    @Override
    protected int leftBackground() {
        CustomAttachConsultCallStatus customAttachTipMsg = (CustomAttachConsultCallStatus) message.getAttachment();
        if (!"true".equals(customAttachTipMsg.getIsConsultOrder())) {
ydl committed
66
            return R.drawable.im_message_receive_content_tip_bg;
ydl committed
67
        } else {
ydl committed
68
            return R.drawable.im_message_receive_content_bg;
ydl committed
69 70
        }
    }
71

ydl committed
72 73 74 75
    @Override
    protected int rightBackground() {
        CustomAttachConsultCallStatus customAttachTipMsg = (CustomAttachConsultCallStatus) message.getAttachment();
        if (!"true".equals(customAttachTipMsg.getIsConsultOrder())) {
ydl committed
76
            return R.drawable.im_message_send_content_tip_bg;
ydl committed
77
        } else {
ydl committed
78
            return R.drawable.im_message_send_content_bg;
ydl committed
79
        }
80 81 82
    }

}