package com.casic.dcms.widgets;

import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;

import com.casic.dcms.R;
import com.casic.dcms.model.LampBoxDetailBean;

public class LightDetailDialog extends AlertDialog {

    public static class Builder {
        private Context context;
        private LampBoxDetailBean detailBean;

        public Builder setContext(Context context) {
            this.context = context;
            return this;
        }

        public Builder setLampBoxDetailBean(LampBoxDetailBean detailBean) {
            this.detailBean = detailBean;
            return this;
        }

        public LightDetailDialog build() {
            return new LightDetailDialog(this);
        }
    }

    private final LampBoxDetailBean detailBean;

    private LightDetailDialog(Builder builder) {
        super(builder.context, R.style.DetailDialogStyle);
        this.detailBean = builder.detailBean;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_lamp_box_detail);
        setCanceledOnTouchOutside(true);
        setCancelable(true);

        TextView lampBoxCodeView = findViewById(R.id.lampBoxCodeView);
        TextView lampBoxNameView = findViewById(R.id.lampBoxNameView);
        TextView deptView = findViewById(R.id.deptView);
        TextView electricityView = findViewById(R.id.electricityView);
        TextView voltageView = findViewById(R.id.voltageView);
        TextView powerView = findViewById(R.id.powerView);
        TextView updateTimeView = findViewById(R.id.updateTimeView);
        TextView roadView = findViewById(R.id.roadView);
        TextView addressView = findViewById(R.id.addressView);

        LampBoxDetailBean.DataModel data = detailBean.getData();
        lampBoxCodeView.setText(data.getLampboxCode());
        lampBoxNameView.setText(data.getLampboxName());
        deptView.setText(data.getDeptName());
        electricityView.setText(String.format("%s/%s/%s", data.getElecA(), data.getElecB(), data.getElecC()));
        voltageView.setText(String.format("%s/%s/%s", data.getVolA(), data.getVolB(), data.getVolC()));
        powerView.setText(String.format("%s/%s/%s", data.getPowerA(), data.getPowerB(), data.getPowerC()));
        updateTimeView.setText(data.getUpTime());
        roadView.setText(data.getStreetName());
        addressView.setText(data.getAddress());
    }
}
