diff --git a/AndroidStudio_projects/app/src/main/java/com/example/hamburger/register.java b/AndroidStudio_projects/app/src/main/java/com/example/hamburger/register.java deleted file mode 100644 index 42a4041..0000000 --- a/AndroidStudio_projects/app/src/main/java/com/example/hamburger/register.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.example.hamburger; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; -import com.example.hamburger.dao.UserDao; -import com.example.hamburger.entity.User; - -import androidx.appcompat.app.AppCompatActivity; - -public class register extends AppCompatActivity { - private static final String TAG = "mysql-party-register"; - EditText userAccount = null; - EditText userPassword = null; - EditText userName = null; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_register); - - userAccount = findViewById(R.id.userAccount); - userPassword = findViewById(R.id.userPassword); - userName = findViewById(R.id.userName); - } - - - public void register(View view){ - - String userAccount1 = userAccount.getText().toString(); - String userPassword1 = userPassword.getText().toString(); - String userName1 = userName.getText().toString(); - User user = new User(); - user.setUserAccount(userAccount1); - user.setUserPassword(userPassword1); - user.setUserName(userName1); - user.setUserType(1); - user.setUserState(0); - user.setUserDel(0); - - new Thread(){ - @Override - public void run() { - int msg = 0; - UserDao userDao = new UserDao(); - User uu = userDao.findUser(user.getUserAccount()); - if(uu != null){ - msg = 1; - } - else{ - boolean flag = userDao.register(user); - if(flag){ - msg = 2; - } - } - hand.sendEmptyMessage(msg); - } - }.start(); - - - } - @SuppressLint("HandlerLeak") - final Handler hand = new Handler() - { - public void handleMessage(Message msg) { - if(msg.what == 0) { - Toast.makeText(getApplicationContext(),"注册失败",Toast.LENGTH_LONG).show(); - } else if(msg.what == 1) { - Toast.makeText(getApplicationContext(),"该账号已经存在,请换一个账号",Toast.LENGTH_LONG).show(); - } else if(msg.what == 2) { - Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(); - //将想要传递的数据用putExtra封装在intent中 - intent.putExtra("a","注册"); - setResult(RESULT_CANCELED,intent); - finish(); - } - } - }; - - public void Ret(View view){ - //获取按钮 - Button button = (Button) findViewById(R.id.ret); - - //按钮进行监听 - button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //监听按钮,如果点击,就跳转 - Intent intent = new Intent(); - //前一个(MainActivity.this)是目前页面,后面一个是要跳转的下一个页面 - intent.setClass(register.this, MainActivity.class); - startActivity(intent); - } - }); - } - -} \ No newline at end of file