Commit 04e2c880ab2bafb5c39cd229e8fb1ccf88379832

Authored by 杨帅
1 parent c689e4c6

1 修复上传数据页面,用户暂停后,无法显示暂停路线问题

moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
... ... @@ -28,8 +28,22 @@ import android.widget.Toast;
28 28  
29 29 import com.baidu.trace.LBSTraceClient;
30 30 import com.baidu.trace.Trace;
  31 +import com.baidu.trace.api.fence.AddMonitoredPersonResponse;
  32 +import com.baidu.trace.api.fence.CreateFenceResponse;
  33 +import com.baidu.trace.api.fence.DeleteFenceResponse;
  34 +import com.baidu.trace.api.fence.DeleteMonitoredPersonResponse;
31 35 import com.baidu.trace.api.fence.FenceAlarmPushInfo;
  36 +import com.baidu.trace.api.fence.FenceListResponse;
  37 +import com.baidu.trace.api.fence.HistoryAlarmResponse;
  38 +import com.baidu.trace.api.fence.ListMonitoredPersonResponse;
32 39 import com.baidu.trace.api.fence.MonitoredAction;
  40 +import com.baidu.trace.api.fence.MonitoredStatus;
  41 +import com.baidu.trace.api.fence.MonitoredStatusByLocationResponse;
  42 +import com.baidu.trace.api.fence.MonitoredStatusInfo;
  43 +import com.baidu.trace.api.fence.MonitoredStatusRequest;
  44 +import com.baidu.trace.api.fence.MonitoredStatusResponse;
  45 +import com.baidu.trace.api.fence.OnFenceListener;
  46 +import com.baidu.trace.api.fence.UpdateFenceResponse;
33 47 import com.baidu.trace.api.track.LatestPoint;
34 48 import com.baidu.trace.api.track.LatestPointResponse;
35 49 import com.baidu.trace.api.track.OnTrackListener;
... ... @@ -43,11 +57,15 @@ import com.cnlive.moudle.pedometer.model.Constant;
43 57 import com.cnlive.moudle.pedometer.model.MessageEvent;
44 58 import com.cnlive.moudle.pedometer.model.step.StepCount;
45 59 import com.cnlive.moudle.pedometer.model.step.StepValuePassListener;
  60 +import com.cnlive.moudle.pedometer.service.KeepLiveService;
  61 +import com.cnlive.moudle.pedometer.service.StepService;
46 62 import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
47 63 import com.cnlive.moudle.pedometer.sql.db.DbCore;
48 64 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
  65 +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
49 66 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
50 67 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
  68 +import com.cnlive.moudle.pedometer.utils.StepUtil;
51 69 import com.cnlive.moudle.pedometer.utils.TimeUtil;
52 70 import com.example.moudle_pedometer.R;
53 71  
... ... @@ -56,6 +74,7 @@ import org.greenrobot.eventbus.Subscribe;
56 74 import org.greenrobot.eventbus.ThreadMode;
57 75  
58 76 import java.text.SimpleDateFormat;
  77 +import java.util.ArrayList;
59 78 import java.util.Date;
60 79 import java.util.List;
61 80 import java.util.UUID;
... ... @@ -63,8 +82,7 @@ import java.util.UUID;
63 82  
64 83 public class CollStepService extends Service implements SensorEventListener {
65 84  
66   - private String TAG = "CollStepService";
67   -
  85 + private String TAG = "StepService";
68 86 /**
69 87 * 通知栏相关
70 88 */
... ... @@ -92,11 +110,11 @@ public class CollStepService extends Service implements SensorEventListener {
92 110 /**
93 111 * 保存记步计时器
94 112 */
95   - private TimeCount time;
  113 + private static TimeCount time;
96 114 /**
97 115 * 当前所走的步数
98 116 */
99   - private int CURRENT_STEP;
  117 + private int CURRENT_STEP = 0;
100 118 /**
101 119 * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR
102 120 */
... ... @@ -120,12 +138,12 @@ public class CollStepService extends Service implements SensorEventListener {
120 138 /**
121 139 * IBinder对象,向Activity传递数据的桥梁
122 140 */
123   - private StepBinder stepBinder = new StepBinder();
  141 + private CollStepService.StepBinder stepBinder = new CollStepService.StepBinder();
124 142 private String userId;
125 143 private Handler handler;
126 144 private Runnable speedRunnable;
127 145 private final int NOTIFICATION_ID = 100;
128   - private static int tempStep;//计步器临时保存步数
  146 + // private static int tempStep;//计步器临时保存步数
129 147 private static boolean pauseFlag;//是否暂停
130 148 private static int speedCurrentStep;//用于检测速度步数
131 149 private boolean updateSpeedStepFlag;//是否是已经更新速度
... ... @@ -139,7 +157,6 @@ public class CollStepService extends Service implements SensorEventListener {
139 157 * 轨迹监听器(用于接收纠偏后实时位置回调)
140 158 */
141 159 private OnTrackListener realTimeTraceListener = null;
142   -// public static final long serviceId = 213553;//杨帅
143 160  
144 161 // 设备标识
145 162 public static String entityName = "";
... ... @@ -153,8 +170,6 @@ public class CollStepService extends Service implements SensorEventListener {
153 170 */
154 171 public static Trace mTrace = null;
155 172  
156   - private boolean isFirstSendNotification = true;
157   -
158 173 public CollStepService() {
159 174  
160 175 }
... ... @@ -165,11 +180,19 @@ public class CollStepService extends Service implements SensorEventListener {
165 180 super.onCreate();
166 181 init();
167 182 initBroadcastReceiver();
  183 + if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.CollKeepLiveService")) {
  184 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  185 + startForegroundService(new Intent(getApplicationContext(), KeepLiveService.class));
  186 + } else {
  187 + startService(new Intent(getApplicationContext(), KeepLiveService.class));
  188 + }
  189 + }
168 190 showStartForegroundNotification();
169 191 }
170 192  
171   - private void initTrace() {
  193 + private static int retryIndex = 0;
172 194  
  195 + private void initTrace() {
173 196 if (mClient == null) {
174 197 mClient = new LBSTraceClient(getApplicationContext());
175 198 // 设置定位和打包周期
... ... @@ -228,9 +251,33 @@ public class CollStepService extends Service implements SensorEventListener {
228 251 if (StatusCodes.SUCCESS == errorNo || StatusCodes.START_TRACE_NETWORK_CONNECT_FAILED <= errorNo) {
229 252 //开始进行采集
230 253 if (mClient != null) {
  254 + retryIndex = 0;
231 255 mClient.startGather(traceListener);
232 256 Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show();
  257 + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
  258 + if (isFirstSendNotification) {
  259 + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
  260 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, ""));
  261 + }
  262 +
  263 +
  264 + }
  265 + } else {
  266 +
  267 + if (retryIndex < 4) {
  268 + //重新开启服务
  269 + if (mClient != null) {
  270 + mClient.startTrace(mTrace, traceListener);
  271 + retryIndex++;
  272 + }
  273 + } else {
  274 + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
  275 + if (isFirstSendNotification) {
  276 + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
  277 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
  278 + }
233 279 }
  280 +
234 281 }
235 282 }
236 283  
... ... @@ -269,17 +316,15 @@ public class CollStepService extends Service implements SensorEventListener {
269 316 @Override
270 317 public void onStartGatherCallback(int errorNo, String message) {
271 318 if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) {
  319 + retryIndex = 0;
272 320 Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show();
273   - boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
274   - if (isFirstSendNotification) {
275   - CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
276   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, ""));
277   - }
278 321 } else {
279   - boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
280   - if (isFirstSendNotification) {
281   - CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
282   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
  322 + //重新开启采集
  323 + if (retryIndex < 4) {
  324 + if (null != mClient) {
  325 + mClient.startGather(traceListener);
  326 + }
  327 + retryIndex++;
283 328 }
284 329 }
285 330 }
... ... @@ -320,24 +365,6 @@ public class CollStepService extends Service implements SensorEventListener {
320 365 @Override
321 366 public void onPushCallback(byte messageType, PushMessage pushMessage) {
322 367 Log.e(TAG, "onPushCallback: ");
323   -
324   - if (messageType < 0x03 || messageType > 0x04) {
325   - return;
326   - }
327   - FenceAlarmPushInfo alarmPushInfo = pushMessage.getFenceAlarmPushInfo();
328   - if (null == alarmPushInfo) {
329   - return;
330   - }
331   - //超出范围
332   - if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) {
333   - EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, ""));
334   - }
335   - //进入范围
336   - else if (alarmPushInfo.getMonitoredAction() == MonitoredAction.enter) {
337   - EventBus.getDefault().post(new MessageEvent(Constant.ENTER_RANGE, ""));
338   - }
339   - Toast.makeText(getApplicationContext(), "onPushCallback:" + alarmPushInfo.getMonitoredAction(), Toast.LENGTH_SHORT).show();
340   -
341 368 }
342 369  
343 370 @Override
... ... @@ -348,14 +375,11 @@ public class CollStepService extends Service implements SensorEventListener {
348 375 //开启轨迹服务
349 376 if (mClient != null) {
350 377 mClient.startTrace(mTrace, traceListener);
351   - long stepStartTime = CollCommonInfo.getStepStartTime(getApplicationContext());
352   - if (stepStartTime == 0) {
353   - CollCommonInfo.setStepStartTime(getApplicationContext(), TimeUtil.getNowTimeStamp());
354   - }
355 378 }
356 379  
357 380 }
358 381  
  382 +
359 383 private long i = 0;
360 384 private long index = 0;
361 385 private int mJobId;
... ... @@ -369,7 +393,6 @@ public class CollStepService extends Service implements SensorEventListener {
369 393 if (!EventBus.getDefault().isRegistered(this)) {
370 394 EventBus.getDefault().register(this);
371 395 }
372   -
373 396 entityName = userId;
374 397 initTodayData(userId);
375 398 initTrace();
... ... @@ -383,8 +406,7 @@ public class CollStepService extends Service implements SensorEventListener {
383 406 }).start();
384 407 startTimeCount();
385 408 } else {
386   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
387   -
  409 + EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, ""));
388 410 }
389 411 // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
390 412 // //开始配置JobInfo
... ... @@ -406,7 +428,7 @@ public class CollStepService extends Service implements SensorEventListener {
406 428 }
407 429  
408 430 private void init() {
409   - CommonInfo.setIsRunStepService(getApplicationContext(), true);
  431 + CollCommonInfo.setIsRunStepService(getApplicationContext(), true);
410 432 if (null == mNM) {
411 433 mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
412 434 }
... ... @@ -431,7 +453,7 @@ public class CollStepService extends Service implements SensorEventListener {
431 453 private void showStartForegroundNotification() {
432 454 remoteViews = new RemoteViews(getPackageName(), R.layout.custom_step_notification);
433 455 NotificationChannel channel = null;
434   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  456 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
435 457 channel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME,
436 458 NotificationManager.IMPORTANCE_HIGH);
437 459 channel.enableLights(false);
... ... @@ -481,7 +503,18 @@ public class CollStepService extends Service implements SensorEventListener {
481 503 if (speedRunnable != null) {
482 504 handler.removeCallbacks(speedRunnable);
483 505 }
484   - Log.e("杀死", "MyTestService");
  506 +// Log.e("杀死", "MyTestService");
  507 + lastStep = 0;
  508 + hasStepCount = 0;
  509 + hasRecord = false;
  510 + CURRENT_STEP = 0;
  511 + previousStepCount = 0;
  512 + if (sensorManager != null) {
  513 + sensorManager.unregisterListener(CollStepService.this);
  514 + sensorManager = null;
  515 + }
  516 + stepSensorType = -1;
  517 + time = null;
485 518 }
486 519  
487 520 //接收事件
... ... @@ -544,17 +577,15 @@ public class CollStepService extends Service implements SensorEventListener {
544 577 return;
545 578 }
546 579 //获取当天的数据,用于展示 CURRENT_DATE
547   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(userId), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
548   - if (list == null) {
549   - return;
550   - }
551   - if (list.size() == 0 || list.isEmpty()) {
  580 + CollUserStepEntity userStepEntity = StepUtil.getCollUserStepData(getApplicationContext(), CollCommonInfo.getUserId(getApplicationContext()));
  581 + if (userStepEntity == null) {
552 582 CURRENT_STEP = 0;
553   - } else if (list.size() == 1) {
554   - CURRENT_STEP = Integer.parseInt(list.get(0).getStepCount());
555 583 } else {
556   - Log.e(TAG, "出错了!");
  584 + if (userStepEntity.getStepCount() != null) {
  585 + CURRENT_STEP = Integer.parseInt(userStepEntity.getStepCount());
  586 + }
557 587 }
  588 +// Log.e(TAG, "initTodayData: 初始化当前步数" + CURRENT_STEP);
558 589 if (mStepCount != null) {
559 590 mStepCount.setSteps(CURRENT_STEP);
560 591 }
... ... @@ -562,6 +593,7 @@ public class CollStepService extends Service implements SensorEventListener {
562 593 }
563 594  
564 595 private void updateNotification() {
  596 +// Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP);
565 597 EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP));
566 598 updateSpeedStepFlag = false;
567 599 // remoteViews = new RemoteViews(getPackageName(), R.layout.custom_step_notification);
... ... @@ -857,29 +889,45 @@ public class CollStepService extends Service implements SensorEventListener {
857 889 *
858 890 * @param event
859 891 */
  892 + private static int lastStep = 0;//有时候获取的是一样的
  893 +
860 894 @Override
861 895 public void onSensorChanged(SensorEvent event) {
862 896 //没有暂停
863 897 if (stepSensorType == Sensor.TYPE_STEP_COUNTER) {
864 898 //获取当前传感器返回的临时步数
865   - tempStep = (int) event.values[0];
  899 + int tempStep = (int) event.values[0];
  900 +// Log.e(TAG, "onSensorChanged: 第一次,tempStep:" + tempStep + "lastStep:" + lastStep + ",previousStepCount" + previousStepCount + ",CURRENT_STEP" + CURRENT_STEP);
866 901 //首次如果没有获取手机系统中已有的步数则获取一次系统中APP还未开始记步的步数
867 902 if (!hasRecord) {
868 903 hasRecord = true;
869 904 hasStepCount = tempStep;
  905 + previousStepCount = 0;
870 906 } else {
871   - //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数
872   - int thisStepCount = tempStep - hasStepCount;
873   - //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数)
874   - int thisStep = thisStepCount - previousStepCount;
875   - //当用户点击暂停了
876   - if (pauseFlag) {
877   - thisStep = 0;
  907 + if (tempStep > lastStep) {
  908 + //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数
  909 +// Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount);
  910 + int thisStepCount = tempStep - hasStepCount;
  911 +// Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount);
  912 + //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数)
  913 + int thisStep = thisStepCount - previousStepCount;
  914 + //记录最后一次APP打开到现在的总步数
  915 + previousStepCount = thisStepCount;
  916 +// Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount);
  917 + //当用户点击暂停了
  918 + if (pauseFlag) {
  919 + thisStep = 0;
  920 +// Log.e(TAG, "修改: thisStepCount" + thisStep);
  921 + }
  922 +// Log.e(TAG, "onSensorChanged: CURRENT_STEP" + CURRENT_STEP);
  923 + if (CURRENT_STEP < 0) {
  924 + CURRENT_STEP = -CURRENT_STEP;
  925 + }
  926 + //总步数=现有的步数+本次有效步数
  927 + CURRENT_STEP += (thisStep);
  928 +// Log.e(TAG, "onSensorChanged: 加了以后" + CURRENT_STEP);
  929 + lastStep = tempStep;
878 930 }
879   - //总步数=现有的步数+本次有效步数
880   - CURRENT_STEP += (thisStep);
881   - //记录最后一次APP打开到现在的总步数
882   - previousStepCount = thisStepCount;
883 931 }
884 932 } else if (stepSensorType == Sensor.TYPE_STEP_DETECTOR) {
885 933 if (event.values[0] == 1.0) {
... ... @@ -905,27 +953,21 @@ public class CollStepService extends Service implements SensorEventListener {
905 953 * 保存记步数据
906 954 */
907 955 private void save() {
908   - boolean isWriteUserStep = CommonInfo.getIsWriteUserStep(getApplicationContext());
909   - if (!isWriteUserStep) {
910   - return;
911   - }
912 956 int tempStep = CURRENT_STEP;
913   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(userId), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
914   - if (list.size() == 0 || list.isEmpty()) {
915   - CollUserStepEntity data = new CollUserStepEntity();
916   - data.setUuid(UUID.randomUUID().toString());
  957 + UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CollCommonInfo.getUserId(getApplicationContext()));
  958 + if (userStepEntity == null) {
  959 + UserStepEntity data = new UserStepEntity();
917 960 data.setUserId(userId);
918 961 data.setDate(CURRENT_DATE);
919 962 data.setStepCount(tempStep + "");
920   - DbCore.getDaoSession().getCollUserStepEntityDao().insert(data);
921   - } else if (list.size() == 1) {
922   - CollUserStepEntity data = list.get(0);
923   - data.setStepCount(tempStep + "");
924   - DbCore.getDaoSession().getCollUserStepEntityDao().update(data);
  963 + StepUtil.insertStepData(getApplicationContext(), data);
925 964 } else {
  965 + userStepEntity.setStepCount(tempStep + "");
  966 + StepUtil.updateStepData(getApplicationContext(), userStepEntity);
926 967 }
927 968 }
928 969  
  970 +
929 971 /**
930 972 * 保存记步数据
931 973 */
... ... @@ -937,9 +979,11 @@ public class CollStepService extends Service implements SensorEventListener {
937 979 @Override
938 980 public void onFinish() {
939 981 // 如果计时器正常结束,则开始计步
940   - time.cancel();
941   - save();
942   - startTimeCount();
  982 + if (null != time) {
  983 + time.cancel();
  984 + save();
  985 + startTimeCount();
  986 + }
943 987 }
944 988  
945 989 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
... ... @@ -211,6 +211,8 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
211 211 //判断用户是否点击暂停按钮
212 212 if (userStepEntity.getPauseCount() == 0) {
213 213 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
  214 + MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -2f);
  215 +
214 216 //没有点击暂停
215 217 //先判断是否到达终点
216 218 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context);
... ... @@ -231,6 +233,8 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
231 233 allResults.addAll(resultPoints);
232 234 //判断用户是否完成
233 235 if (importPoints != null) {
  236 + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end);
  237 + MyMapUtil.setMapAutoZoom(getView().baiduMap, allResults, -2f);
234 238 //先判断是否到达终点
235 239 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context);
236 240 saveRouteData(context, userStepEntity, runningFinishBean);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
... ... @@ -382,7 +382,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
382 382 if (isPause) {
383 383 MyMapUtil.drawRealTimeTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start);
384 384 } else {
385   - MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
  385 + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, 0);
386 386 }
387 387 }
388 388 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -6,9 +6,11 @@ import android.util.Log;
6 6  
7 7 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
8 8 import com.cnlive.moudle.pedometer.model.Constant;
  9 +import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
9 10 import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao;
10 11 import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
11 12 import com.cnlive.moudle.pedometer.sql.db.DbCore;
  13 +import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
12 14 import com.cnlive.moudle.pedometer.sql.entity.FailedEntity;
13 15 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
14 16  
... ... @@ -264,6 +266,27 @@ public class StepUtil {
264 266 }
265 267  
266 268 /**
  269 + * 获取运营用户数据
  270 + *
  271 + * @param context
  272 + * @param uid
  273 + * @return
  274 + */
  275 + public static CollUserStepEntity getCollUserStepData(Context context, String uid) {
  276 + if (!TextUtils.isEmpty(uid)) {
  277 + DbCore.init(context, dbName);
  278 + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list();
  279 + if (list != null && list.size() > 0) {
  280 + return list.get(0);
  281 + } else {
  282 + return null;
  283 + }
  284 + } else {
  285 + return null;
  286 + }
  287 + }
  288 +
  289 + /**
267 290 * 设置用户数据
268 291 *
269 292 * @param context
... ...