package com.example.shengwutanzhen;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class StandOrWalkActivity extends AppCompatActivity {

    private String uuid;
    private TextView show_uuid;

    private RadioGroup radioGroup_sd;

    private Button confirm_btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_stand_or_walk);
        initView();
        Bundle bundle = getIntent().getExtras();
        assert bundle != null;
        uuid = bundle.getString("uuid");
        show_uuid.setText(uuid);
        show_uuid.setTextSize(25);
        show_uuid.setTextColor(getResources().getColor(R.color.text_color));
        setListener();
    }
    private void initView(){
        show_uuid = findViewById(R.id.show_uuid);
        radioGroup_sd = findViewById(R.id.radioGroup_sd);
        confirm_btn = findViewById(R.id.confirm_btn);
    }

    private void setListener(){
        confirm_btn.setOnClickListener(view -> {
            int checkedId = radioGroup_sd.getCheckedRadioButtonId();
            RadioButton radioButton = findViewById(checkedId);
            String gesture = radioButton.getText().toString();
            new AlertDialog.Builder(StandOrWalkActivity.this)
                    .setTitle("提示")
                    .setMessage("您选择的动作是:"+gesture)
                    .setPositiveButton("确定", (dialogInterface, i) -> {
                        Bundle bundle = new Bundle();
                        bundle.putString("gesture", gesture);
                        bundle.putString("uuid",uuid);
                        Intent intent = new Intent(StandOrWalkActivity.this, PhoneActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    })
                    .setNegativeButton("取消", (dialogInterface, i) -> {

                    })
                    .show();
        });
    }
}