package com.example.shengwutanzhen;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class ResultActivity extends AppCompatActivity {

    private TextView tv_result_succeed, tv_result_failed;
    private Button btn_result_confirm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);
        initView();
        Bundle bundle = getIntent().getExtras();
        String result = bundle.getString("result");
        if (result.equals("数据发送成功")) {
            tv_result_succeed.setVisibility(TextView.VISIBLE);
            tv_result_failed.setVisibility(TextView.GONE);
        }else {
            tv_result_succeed.setVisibility(TextView.GONE);
            tv_result_failed.setVisibility(TextView.VISIBLE);
        }
        setListener();
    }

    private void initView() {
        tv_result_succeed = findViewById(R.id.tv_result_succeed);
        tv_result_failed = findViewById(R.id.tv_result_failed);
        btn_result_confirm = findViewById(R.id.btn_result_confirm);
    }

    private void setListener() {
        btn_result_confirm.setOnClickListener(view -> {
            finishAffinity();
        });
    }
}