Commit 6fdb98e413a58bae4e9c007ee67ce4f89a5e5c6f

Authored by 韩亚云
2 parents 93f5e6b2 55a3d330

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer

moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
... ... @@ -279,7 +279,28 @@ public class CommonInfo {
279 279 }
280 280  
281 281  
282   -// /**
  282 + /**
  283 + * 设置赛事标题
  284 + *
  285 + * @param context
  286 + * @param streetTitle
  287 + */
  288 + public static void setStreetTitle(Context context, String streetTitle) {
  289 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStreetTitle", streetTitle);
  290 +
  291 + }
  292 +
  293 + /**
  294 + * 获取赛事标题
  295 + *
  296 + * @param context
  297 + */
  298 + public static String getStreetTitle(Context context) {
  299 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runStreetTitle", "");
  300 +
  301 + }
  302 +
  303 + // /**
283 304 // * 设置起点经纬度
284 305 // *
285 306 // * @param context
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -323,6 +323,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
323 323 }
324 324 //设置标题
325 325 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
  326 + CommonInfo.setStreetTitle(getContext(),runRaceDetailInfo.getTitle());
326 327 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
327 328 fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
328 329 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -372,11 +372,7 @@ public class StepService extends Service implements SensorEventListener {
372 372 if (null == userStepEntity) {
373 373 return;
374 374 }
375   - if (userStepEntity.getFenceId() == 0) {
376   - return;
377   - }
378   - if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) {
379   -
  375 + if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId() && alarmPushInfo.getFenceName().equals(userStepEntity.getStreetTitle())) {
380 376 //超出范围
381 377 if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) {
382 378 EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, ""));
... ... @@ -523,6 +519,7 @@ public class StepService extends Service implements SensorEventListener {
523 519 public int onStartCommand(Intent intent, int flags, int startId) {
524 520 userId = CommonInfo.getUserId(getApplicationContext());
525 521 if (userId != null && !TextUtils.isEmpty(userId)) {
  522 + StepUtil.initDataBase(getApplicationContext(), userId);
526 523 if (!EventBus.getDefault().isRegistered(this)) {
527 524 EventBus.getDefault().register(this);
528 525 }
... ... @@ -533,6 +530,9 @@ public class StepService extends Service implements SensorEventListener {
533 530 Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId);
534 531 //设置围栏id
535 532 StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId);
  533 + //设置赛事标题
  534 + String streetTitle = CommonInfo.getStreetTitle(getApplicationContext());
  535 + StepUtil.setStreetTitle(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), streetTitle);
536 536 }
537 537 entityName = userId;
538 538 initTodayData(userId);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -35,6 +35,14 @@ public class StepUtil {
35 35 return UUID.randomUUID().toString().replace("-", "");
36 36 }
37 37  
  38 + public static void initDataBase(Context context, String uid) {
  39 + if (null == getUserStepData(context, uid)) {
  40 + DbCore.init(context, dbName);
  41 + UserStepEntity userStepEntity = new UserStepEntity();
  42 + userStepEntity.setUserId(uid);
  43 + DbCore.getDaoSession().getUserStepEntityDao().insert(userStepEntity);
  44 + }
  45 + }
38 46  
39 47 /**
40 48 * 删除临时保存数据
... ... @@ -107,7 +115,6 @@ public class StepUtil {
107 115 }
108 116  
109 117  
110   -
111 118 /**
112 119 * 设置重要点
113 120 *
... ... @@ -211,7 +218,6 @@ public class StepUtil {
211 218 }
212 219  
213 220  
214   -
215 221 /**
216 222 * 得到当前速度
217 223 *
... ... @@ -338,7 +344,6 @@ public class StepUtil {
338 344 }
339 345  
340 346  
341   -
342 347 /**
343 348 * 设置计步开始时间
344 349 *
... ... @@ -373,8 +378,6 @@ public class StepUtil {
373 378 }
374 379  
375 380  
376   -
377   -
378 381 /**
379 382 * 获取用户暂停次数
380 383 *
... ...