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

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.
 */

public class EmergencySignOverModuleLayout extends LinearLayout {
    @BindView(R.id.text_is_sign_over)
    TextView textIsSignOver;
    @BindView(R.id.layout_over_time)
    LinearLayout layoutOverTime;
    @BindView(R.id.text_over_time)
    TextView textOverTime;
    @BindView(R.id.sign_hint_text)
    TextView textSignHint;
    @BindView(R.id.text_over_sign)
    TextView textOverSign;

    private Context mContext;

    private boolean isEditable;

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

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

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

        mContext = context;

        initView();
        initListener();
    }

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

    private void initListener() {

    }

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

    private void setViewContent(EmergencyHandleData emergencyData) {
        /*到位时间*/
        String signTime = emergencyData.getSignTime();
        if (signTime != null && !signTime.isEmpty()) {
            textSignHint.setVisibility(GONE);
            textOverSign.setVisibility(GONE);
            textIsSignOver.setText("已签到");
            layoutOverTime.setVisibility(VISIBLE);
            textOverTime.setText(signTime);
        }else {
            textSignHint.setVisibility(VISIBLE);
            textOverSign.setVisibility(VISIBLE);
            textIsSignOver.setText("未签到");
            layoutOverTime.setVisibility(GONE);
        }
    }
}
