文档更新

zhenghaoyuan_branch
zhenghaoyuan20 2 years ago
parent 662b13171c
commit 205f5563d5

@ -3,6 +3,7 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="..\:/AndroidTool/AndriodProject/Shaobing/src/sixaunyi/app/src/main/res/layout/activity_main.xml" value="0.25364583333333335" />
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/drawable/icon_favorite_red.xml" value="0.12" /> <entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/drawable/icon_favorite_red.xml" value="0.12" />
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_detect.xml" value="0.1" /> <entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_detect.xml" value="0.1" />
<entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_main.xml" value="0.1" /> <entry key="..\:/MiNote_maintain/new_MiCode/src/sixaunyi/app/src/main/res/layout/activity_main.xml" value="0.1" />

@ -29,7 +29,6 @@ public class LoginActivity extends AppCompatActivity {
mLoginButton = findViewById(R.id.login); mLoginButton = findViewById(R.id.login);
// 设置登录按钮的点击事件 // 设置登录按钮的点击事件
mLoginButton.setOnClickListener(v -> { mLoginButton.setOnClickListener(v -> {
attemptLogin(); attemptLogin();
}); });
} }
@ -37,19 +36,23 @@ public class LoginActivity extends AppCompatActivity {
String username = mUsername.getText().toString(); String username = mUsername.getText().toString();
String password = mPassword.getText().toString(); String password = mPassword.getText().toString();
boolean if_correct = verifyUser(username,password); boolean if_correct = verifyUser(username,password);
if (!isInputUsernameValid(username)){ if (!isInputUsernameValid(username) || !isInputPasswordValid(password)){
Toast.makeText(this, "用户名非法", Toast.LENGTH_SHORT).show(); if (!isInputUsernameValid(username) && !isInputPasswordValid(password)) {
} Toast.makeText(this, "用户名和密码非法", Toast.LENGTH_SHORT).show();
if (!isInputPasswordValid(password)){ }
Toast.makeText(this, "密码非法", Toast.LENGTH_SHORT).show(); else if (!isInputPasswordValid(password)){
} Toast.makeText(this, "密码非法", Toast.LENGTH_SHORT).show();
if (if_correct) { }
Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show(); else {Toast.makeText(this, "用户名非法", Toast.LENGTH_SHORT).show();}
Intent intent = new Intent(LoginActivity.this, MainActivity.class); }else {
startActivity(intent); if (if_correct) {
finish(); // 关闭登录界面 Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
} else { Intent intent = new Intent(LoginActivity.this, MainActivity.class);
Toast.makeText(this, "用户名或密码错误", Toast.LENGTH_SHORT).show(); startActivity(intent);
finish(); // 关闭登录界面
} else {
Toast.makeText(this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
}
} }
} }
@ -93,4 +96,5 @@ public class LoginActivity extends AppCompatActivity {
return false; return false;
} }
} }
} }

Loading…
Cancel
Save