版本更新url获取优化
This commit is contained in:
parent
3d338c2628
commit
1671ef3c3f
|
|
@ -156,8 +156,6 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
initData();
|
||||
initListeners();
|
||||
showPresentation();
|
||||
// 启动服务
|
||||
startService(new Intent(this, HeartbeatService.class));
|
||||
//判断是否存在当天订单
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
BusinessDataInfo businessDataInfo = AppDatabase.getDatabase(this).businessDataDao().getBusinessDataInfoByDate(DateTimeHelper.getNowDate());
|
||||
|
|
@ -185,7 +183,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
// 显示屏幕分辨率在TextView上
|
||||
String resolutionText = "屏幕分辨率:\n宽度:" + widthPixels + " 像素\n高度:" + heightPixels + " 像素";
|
||||
Log.d(TAG, "resolutionText: " + resolutionText);
|
||||
|
||||
// 启动服务
|
||||
startService(new Intent(this, HeartbeatService.class));
|
||||
|
||||
startService(new Intent(this, UpLoadDataService.class));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@ package com.bonus.canteen.activity;
|
|||
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
import com.bonus.canteen.db.entity.base.ParamSettingInfo;
|
||||
import com.bonus.canteen.upgrade.UpdateDown;
|
||||
import com.bonus.canteen.utils.TokenUtils;
|
||||
import com.bonus.canteen.utils.WorkConfig;
|
||||
import com.ccb.facedevice.sdk.utils.NetworkUtils;
|
||||
import com.xuexiang.xui.utils.KeyboardUtils;
|
||||
import com.xuexiang.xui.widget.activity.BaseSplashActivity;
|
||||
|
|
@ -64,7 +67,12 @@ public class SplashActivity extends BaseSplashActivity implements CancelAdapt {
|
|||
private void loginOrGoMainPage() {
|
||||
if (NetworkUtils.isNetworkConnected(this)) {
|
||||
new Thread(() -> {
|
||||
boolean isLatestVersion = down.checkUpdate();
|
||||
ParamSettingInfo paramSettingInfo = AppDatabase.getDatabase(this).parameterInfoDao().getOneInfo();
|
||||
String url = WorkConfig.getBaseUrl();
|
||||
if (paramSettingInfo != null){
|
||||
url = paramSettingInfo.getIpAddress() + "/smart-canteen";
|
||||
}
|
||||
boolean isLatestVersion = down.checkUpdate(url);
|
||||
runOnUiThread(() -> {
|
||||
if (!isLatestVersion) {
|
||||
navigateToNextPage();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public class DownLoadDataService extends Service {
|
|||
|
||||
private List<String> methodList = new ArrayList<>();
|
||||
|
||||
private WorkConfig workConfig;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
@ -147,8 +148,10 @@ public class DownLoadDataService extends Service {
|
|||
case "人员信息":
|
||||
return service.getPersonInfo(null,null,0);
|
||||
case "设备信息":
|
||||
workConfig = new WorkConfig();
|
||||
return service.getDeviceBase();
|
||||
case "基础参数":
|
||||
workConfig = new WorkConfig();
|
||||
return service.getParamSettingInfo();
|
||||
case "MQ_CONNECT":
|
||||
return activateFaceEngine();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.canteen.upgrade;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
|
@ -36,8 +37,8 @@ public class UpdateDown {
|
|||
/**
|
||||
* 检测软件更新
|
||||
*/
|
||||
public boolean checkUpdate() {
|
||||
VersionBean versionBean = isUpdate();
|
||||
public boolean checkUpdate(String url) {
|
||||
VersionBean versionBean = isUpdate(url);
|
||||
if (versionBean != null) {
|
||||
AppUpdate appUpdate = new AppUpdate.Builder()
|
||||
//更新地址(必传)
|
||||
|
|
@ -98,6 +99,7 @@ public class UpdateDown {
|
|||
new UpdateManager().startUpdate(mContext, appUpdate);
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
|
@ -113,13 +115,15 @@ public class UpdateDown {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
private VersionBean isUpdate() {
|
||||
private VersionBean isUpdate(String url) {
|
||||
VersionBean versionBean = new VersionBean();
|
||||
try {
|
||||
// 获取当前软件版本
|
||||
int versionCode = getVersionCode(mContext);
|
||||
// 把version.xml放到网络上,然后获取文件信息
|
||||
String path = WorkConfig.getBaseUrl() + "/api/android/device/getAppVersion";
|
||||
|
||||
|
||||
String path = url + "/api/android/device/getAppVersion";
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", versionCode + "");
|
||||
json.put("type", "1");
|
||||
|
|
|
|||
Loading…
Reference in New Issue