package com.example.shengwutanzhen;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class UuidActivity extends AppCompatActivity {

    private EditText uuid_text;
    private Button btn_send;
    private ImageView uuid_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uuid);
        initView();
        setListener();
    }

    private void initView(){
        uuid_text = findViewById(R.id.uuid_text);
        btn_send = findViewById(R.id.btn_send);
        uuid_back = findViewById(R.id.uuid_back);
    }

    private void setListener(){
        btn_send.setOnClickListener(view -> {
            String uuid = uuid_text.getText().toString();
            if (uuid.isEmpty()){
                Toast.makeText(UuidActivity.this,"请输入UUID",Toast.LENGTH_SHORT).show();
                return;
            }
            new AlertDialog.Builder(UuidActivity.this)
                    .setTitle("提示信息")
                    .setMessage("您的UUID为:"+uuid)
                    .setPositiveButton("确定", (dialog, which) -> {
                        Bundle bundle = new Bundle();
                        bundle.putString("uuid", uuid);
                        Intent intent = new Intent(UuidActivity.this, StandOrWalkActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    })
                    .setNegativeButton("取消", (dialog, which) -> {
                        // Do something when user presses Cancel
                    })
                    .show();
        });
        uuid_back.setOnClickListener(view -> {
            finish();
        });
    }
}