|
|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.appme.pedometer.utils;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
+import android.support.v4.content.LocalBroadcastManager;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.common.LogUtil;
|
|
|
@@ -9,6 +10,7 @@ import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
|
+import com.core.app.AppConstant;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.TimeUtils;
|
|
|
@@ -18,6 +20,7 @@ import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
import com.uas.appme.pedometer.bean.PersonalStepBean;
|
|
|
import com.uas.appme.pedometer.bean.StepEntity;
|
|
|
+import com.uas.appme.pedometer.bean.StepsRankingBean;
|
|
|
import com.uas.appme.pedometer.constant.Constant;
|
|
|
import com.uas.appme.pedometer.db.StepDataDao;
|
|
|
|
|
|
@@ -53,7 +56,6 @@ 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>() {
|
|
|
@@ -73,10 +75,12 @@ public class StepUtils {
|
|
|
*/
|
|
|
public static void canUnloadToRemote(String s) {
|
|
|
PersonalStepBean mPersonalStepBean = new PersonalStepBean();
|
|
|
- mPersonalStepBean = JSON.parseObject(s.toString(), PersonalStepBean.class);
|
|
|
- String CURRENT_DATE = TimeUtil.getCurrentDate();
|
|
|
- StepDataDao stepDataDao = new StepDataDao(MyApplication.getInstance());
|
|
|
- StepEntity stepEntity = stepDataDao.getCurDataByDate(CURRENT_DATE);
|
|
|
+ try {
|
|
|
+ if (!JSONUtil.validate(s)) return;
|
|
|
+ mPersonalStepBean = JSON.parseObject(s.toString(), PersonalStepBean.class);
|
|
|
+ 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);
|
|
|
@@ -84,13 +88,8 @@ public class StepUtils {
|
|
|
}
|
|
|
int remoteSteps = CommonUtil.getNumByString(mPersonalStepBean.getWeekSteps().get(mPersonalStepBean.getWeekSteps().size() - 1).getAs_uusteps());
|
|
|
|
|
|
- try {
|
|
|
- if (stepEntity == null) {
|
|
|
-// stepEntity = new StepEntity();
|
|
|
-// stepEntity.setSteps(remoteSteps + "");
|
|
|
-// stepEntity.setCurDate(CURRENT_DATE);
|
|
|
-// stepDataDao.addNewData(stepEntity);
|
|
|
|
|
|
+ if (stepEntity == null) {
|
|
|
Intent intent = new Intent("addStepEntity");
|
|
|
intent.putExtra("remoteSteps", remoteSteps);
|
|
|
BaseConfig.getContext().sendBroadcast(intent);
|
|
|
@@ -148,6 +147,26 @@ public class StepUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * UURANKing列表点赞后的逻辑
|
|
|
+ * @param model
|
|
|
+ * @param type
|
|
|
+ * @param position
|
|
|
+ */
|
|
|
+ public static void doStepPriseHttp(StepsRankingBean model, int type, int position) {
|
|
|
+ switch (type){
|
|
|
+ case 2:
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 请求操作成功后发广播更新排行版界面
|
|
|
+ //发送本地广播
|
|
|
+ LocalBroadcastManager.getInstance(MyApplication.getInstance().getApplicationContext()).sendBroadcast(new Intent(AppConstant.UPDATE_STEPRANKING_PRISE));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 分享UU运动的发消息方法
|
|
|
* @param activity 上下文
|