package com.tofly.ghrq_route.module.emergencyHandle.ui.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tofly.ghrq_route.R;
import com.tofly.ghrq_route.module.emergencyHandle.domain.EmergencyHandleData;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Amu on 2017/2/21.
 */

@SuppressLint("NonConstantResourceId")
public class EmergencyScheduleAssignInfoModuleLayout extends LinearLayout {
    @BindView(R.id.text_department)
    TextView textDepart;
    @BindView(R.id.text_response_user)
    TextView textResponseUser;
    @BindView(R.id.layout_dispatch_info)
    LinearLayout layoutDispatchInfo;
    @BindView(R.id.text_dispatch_info)
    TextView textDispatchInfo;

    private final Context mContext;

    public EmergencyScheduleAssignInfoModuleLayout(Context context) {
        this(context, null);
    }

    public EmergencyScheduleAssignInfoModuleLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public EmergencyScheduleAssignInfoModuleLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mContext = context;

        initView();
        initListener();
    }

    private void initView() {
        inflate(mContext, R.layout.layout_emergency_schedule_assign_info_module, this);
        ButterKnife.bind(this);
    }

    private void initListener() {

    }

    public void initEmergencyInfo(EmergencyHandleData emergencyData) {
        if (emergencyData != null) {
            setViewContent(emergencyData);
        }
    }

    private void setViewContent(EmergencyHandleData emergencyData) {
        /*部门*/
        String department = emergencyData.getDispatchDisposeDeptIdName();
        textDepart.setText(department);

        /*责任班长*/
        String responseUserName = emergencyData.getDispatchDisposeUserIdName();
        textResponseUser.setText(responseUserName);

        /*处理意见*/
        String dispatchingNotes = emergencyData.getDispatchDisposeNote();
        if (dispatchingNotes != null && !dispatchingNotes.isEmpty()) {
            layoutDispatchInfo.setVisibility(VISIBLE);
            textDispatchInfo.setText(dispatchingNotes);
        }else {
            layoutDispatchInfo.setVisibility(GONE);
        }

    }
}
