|
|
|
@ -18,24 +18,31 @@ import com.lzy.okgo.OkGo;
|
|
|
|
|
import com.lzy.okgo.callback.StringCallback;
|
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
|
import com.uhf.api.cls.Reader;
|
|
|
|
|
import com.xuexiang.xupdate.XUpdate;
|
|
|
|
|
import com.xuexiang.xupdate.easy.EasyUpdate;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends BaseActivity {
|
|
|
|
|
private LoginVm loginVm;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
ActivityMainBinding binding= DataBindingUtil.setContentView(this,R.layout.activity_main);
|
|
|
|
|
loginVm=new LoginVm();
|
|
|
|
|
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
|
|
|
|
|
loginVm = new LoginVm();
|
|
|
|
|
boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false);
|
|
|
|
|
if (isRemember){
|
|
|
|
|
loginVm.setName(SharedPreferencesUtils.getstring("user",""));
|
|
|
|
|
loginVm.setPass(SharedPreferencesUtils.getstring("pass",""));
|
|
|
|
|
if (isRemember) {
|
|
|
|
|
loginVm.setName(SharedPreferencesUtils.getstring("user", ""));
|
|
|
|
|
loginVm.setPass(SharedPreferencesUtils.getstring("pass", ""));
|
|
|
|
|
loginVm.setRemember(isRemember);
|
|
|
|
|
}
|
|
|
|
|
binding.setUser(loginVm);
|
|
|
|
|
|
|
|
|
|
EasyUpdate.checkUpdate(this,url + "/getVersion");
|
|
|
|
|
// XUpdate.newBuild(this)
|
|
|
|
|
// .updateUrl(url + "/getVersion")
|
|
|
|
|
// .promptIgnoreDownloadError(true)
|
|
|
|
|
// .update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -43,39 +50,39 @@ public class MainActivity extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void login_click(View view){
|
|
|
|
|
String pass = loginVm.getPass();
|
|
|
|
|
String name = loginVm.getName();
|
|
|
|
|
if (pass==null|| name==null||pass.isEmpty()||name.isEmpty()) return;
|
|
|
|
|
dialog.show();
|
|
|
|
|
OkGo.<String> get(url+"/login/finduser").tag(this)
|
|
|
|
|
.params("name", name)
|
|
|
|
|
.params("pass", pass)
|
|
|
|
|
.execute(new StringCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<String> response) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
String body = response.body();
|
|
|
|
|
if (body.equals("isEmpty")){
|
|
|
|
|
Toast.makeText(MainActivity.this, "暂无权限", Toast.LENGTH_SHORT).show();
|
|
|
|
|
} else if (body.equals("Error")) {
|
|
|
|
|
Toast.makeText(MainActivity.this, "用户名密码错误", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}else {
|
|
|
|
|
boolean remember = loginVm.isRemember();
|
|
|
|
|
if (remember){
|
|
|
|
|
SharedPreferencesUtils.putboolean("isRemember",remember);
|
|
|
|
|
SharedPreferencesUtils.putstring("user",name);
|
|
|
|
|
SharedPreferencesUtils.putstring("pass",pass);
|
|
|
|
|
Intent intent=new Intent(MainActivity.this, HomePageActivity.class);
|
|
|
|
|
intent.putExtra("json",body);
|
|
|
|
|
intent.putExtra("user",name);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public void login_click(View view) {
|
|
|
|
|
String pass = loginVm.getPass();
|
|
|
|
|
String name = loginVm.getName();
|
|
|
|
|
if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
|
|
|
|
|
dialog.show();
|
|
|
|
|
OkGo.<String>get(url + "/login/finduser").tag(this)
|
|
|
|
|
.params("name", name)
|
|
|
|
|
.params("pass", pass)
|
|
|
|
|
.execute(new StringCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<String> response) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
String body = response.body();
|
|
|
|
|
if (body.equals("isEmpty")) {
|
|
|
|
|
Toast.makeText(MainActivity.this, "暂无权限", Toast.LENGTH_SHORT).show();
|
|
|
|
|
} else if (body.equals("Error")) {
|
|
|
|
|
Toast.makeText(MainActivity.this, "用户名密码错误", Toast.LENGTH_SHORT).show();
|
|
|
|
|
} else {
|
|
|
|
|
boolean remember = loginVm.isRemember();
|
|
|
|
|
if (remember) {
|
|
|
|
|
SharedPreferencesUtils.putboolean("isRemember", remember);
|
|
|
|
|
SharedPreferencesUtils.putstring("user", name);
|
|
|
|
|
SharedPreferencesUtils.putstring("pass", pass);
|
|
|
|
|
Intent intent = new Intent(MainActivity.this, HomePageActivity.class);
|
|
|
|
|
intent.putExtra("json", body);
|
|
|
|
|
intent.putExtra("user", name);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|