|
|
@@ -7,6 +7,7 @@ import com.common.LogUtil;
|
|
|
import com.common.config.BaseConfig;
|
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
+import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
@@ -52,11 +53,13 @@ public class StepUtils {
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("appUUsteps")
|
|
|
.add("map", map)
|
|
|
+// .header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
|
|
|
.add("token", MyApplication.getInstance().mAccessToken)
|
|
|
.method(Method.POST)
|
|
|
.build(), new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
+ if (o == null) return;
|
|
|
LogUtil.prinlnLongMsg("appUUsteps", o.toString() + "");
|
|
|
}
|
|
|
}));
|
|
|
@@ -71,11 +74,16 @@ public class StepUtils {
|
|
|
public static void canUnloadToRemote(String s) {
|
|
|
PersonalStepBean mPersonalStepBean = new PersonalStepBean();
|
|
|
mPersonalStepBean = JSON.parseObject(s.toString(), PersonalStepBean.class);
|
|
|
- if (mPersonalStepBean == null) return;
|
|
|
- int remoteSteps = CommonUtil.getNumByString(mPersonalStepBean.getWeekSteps().get(mPersonalStepBean.getWeekSteps().size() - 1).getAs_uusteps());
|
|
|
String CURRENT_DATE = TimeUtil.getCurrentDate();
|
|
|
StepDataDao stepDataDao = new StepDataDao(MyApplication.getInstance());
|
|
|
StepEntity stepEntity = stepDataDao.getCurDataByDate(CURRENT_DATE);
|
|
|
+
|
|
|
+ if (mPersonalStepBean == null || ListUtils.isEmpty(mPersonalStepBean.getWeekSteps())) {
|
|
|
+ doSaveLocalStepsToHttps(stepEntity);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int remoteSteps = CommonUtil.getNumByString(mPersonalStepBean.getWeekSteps().get(mPersonalStepBean.getWeekSteps().size() - 1).getAs_uusteps());
|
|
|
+
|
|
|
try {
|
|
|
if (stepEntity == null) {
|
|
|
// stepEntity = new StepEntity();
|
|
|
@@ -91,7 +99,7 @@ public class StepUtils {
|
|
|
intent.putExtra("remoteSteps", remoteSteps);
|
|
|
BaseConfig.getContext().sendBroadcast(intent);
|
|
|
LogUtil.prinlnLongMsg("stepDb.update","sendLocalBroadcast");
|
|
|
- } else if (remoteSteps < CommonUtil.getNumByString(stepEntity.getSteps())) {
|
|
|
+ } else if (remoteSteps <= CommonUtil.getNumByString(stepEntity.getSteps())) {
|
|
|
doSaveLocalStepsToHttps(stepEntity);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -132,6 +140,7 @@ public class StepUtils {
|
|
|
.build(), new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
+ if (o == null) return;
|
|
|
LogUtil.prinlnLongMsg("appSteps", o.toString());
|
|
|
canUnloadToRemote(o.toString());
|
|
|
}
|