Commit 0b67b19b670bffd89f169b61cc8c24ad89f6332b

Authored by 杨帅
1 parent f20d81f6

1 修复用户在运动开始后,地理围栏不生效的问题

config.gradle
... ... @@ -21,7 +21,7 @@ ext {
21 21 //编译方式
22 22 debug : false,
23 23 //版本号
24   - version: "0.5.6",
  24 + version: "0.5.7",
25 25 //Lib库前缀
26 26 packeg : "com.cnlive.module",
27 27 //Lib库名称
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -1014,7 +1014,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1014 1014 //获取用户暂停的时间戳
1015 1015 long userPauseTime = userStepEntity.getChronometerBase();
1016 1016 //判断时间是否小于9小时
1017   - Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime);
  1017 +// Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime);
1018 1018 if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) {
1019 1019 Log.e(TAG, "小于9小时");
1020 1020 fragment.binding.tvRunNow.setText("继续运动");
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
... ... @@ -38,7 +38,7 @@ public class Constant {
38 38 public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围
39 39 public static final int LOCA_ACCURACY = 20;//定位过滤精度
40 40 public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度
41   - public static final int LOCA_START_POINT_ACCURACY = 20;//起点位置比较精度
  41 + public static final int LOCA_START_POINT_ACCURACY = 200;//起点位置比较精度
42 42 public static final int FENCE_OFFSET = 70;//围栏偏离距离
43 43 public static final int FENCE_DENOISE = 70;//围栏去噪精度
44 44 public static final int TAKE_POINT_MAX_SIZE = 100;//最大打点数量
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -369,10 +369,10 @@ public class StepService extends Service implements SensorEventListener {
369 369 return;
370 370 }
371 371 UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
372   - if (null == userStepEntity) {
  372 + if (null == userStepEntity || TextUtils.isEmpty(userStepEntity.getFenceId())) {
373 373 return;
374 374 }
375   - if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) {
  375 + if (alarmPushInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) {
376 376 //超出范围
377 377 if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) {
378 378 EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, ""));
... ... @@ -398,7 +398,7 @@ public class StepService extends Service implements SensorEventListener {
398 398 }
399 399  
400 400 public void startQueryFence() {
401   - UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
  401 + final UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
402 402 // 初始化围栏监听器
403 403 OnFenceListener onFenceListener = new OnFenceListener() {
404 404 // 创建围栏回调
... ... @@ -442,11 +442,11 @@ public class StepService extends Service implements SensorEventListener {
442 442 Toast.makeText(getApplicationContext(), "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show();
443 443 } //查询监控对象状态响应结果
444 444 List<MonitoredStatusInfo> monitoredStatusInfos = monitoredStatusResponse.getMonitoredStatusInfos();
445   - if (monitoredStatusInfos == null) {
  445 + if (monitoredStatusInfos == null||TextUtils.isEmpty(userStepEntity.getFenceId())) {
446 446 return;
447 447 }
448 448 for (MonitoredStatusInfo monitoredStatusInfo : monitoredStatusInfos) {
449   - if (monitoredStatusInfo.getFenceId() == userStepEntity.getFenceId()) {
  449 + if (monitoredStatusInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) {
450 450 MonitoredStatus status = monitoredStatusInfo.getMonitoredStatus();//获取状态
451 451 switch (status) {
452 452 case in:
... ... @@ -498,9 +498,9 @@ public class StepService extends Service implements SensorEventListener {
498 498 Log.e(TAG, "onListMonitoredPersonCallback: ");
499 499 }
500 500 };
501   - if (userStepEntity != null) {
  501 + if (userStepEntity != null||TextUtils.isEmpty(userStepEntity.getFenceId())) {
502 502 List<Long> fenids = new ArrayList<>();
503   - fenids.add(userStepEntity.getFenceId());
  503 + fenids.add(Long.parseLong(userStepEntity.getFenceId()));
504 504 MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG,
505 505 Constant.SERVICE_ID, userId, fenids);
506 506 if (mClient != null) {
... ... @@ -525,11 +525,13 @@ public class StepService extends Service implements SensorEventListener {
525 525 }
526 526 //设置围栏ID
527 527 UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
528   - if (userStepEntity == null) {
529   - int fenceId = CommonInfo.getFenceId(getApplicationContext());
530   - Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId);
531   - //设置围栏id
532   - StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId);
  528 + if (userStepEntity != null) {
  529 + if (TextUtils.isEmpty(userStepEntity.getFenceId())) {
  530 + int fenceId = CommonInfo.getFenceId(getApplicationContext());
  531 + Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId);
  532 + //设置围栏id
  533 + StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId + "");
  534 + }
533 535 }
534 536 entityName = userId;
535 537 initTodayData(userId);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
... ... @@ -42,7 +42,7 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
42 42 public final static Property QueryTraceEndTime = new Property(15, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME");
43 43 public final static Property QueryEntityName = new Property(16, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME");
44 44 public final static Property ContinueTime = new Property(17, long.class, "continueTime", false, "CONTINUE_TIME");
45   - public final static Property FenceId = new Property(18, long.class, "fenceId", false, "FENCE_ID");
  45 + public final static Property FenceId = new Property(18, String.class, "fenceId", false, "FENCE_ID");
46 46 public final static Property ImportPoint = new Property(19, String.class, "importPoint", false, "IMPORT_POINT");
47 47 public final static Property StreetTitle = new Property(20, String.class, "streetTitle", false, "STREET_TITLE");
48 48 public final static Property EndLatLng = new Property(21, String.class, "endLatLng", false, "END_LAT_LNG");
... ... @@ -80,7 +80,7 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
80 80 "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 15: queryTraceEndTime
81 81 "\"QUERY_ENTITY_NAME\" TEXT," + // 16: queryEntityName
82 82 "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 17: continueTime
83   - "\"FENCE_ID\" INTEGER NOT NULL ," + // 18: fenceId
  83 + "\"FENCE_ID\" TEXT," + // 18: fenceId
84 84 "\"IMPORT_POINT\" TEXT," + // 19: importPoint
85 85 "\"STREET_TITLE\" TEXT," + // 20: streetTitle
86 86 "\"END_LAT_LNG\" TEXT," + // 21: endLatLng
... ... @@ -146,7 +146,11 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
146 146 stmt.bindString(17, queryEntityName);
147 147 }
148 148 stmt.bindLong(18, entity.getContinueTime());
149   - stmt.bindLong(19, entity.getFenceId());
  149 +
  150 + String fenceId = entity.getFenceId();
  151 + if (fenceId != null) {
  152 + stmt.bindString(19, fenceId);
  153 + }
150 154  
151 155 String importPoint = entity.getImportPoint();
152 156 if (importPoint != null) {
... ... @@ -218,7 +222,11 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
218 222 stmt.bindString(17, queryEntityName);
219 223 }
220 224 stmt.bindLong(18, entity.getContinueTime());
221   - stmt.bindLong(19, entity.getFenceId());
  225 +
  226 + String fenceId = entity.getFenceId();
  227 + if (fenceId != null) {
  228 + stmt.bindString(19, fenceId);
  229 + }
222 230  
223 231 String importPoint = entity.getImportPoint();
224 232 if (importPoint != null) {
... ... @@ -263,7 +271,7 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
263 271 cursor.getLong(offset + 15), // queryTraceEndTime
264 272 cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // queryEntityName
265 273 cursor.getLong(offset + 17), // continueTime
266   - cursor.getLong(offset + 18), // fenceId
  274 + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // fenceId
267 275 cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // importPoint
268 276 cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // streetTitle
269 277 cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // endLatLng
... ... @@ -292,7 +300,7 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
292 300 entity.setQueryTraceEndTime(cursor.getLong(offset + 15));
293 301 entity.setQueryEntityName(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
294 302 entity.setContinueTime(cursor.getLong(offset + 17));
295   - entity.setFenceId(cursor.getLong(offset + 18));
  303 + entity.setFenceId(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
296 304 entity.setImportPoint(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
297 305 entity.setStreetTitle(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
298 306 entity.setEndLatLng(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
... ... @@ -27,15 +27,15 @@ public class UserStepEntity {
27 27 private long queryTraceEndTime;//从服务器获取的结束时间呢
28 28 private String queryEntityName;//从服务器获取的运营人员的实体名称
29 29 private long continueTime;//继续运动时间
30   - private long fenceId;//围栏id
  30 + private String fenceId;//围栏id
31 31 private String importPoint;//关键点
32 32 private String streetTitle;//赛事标题
33 33 private String endLatLng;//终点坐标
34 34 private boolean isArriveEndPoint;//是否到达终点
35   - @Generated(hash = 434792384)
  35 + @Generated(hash = 640124145)
36 36 public UserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, String startPoint, String endPoint,
37 37 long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime,
38   - String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint) {
  38 + String queryEntityName, long continueTime, String fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint) {
39 39 this.userId = userId;
40 40 this.date = date;
41 41 this.stepCount = stepCount;
... ... @@ -210,13 +210,6 @@ public class UserStepEntity {
210 210 this.continueTime = continueTime;
211 211 }
212 212  
213   - public long getFenceId() {
214   - return this.fenceId;
215   - }
216   -
217   - public void setFenceId(long fenceId) {
218   - this.fenceId = fenceId;
219   - }
220 213  
221 214 public String getImportPoint() {
222 215 return this.importPoint;
... ... @@ -250,6 +243,14 @@ public class UserStepEntity {
250 243 this.endLatLng = endLatLng;
251 244 }
252 245  
  246 + public String getFenceId() {
  247 + return this.fenceId;
  248 + }
  249 +
  250 + public void setFenceId(String fenceId) {
  251 + this.fenceId = fenceId;
  252 + }
  253 +
253 254  
254 255  
255 256 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -215,7 +215,7 @@ public class StepUtil {
215 215 * @param uid
216 216 * @param fenceId
217 217 */
218   - public static void setFenceId(Context context, String uid, long fenceId) {
  218 + public static void setFenceId(Context context, String uid, String fenceId) {
219 219 try {
220 220 if (getUserStepData(context, uid) != null) {
221 221 UserStepEntity entity = getUserStepData(context, uid);
... ...