package com.police.policedatasystem.data.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.police.policedatasystem.App;
import com.police.policedatasystem.databinding.ActivityPoliceEmergencyDetailBinding;
import com.police.policedatasystem.model.PoliceEmergencyDetail;
import com.police.policedatasystem.util.Constants;
import com.police.policedatasystem.util.UiUtils;

/**
 * 警情详情页面
 */
public class PoliceEmergencyDetailActivity extends Activity {

    private ActivityPoliceEmergencyDetailBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityPoliceEmergencyDetailBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.wm.setTextSize(50);
        binding.wm.setText(Constants.SFZH);
        binding.ivBack.setOnClickListener(view -> finish());
        PoliceEmergencyDetail detail = new Gson().fromJson(getIntent().getStringExtra("param"), PoliceEmergencyDetail.class);
        if (UiUtils.isNotEmpty(detail.getZp())) {
            Glide.with(App.getApp()).asBitmap().load(detail.getZp()).into(binding.ivZp);
        }
        setText(binding.tvJcjbh, detail.getJcjbh());//报警编号
        setText(binding.tvBjjyqk, detail.getBjjyqk());//报警内容
        setText(binding.tvBjrlxdh, detail.getBjrlxdh());//报警电话
        setText(binding.tvJjsj, UiUtils.formatTime(detail.getJjsj()));//报警时间
        setText(binding.tvAsjfsdddzmc, detail.getAsjfsdddzmc());//报警位置
        setText(binding.tvCjdwgajgjgdm, detail.getCjdwgajgjgdm());//出警单位
        setText(binding.tvCjrxm, detail.getCjrxm());//出警民警
        setText(binding.tvBq, detail.getBq());//标签
        setText(binding.tvJg, detail.getJg());//籍贯
        setText(binding.tvXm, detail.getXm());//姓名
        setText(binding.tvXb, detail.getXb());//性别
        setText(binding.tvMz, detail.getMz());//民族
        setText(binding.tvHyzk, detail.getHyzk());//婚姻状况
        setText(binding.tvSfzh, detail.getBjrzjhm());//身份证号
        setText(binding.tvNl, detail.getNl());//年龄
        setText(binding.tvFwcs, detail.getFwcs());//服务场所
        setText(binding.tvLsbjcs, detail.getLsbjcs());//历史报警次数
        setText(binding.tvJqlb, detail.getJqlb());//警情类别
        setText(binding.tvCllb, detail.getCllx());//处理类型
        setText(binding.tvCljg, detail.getCljg());//处理结果
    }

    public static void startAction(Context context, String num) {
        Intent intent = new Intent(context, PoliceEmergencyDetailActivity.class);
        intent.putExtra("param", num);
        context.startActivity(intent);
    }

    private void setText(TextView view, String str) {
        if (UiUtils.isNotEmpty(str)) {
            view.setText(str);
        } else {
            view.setText("无");
        }
    }
}