package com.bjzc.zjyxdxj.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import com.bjzc.zjyxdxj.R;


public class CustomDialogActivity extends Activity {
    private TextView title;
    private TextView msg;
    private TextView btnStart;
    private TextView btnClose;

    String type = "7";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //必须在调用setContentView()之前调用requestWindowFeature()
        //requestWindowFeature(Window.FEATURE_LEFT_ICON);//要标题栏显示图标
        //全屏操作,一定要放在加载根view之前
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT);
        setContentView(R.layout.dialog_activity);
        initView();
        initData();
    }

    private  void initView(){
        title = findViewById(R.id.tv_title);
        msg = findViewById(R.id.tv_msg);
        btnClose = findViewById(R.id.dialog_commit);
        btnStart = findViewById(R.id.dialog_cancel);
        btnStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(type.equals("7")){

                }
                if(type.equals("11")){

                }
            }
        });
        btnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
    private void initData() {
        Intent intent = getIntent();
        type = intent.getStringExtra("type");
        if(type.equals("7")){
            title.setText("测温" + "(℃)");
        }
        if(type.equals("11")){
            title.setText("测振" + "(mm)");
        }
    }





    @Override
    protected void onResume() {
        super.onResume();
        if(type.equals("7")){
            title.setText("测温" + "(℃)");
        }
        if(type.equals("11")){
            title.setText("测振" + "(mm)");
        }
    }

    public void updateUIByTemp(final String info) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (info != null) {
                    msg.setText(info);
                }
            }
        });
    }

    public void updateUIByVibration(final String info) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (info != null) {
                    msg.setText(info);
                }
            }
        });
    }
}