Commit 0b67b19b670bffd89f169b61cc8c24ad89f6332b
1 parent
f20d81f6
1 修复用户在运动开始后,地理围栏不生效的问题
Showing
7 changed files
with
43 additions
and
32 deletions
config.gradle
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| @@ -1014,7 +1014,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -1014,7 +1014,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 1014 | //获取用户暂停的时间戳 | 1014 | //获取用户暂停的时间戳 |
| 1015 | long userPauseTime = userStepEntity.getChronometerBase(); | 1015 | long userPauseTime = userStepEntity.getChronometerBase(); |
| 1016 | //判断时间是否小于9小时 | 1016 | //判断时间是否小于9小时 |
| 1017 | - Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime); | 1017 | +// Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime); |
| 1018 | if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { | 1018 | if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { |
| 1019 | Log.e(TAG, "小于9小时"); | 1019 | Log.e(TAG, "小于9小时"); |
| 1020 | fragment.binding.tvRunNow.setText("继续运动"); | 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,7 +38,7 @@ public class Constant { | ||
| 38 | public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围 | 38 | public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围 |
| 39 | public static final int LOCA_ACCURACY = 20;//定位过滤精度 | 39 | public static final int LOCA_ACCURACY = 20;//定位过滤精度 |
| 40 | public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度 | 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 | public static final int FENCE_OFFSET = 70;//围栏偏离距离 | 42 | public static final int FENCE_OFFSET = 70;//围栏偏离距离 |
| 43 | public static final int FENCE_DENOISE = 70;//围栏去噪精度 | 43 | public static final int FENCE_DENOISE = 70;//围栏去噪精度 |
| 44 | public static final int TAKE_POINT_MAX_SIZE = 100;//最大打点数量 | 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,10 +369,10 @@ public class StepService extends Service implements SensorEventListener { | ||
| 369 | return; | 369 | return; |
| 370 | } | 370 | } |
| 371 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | 371 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); |
| 372 | - if (null == userStepEntity) { | 372 | + if (null == userStepEntity || TextUtils.isEmpty(userStepEntity.getFenceId())) { |
| 373 | return; | 373 | return; |
| 374 | } | 374 | } |
| 375 | - if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) { | 375 | + if (alarmPushInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) { |
| 376 | //超出范围 | 376 | //超出范围 |
| 377 | if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) { | 377 | if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) { |
| 378 | EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, "")); | 378 | EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, "")); |
| @@ -398,7 +398,7 @@ public class StepService extends Service implements SensorEventListener { | @@ -398,7 +398,7 @@ public class StepService extends Service implements SensorEventListener { | ||
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | public void startQueryFence() { | 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 | OnFenceListener onFenceListener = new OnFenceListener() { | 403 | OnFenceListener onFenceListener = new OnFenceListener() { |
| 404 | // 创建围栏回调 | 404 | // 创建围栏回调 |
| @@ -442,11 +442,11 @@ public class StepService extends Service implements SensorEventListener { | @@ -442,11 +442,11 @@ public class StepService extends Service implements SensorEventListener { | ||
| 442 | Toast.makeText(getApplicationContext(), "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show(); | 442 | Toast.makeText(getApplicationContext(), "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show(); |
| 443 | } //查询监控对象状态响应结果 | 443 | } //查询监控对象状态响应结果 |
| 444 | List<MonitoredStatusInfo> monitoredStatusInfos = monitoredStatusResponse.getMonitoredStatusInfos(); | 444 | List<MonitoredStatusInfo> monitoredStatusInfos = monitoredStatusResponse.getMonitoredStatusInfos(); |
| 445 | - if (monitoredStatusInfos == null) { | 445 | + if (monitoredStatusInfos == null||TextUtils.isEmpty(userStepEntity.getFenceId())) { |
| 446 | return; | 446 | return; |
| 447 | } | 447 | } |
| 448 | for (MonitoredStatusInfo monitoredStatusInfo : monitoredStatusInfos) { | 448 | for (MonitoredStatusInfo monitoredStatusInfo : monitoredStatusInfos) { |
| 449 | - if (monitoredStatusInfo.getFenceId() == userStepEntity.getFenceId()) { | 449 | + if (monitoredStatusInfo.getFenceId() == Long.parseLong(userStepEntity.getFenceId())) { |
| 450 | MonitoredStatus status = monitoredStatusInfo.getMonitoredStatus();//获取状态 | 450 | MonitoredStatus status = monitoredStatusInfo.getMonitoredStatus();//获取状态 |
| 451 | switch (status) { | 451 | switch (status) { |
| 452 | case in: | 452 | case in: |
| @@ -498,9 +498,9 @@ public class StepService extends Service implements SensorEventListener { | @@ -498,9 +498,9 @@ public class StepService extends Service implements SensorEventListener { | ||
| 498 | Log.e(TAG, "onListMonitoredPersonCallback: "); | 498 | Log.e(TAG, "onListMonitoredPersonCallback: "); |
| 499 | } | 499 | } |
| 500 | }; | 500 | }; |
| 501 | - if (userStepEntity != null) { | 501 | + if (userStepEntity != null||TextUtils.isEmpty(userStepEntity.getFenceId())) { |
| 502 | List<Long> fenids = new ArrayList<>(); | 502 | List<Long> fenids = new ArrayList<>(); |
| 503 | - fenids.add(userStepEntity.getFenceId()); | 503 | + fenids.add(Long.parseLong(userStepEntity.getFenceId())); |
| 504 | MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, | 504 | MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, |
| 505 | Constant.SERVICE_ID, userId, fenids); | 505 | Constant.SERVICE_ID, userId, fenids); |
| 506 | if (mClient != null) { | 506 | if (mClient != null) { |
| @@ -525,11 +525,13 @@ public class StepService extends Service implements SensorEventListener { | @@ -525,11 +525,13 @@ public class StepService extends Service implements SensorEventListener { | ||
| 525 | } | 525 | } |
| 526 | //设置围栏ID | 526 | //设置围栏ID |
| 527 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | 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 | entityName = userId; | 536 | entityName = userId; |
| 535 | initTodayData(userId); | 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<UserStepEntity, String> { | @@ -42,7 +42,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 42 | public final static Property QueryTraceEndTime = new Property(15, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME"); | 42 | public final static Property QueryTraceEndTime = new Property(15, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME"); |
| 43 | public final static Property QueryEntityName = new Property(16, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME"); | 43 | public final static Property QueryEntityName = new Property(16, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME"); |
| 44 | public final static Property ContinueTime = new Property(17, long.class, "continueTime", false, "CONTINUE_TIME"); | 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 | public final static Property ImportPoint = new Property(19, String.class, "importPoint", false, "IMPORT_POINT"); | 46 | public final static Property ImportPoint = new Property(19, String.class, "importPoint", false, "IMPORT_POINT"); |
| 47 | public final static Property StreetTitle = new Property(20, String.class, "streetTitle", false, "STREET_TITLE"); | 47 | public final static Property StreetTitle = new Property(20, String.class, "streetTitle", false, "STREET_TITLE"); |
| 48 | public final static Property EndLatLng = new Property(21, String.class, "endLatLng", false, "END_LAT_LNG"); | 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<UserStepEntity, String> { | @@ -80,7 +80,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 80 | "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 15: queryTraceEndTime | 80 | "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 15: queryTraceEndTime |
| 81 | "\"QUERY_ENTITY_NAME\" TEXT," + // 16: queryEntityName | 81 | "\"QUERY_ENTITY_NAME\" TEXT," + // 16: queryEntityName |
| 82 | "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 17: continueTime | 82 | "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 17: continueTime |
| 83 | - "\"FENCE_ID\" INTEGER NOT NULL ," + // 18: fenceId | 83 | + "\"FENCE_ID\" TEXT," + // 18: fenceId |
| 84 | "\"IMPORT_POINT\" TEXT," + // 19: importPoint | 84 | "\"IMPORT_POINT\" TEXT," + // 19: importPoint |
| 85 | "\"STREET_TITLE\" TEXT," + // 20: streetTitle | 85 | "\"STREET_TITLE\" TEXT," + // 20: streetTitle |
| 86 | "\"END_LAT_LNG\" TEXT," + // 21: endLatLng | 86 | "\"END_LAT_LNG\" TEXT," + // 21: endLatLng |
| @@ -146,7 +146,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -146,7 +146,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 146 | stmt.bindString(17, queryEntityName); | 146 | stmt.bindString(17, queryEntityName); |
| 147 | } | 147 | } |
| 148 | stmt.bindLong(18, entity.getContinueTime()); | 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 | String importPoint = entity.getImportPoint(); | 155 | String importPoint = entity.getImportPoint(); |
| 152 | if (importPoint != null) { | 156 | if (importPoint != null) { |
| @@ -218,7 +222,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -218,7 +222,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 218 | stmt.bindString(17, queryEntityName); | 222 | stmt.bindString(17, queryEntityName); |
| 219 | } | 223 | } |
| 220 | stmt.bindLong(18, entity.getContinueTime()); | 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 | String importPoint = entity.getImportPoint(); | 231 | String importPoint = entity.getImportPoint(); |
| 224 | if (importPoint != null) { | 232 | if (importPoint != null) { |
| @@ -263,7 +271,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -263,7 +271,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 263 | cursor.getLong(offset + 15), // queryTraceEndTime | 271 | cursor.getLong(offset + 15), // queryTraceEndTime |
| 264 | cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // queryEntityName | 272 | cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // queryEntityName |
| 265 | cursor.getLong(offset + 17), // continueTime | 273 | cursor.getLong(offset + 17), // continueTime |
| 266 | - cursor.getLong(offset + 18), // fenceId | 274 | + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // fenceId |
| 267 | cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // importPoint | 275 | cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // importPoint |
| 268 | cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // streetTitle | 276 | cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // streetTitle |
| 269 | cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // endLatLng | 277 | cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // endLatLng |
| @@ -292,7 +300,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -292,7 +300,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 292 | entity.setQueryTraceEndTime(cursor.getLong(offset + 15)); | 300 | entity.setQueryTraceEndTime(cursor.getLong(offset + 15)); |
| 293 | entity.setQueryEntityName(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); | 301 | entity.setQueryEntityName(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); |
| 294 | entity.setContinueTime(cursor.getLong(offset + 17)); | 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 | entity.setImportPoint(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); | 304 | entity.setImportPoint(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); |
| 297 | entity.setStreetTitle(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); | 305 | entity.setStreetTitle(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); |
| 298 | entity.setEndLatLng(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); | 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,15 +27,15 @@ public class UserStepEntity { | ||
| 27 | private long queryTraceEndTime;//从服务器获取的结束时间呢 | 27 | private long queryTraceEndTime;//从服务器获取的结束时间呢 |
| 28 | private String queryEntityName;//从服务器获取的运营人员的实体名称 | 28 | private String queryEntityName;//从服务器获取的运营人员的实体名称 |
| 29 | private long continueTime;//继续运动时间 | 29 | private long continueTime;//继续运动时间 |
| 30 | - private long fenceId;//围栏id | 30 | + private String fenceId;//围栏id |
| 31 | private String importPoint;//关键点 | 31 | private String importPoint;//关键点 |
| 32 | private String streetTitle;//赛事标题 | 32 | private String streetTitle;//赛事标题 |
| 33 | private String endLatLng;//终点坐标 | 33 | private String endLatLng;//终点坐标 |
| 34 | private boolean isArriveEndPoint;//是否到达终点 | 34 | private boolean isArriveEndPoint;//是否到达终点 |
| 35 | - @Generated(hash = 434792384) | 35 | + @Generated(hash = 640124145) |
| 36 | public UserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, String startPoint, String endPoint, | 36 | public UserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, String startPoint, String endPoint, |
| 37 | long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime, | 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 | this.userId = userId; | 39 | this.userId = userId; |
| 40 | this.date = date; | 40 | this.date = date; |
| 41 | this.stepCount = stepCount; | 41 | this.stepCount = stepCount; |
| @@ -210,13 +210,6 @@ public class UserStepEntity { | @@ -210,13 +210,6 @@ public class UserStepEntity { | ||
| 210 | this.continueTime = continueTime; | 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 | public String getImportPoint() { | 214 | public String getImportPoint() { |
| 222 | return this.importPoint; | 215 | return this.importPoint; |
| @@ -250,6 +243,14 @@ public class UserStepEntity { | @@ -250,6 +243,14 @@ public class UserStepEntity { | ||
| 250 | this.endLatLng = endLatLng; | 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,7 +215,7 @@ public class StepUtil { | ||
| 215 | * @param uid | 215 | * @param uid |
| 216 | * @param fenceId | 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 | try { | 219 | try { |
| 220 | if (getUserStepData(context, uid) != null) { | 220 | if (getUserStepData(context, uid) != null) { |
| 221 | UserStepEntity entity = getUserStepData(context, uid); | 221 | UserStepEntity entity = getUserStepData(context, uid); |