diff --git a/app/build.gradle b/app/build.gradle
index 012425d..cd8b22f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -59,4 +59,14 @@ dependencies {
// https://mvnrepository.com/artifact/com.contrarywind/Android-PickerView
// implementation 'com.contrarywind:Android-PickerView:4.1.9'
implementation 'org.litepal.android:java:3.0.0'
+
+
+ implementation 'com.github.xuexiangjys:XUpdate:2.1.4'
+ implementation 'com.github.xuexiangjys.XUpdateAPI:xupdate-easy:1.0.1'
+//
+//
+// implementation 'com.lzy.net:okhttputils:1.6.0' //可以单独使用,不需要依赖下方的扩展包
+// implementation 'com.lzy.net:okhttpserver:0.1.7' //扩展了下载管理和上传管理,根据需要添加
+
+
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 829fef8..59bf6ea 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,7 +5,13 @@
-
+
+
+
+
+
+
+
get(url+"/login/finduser").tag(this)
- .params("name", name)
- .params("pass", pass)
- .execute(new StringCallback() {
- @Override
- public void onSuccess(Response 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.get(url + "/login/finduser").tag(this)
+ .params("name", name)
+ .params("pass", pass)
+ .execute(new StringCallback() {
+ @Override
+ public void onSuccess(Response 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();
+ }
+ }
+ }
+ });
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java b/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java
index a48e2f6..b42ed2d 100644
--- a/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java
+++ b/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java
@@ -1,5 +1,7 @@
package com.example.beijing_daxing.base;
+import static com.xuexiang.xupdate.entity.UpdateError.ERROR.CHECK_NO_NEW_VERSION;
+
import android.app.Application;
import android.util.Log;
@@ -13,6 +15,13 @@ import com.lzy.okgo.cookie.CookieJarImpl;
import com.lzy.okgo.cookie.store.MemoryCookieStore;
import com.lzy.okgo.https.HttpsUtils;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
+import com.xuexiang.xupdate.XUpdate;
+
+import com.xuexiang.xupdate.easy.service.OkHttpUpdateHttpServiceImpl;
+import com.xuexiang.xupdate.entity.UpdateError;
+import com.xuexiang.xupdate.listener.OnUpdateFailureListener;
+import com.xuexiang.xupdate.proxy.IUpdateHttpService;
+import com.xuexiang.xupdate.utils.UpdateUtils;
import org.litepal.LitePal;
@@ -39,6 +48,17 @@ public class MyApplication extends Application {
SharedPreferencesUtils.init(getApplicationContext(), "myapp");
okGoBase();
getUhfLongerManager();
+ XUpdate.get()
+ .debug(true)
+ .isWifiOnly(false) //默认设置只在wifi下检查版本更新
+ .isGet(true) //默认设置使用get请求检查版本
+ .isAutoMode(false) //默认设置非自动模式,可根据具体使用配置
+ // .param("versionCode", UpdateUtils.getVersionCode(this)) //设置默认公共请求参数
+ // .param("appKey", getPackageName())
+
+ .supportSilentInstall(false) //设置是否支持静默安装,默认是true
+ .setIUpdateHttpService(new OkHttpUpdateHttpServiceImpl()) //这个必须设置!实现网络请求功能。
+ .init(this);
}
public static UHFRManager getUhfLongerManager() {
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 59c4648..a32fb99 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -34,6 +34,7 @@
android:layout_gravity="center"/>
+