Commit 603c57d4 authored by hywang's avatar hywang

Merge remote-tracking branch 'origin/master'

parents beed5e0a 2cda0f48
......@@ -9,8 +9,8 @@ android {
applicationId "com.phlx.anchorcollect"
minSdkVersion 21
targetSdkVersion 29
versionCode 6
versionName "1.0.5"
versionCode 7
versionName "2.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
......
......@@ -23,6 +23,7 @@ import cn.wandersnail.bluetooth.Connection;
import cn.wandersnail.bluetooth.EventObserver;
import cn.wandersnail.commons.util.ToastUtils;
import me.goldze.mvvmhabit.bus.RxBus;
import me.goldze.mvvmhabit.utils.StringUtils;
public class BtService extends Service implements EventObserver {
......@@ -72,7 +73,16 @@ public class BtService extends Service implements EventObserver {
// Log.e(TAG, "onRead: " + data);
// ToastUtils.showShort("onRead: " + data);
String weightData = data.substring(data.indexOf("wn") + 3, data.indexOf("kg"));
String weightData = data.substring(data.indexOf("wn") + 3, data.indexOf("kg")).trim();
if (StringUtils.isEmpty(weightData)) {//如果是空数据,返回-1
weightData = "-1";
// return;
}
try {//判断数据是否合法,不合法返回-100
Double.parseDouble(weightData);
} catch (Exception e) {
weightData = "-100";
}
EventMsg eventMsg = new EventMsg();
eventMsg.setAction(Configs.currentEvent);
eventMsg.setObj(weightData);
......
......@@ -99,6 +99,22 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
}
}
});
viewModel.dateEvent.observe(this, new Observer<Integer>() {
@Override
public void onChanged(Integer integer) {
new MaterialDialog.Builder(LoginActivity.this).canceledOnTouchOutside(false).title("系统提示").content("日期错误,请联网自动获取日期").positiveText("退出").onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
ModuleManager.destroyLibSO();
finish();
android.os.Process.killProcess(android.os.Process.myPid());
}
}
}).show();
}
});
}
@Override
......
......@@ -25,6 +25,7 @@ import com.phlx.anchorcollect.params.BaseResponse;
import com.phlx.anchorcollect.params.CollectResponse;
import com.phlx.anchorcollect.ui.main.MainActivity;
import com.phlx.anchorcollect.ui.splash.SplashActivity;
import com.phlx.anchorcollect.util.DateUtils;
import com.phlx.anchorcollect.util.StringUtil;
import com.phlx.anchorcollect.util.TextUtil;
......@@ -63,6 +64,9 @@ public class LoginVM extends BaseViewModel<Repository> {
//更新app
public SingleLiveEvent<Integer> appUpdateEvent = new SingleLiveEvent<>();
//手机时间问题,退出软件
public SingleLiveEvent<Integer> dateEvent = new SingleLiveEvent<>();
public int loginType;//登录后是否跳转, 0跳转main 1不跳转
......@@ -109,6 +113,10 @@ public class LoginVM extends BaseViewModel<Repository> {
public BindingCommand loginOnClickCommand = new BindingCommand(new BindingAction() {
@Override
public void call() {
if(Integer.parseInt(DateUtils.getYear())<2020){
dateEvent.call();
return;
}
if (Configs.isOnLine) {
login();
} else {
......
package com.phlx.anchorcollect.util;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
public static String getYear(){
public static String getYear() {
String year = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
year = simpleDateFormat.format(new Date());
return year;
}
String year = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
year = simpleDateFormat.format(new Date());
return year;
}
public static long getYearLong() {
Calendar c1 = Calendar.getInstance();
c1.set(Integer.parseInt(getYear()), 0, 1, 0, 0, 0);
return c1.getTimeInMillis();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment