|
|
|
@ -6,8 +6,10 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Looper;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +20,7 @@ public class SignInActivity extends AppCompatActivity {
|
|
|
|
|
public static final int SEND = 0;
|
|
|
|
|
EditText usnm;
|
|
|
|
|
EditText pswd;
|
|
|
|
|
UserService uService;
|
|
|
|
|
User user;
|
|
|
|
|
Handler mHandler = new Handler(){
|
|
|
|
|
int flag = -1;
|
|
|
|
@ -44,12 +47,14 @@ public class SignInActivity extends AppCompatActivity {
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
setContentView(R.layout.activity_signin);
|
|
|
|
|
uService = new UserService();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void user_commit(View view){
|
|
|
|
|
usnm = findViewById(R.id.user_name);
|
|
|
|
|
pswd = findViewById(R.id.pass_word);
|
|
|
|
|
new LoginThread().start();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onToRegister(View view){
|
|
|
|
@ -63,7 +68,7 @@ public class SignInActivity extends AppCompatActivity {
|
|
|
|
|
int flag = -1;
|
|
|
|
|
String name = usnm.getText().toString();
|
|
|
|
|
String pasd = pswd.getText().toString();
|
|
|
|
|
UserService uService = new UserService();
|
|
|
|
|
//UserService uService = new UserService();
|
|
|
|
|
flag = uService.login(name,pasd);
|
|
|
|
|
Message message = mHandler.obtainMessage();
|
|
|
|
|
if(flag==0){
|
|
|
|
@ -75,17 +80,17 @@ public class SignInActivity extends AppCompatActivity {
|
|
|
|
|
message.obj = "密码错误";
|
|
|
|
|
mHandler.sendMessage(message);
|
|
|
|
|
}else{
|
|
|
|
|
User user = new User();
|
|
|
|
|
user.setName(name);
|
|
|
|
|
user.setPasd(pasd);
|
|
|
|
|
String role = uService.getRole(name);
|
|
|
|
|
user.setRole(role);
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
bundle.putSerializable("user",user);
|
|
|
|
|
Intent intent =new Intent(SignInActivity.this,MainActivity.class);
|
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
User user = new User();
|
|
|
|
|
user.setName(name);
|
|
|
|
|
user.setPasd(pasd);
|
|
|
|
|
String role = uService.getRole(name);
|
|
|
|
|
user.setRole(role);
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
bundle.putSerializable("user",user);
|
|
|
|
|
Intent intent =new Intent(SignInActivity.this,MainActivity.class);
|
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|