package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.bpa.Model.IMessageLogNotify;
import com.example.bpa.Model.IRun;
import com.example.bpa.R;
import com.example.bpa.helper.MessageLog;

import java.util.logging.Handler;

public class RunLog extends AppCompatActivity implements View.OnClickListener {


    //region 变量
    /**
     * 返回按钮
     */
    ImageView gongneng_fanhui;
    /**
     * 标题设置
     */
    TextView gongneng_title;
    //endregion

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_run_log);
        Init();
        initEvents();
    }

    TextView InfoTv;

    /**
     * 初始化
     */
    private void Init() {
        gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
        gongneng_title = this.findViewById(R.id.gongneng_title);
        //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
        String msg = getIntent().getStringExtra("data");
        gongneng_title.setText(msg);
        InfoTv = ((TextView) this.findViewById(R.id.test_view));
        InfoTv.setText(MessageLog.MsgInfo);
        MessageLog.AddNotify = new IRun() {
            @Override
            public void Run() {
                runOnUiThread(() -> {
                    InfoTv.setText(MessageLog.MsgInfo);
                });
            }
        };
    }

    /**
     * 初始化按钮事件
     */
    private void initEvents() {
        gongneng_fanhui.setOnClickListener(this);
    }


    /**
     * 本页面点击事件监听
     *
     * @param v
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.gongneng_fanhui://返回按钮
                this.finish();
                break;
        }
    }

}