Commit 4614a35985bf98a2a0f7d47b40c52468cdf8f2dd
代码合并
Showing
24 changed files
with
652 additions
and
283 deletions
.idea/gradle.xml
| ... | ... | @@ -3,9 +3,6 @@ |
| 3 | 3 | <component name="GradleSettings"> |
| 4 | 4 | <option name="linkedExternalProjectsSettings"> |
| 5 | 5 | <GradleProjectSettings> |
| 6 | - <compositeConfiguration> | |
| 7 | - <compositeBuild compositeDefinitionSource="SCRIPT" /> | |
| 8 | - </compositeConfiguration> | |
| 9 | 6 | <option name="distributionType" value="DEFAULT_WRAPPED" /> |
| 10 | 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
| 11 | 8 | <option name="modules"> | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
| ... | ... | @@ -348,9 +348,9 @@ public class CollStepService extends Service implements SensorEventListener { |
| 348 | 348 | //开启轨迹服务 |
| 349 | 349 | if (mClient != null) { |
| 350 | 350 | mClient.startTrace(mTrace, traceListener); |
| 351 | - long stepStartTime = CommonInfo.getStepStartTime(getApplicationContext()); | |
| 351 | + long stepStartTime = CollCommonInfo.getStepStartTime(getApplicationContext()); | |
| 352 | 352 | if (stepStartTime == 0) { |
| 353 | - CommonInfo.setStepStartTime(getApplicationContext(), TimeUtil.getCurrentTime()); | |
| 353 | + CollCommonInfo.setStepStartTime(getApplicationContext(), TimeUtil.getNowTimeStamp()); | |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningMapFragment.java
| ... | ... | @@ -15,6 +15,7 @@ import com.cnlive.libs.base.ui.QMUIFragment; |
| 15 | 15 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 16 | 16 | import com.cnlive.moudle.collectionTrace.frame.presenter.CollRunningMapFragmentPresenter; |
| 17 | 17 | import com.cnlive.moudle.collectionTrace.frame.view.CollRunningMapFragmentView; |
| 18 | +import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 18 | 19 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 19 | 20 | import com.cnlive.moudle.pedometer.model.Constant; |
| 20 | 21 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| ... | ... | @@ -104,7 +105,7 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 104 | 105 | } |
| 105 | 106 | //开始进行历史轨迹查询 |
| 106 | 107 | if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) { |
| 107 | - long stepStartTime = CommonInfo.getStepStartTime(getActivity()); | |
| 108 | + long stepStartTime = CollCommonInfo.getStepStartTime(getActivity()); | |
| 108 | 109 | Log.e(TAG, "onViewCreated: 时间"+stepStartTime ); |
| 109 | 110 | long startTime = 0; |
| 110 | 111 | if (stepStartTime != 0) { |
| ... | ... | @@ -112,7 +113,7 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 112 | 113 | } else { |
| 113 | 114 | startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60); |
| 114 | 115 | } |
| 115 | - long current = TimeUtil.getCurrentTime(); | |
| 116 | + long current = TimeUtil.getNowTimeStamp(); | |
| 116 | 117 | // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; |
| 117 | 118 | long endTime = current; |
| 118 | 119 | // Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
| ... | ... | @@ -7,23 +7,23 @@ import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 7 | 7 | |
| 8 | 8 | public class CommonInfo { |
| 9 | 9 | |
| 10 | - /** | |
| 11 | - * 设置计步时间 | |
| 12 | - * | |
| 13 | - * @param context | |
| 14 | - */ | |
| 15 | - public static void setStepStartTime(Context context, long currentTime) { | |
| 16 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("stepStartTime", currentTime); | |
| 17 | - } | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 获取计步时间 | |
| 21 | - * | |
| 22 | - * @param context | |
| 23 | - */ | |
| 24 | - public static long getStepStartTime(Context context) { | |
| 25 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0); | |
| 26 | - } | |
| 10 | +// /** | |
| 11 | +// * 设置计步时间 | |
| 12 | +// * | |
| 13 | +// * @param context | |
| 14 | +// */ | |
| 15 | +// public static void setStepStartTime(Context context, long currentTime) { | |
| 16 | +// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("stepStartTime", currentTime); | |
| 17 | +// } | |
| 18 | +// | |
| 19 | +// /** | |
| 20 | +// * 获取计步时间 | |
| 21 | +// * | |
| 22 | +// * @param context | |
| 23 | +// */ | |
| 24 | +// public static long getStepStartTime(Context context) { | |
| 25 | +// return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0); | |
| 26 | +// } | |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * 设置计步完成时间 |
| ... | ... | @@ -232,8 +232,8 @@ public class CommonInfo { |
| 232 | 232 | */ |
| 233 | 233 | public static String getUserIcon(Context context) { |
| 234 | 234 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("RunUserNickIcon", ""); |
| 235 | - } | |
| 236 | 235 | |
| 236 | + } | |
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * 设置用户号码 |
| ... | ... | @@ -256,23 +256,50 @@ public class CommonInfo { |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | + | |
| 260 | + /** | |
| 261 | + * 是否第一次显示倒计时动画 | |
| 262 | + * | |
| 263 | + * @param context | |
| 264 | + * @param isAllow | |
| 265 | + */ | |
| 266 | + public static void setIsFirstShowTimeTip(Context context, boolean isAllow) { | |
| 267 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("IsFirstShowTimeTip", isAllow); | |
| 268 | + } | |
| 269 | + | |
| 270 | + /** | |
| 271 | + * 是否第一次显示倒计时动画 | |
| 272 | + * | |
| 273 | + * @param context | |
| 274 | + */ | |
| 275 | + public static boolean getIsFirstShowTimeTip(Context context) { | |
| 276 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("IsFirstShowTimeTip", true); | |
| 277 | + } | |
| 278 | + | |
| 279 | + | |
| 259 | 280 | /*重置 |
| 260 | 281 | * @param context |
| 261 | 282 | */ |
| 262 | 283 | public static void reset(Context context) { |
| 263 | 284 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); |
| 264 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("stepStartTime"); | |
| 265 | 285 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); |
| 266 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("stepStartTime"); | |
| 267 | 286 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); |
| 268 | 287 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); |
| 269 | 288 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("streetId"); |
| 270 | 289 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); |
| 271 | 290 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FenceId"); |
| 272 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("stepEndTime"); | |
| 273 | - | |
| 274 | - | |
| 291 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 275 | 292 | } |
| 276 | 293 | |
| 277 | - | |
| 294 | + /*重置赛事 | |
| 295 | + * @param context | |
| 296 | + */ | |
| 297 | + public static void resetRace(Context context) { | |
| 298 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | |
| 299 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | |
| 300 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | |
| 301 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); | |
| 302 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); | |
| 303 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | |
| 304 | + } | |
| 278 | 305 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| ... | ... | @@ -33,6 +33,7 @@ import com.cnlive.moudle.pedometer.ui.activity.RunningFinishActivity; |
| 33 | 33 | import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity; |
| 34 | 34 | import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 35 | 35 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 36 | +import com.cnlive.moudle.pedometer.ui.widget.TipDialog; | |
| 36 | 37 | import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; |
| 37 | 38 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 38 | 39 | import com.cnlive.moudle.pedometer.utils.MySpHelper; |
| ... | ... | @@ -115,11 +116,7 @@ public class RunMainFragmentView implements MvpView { |
| 115 | 116 | * 初始化相关视图 |
| 116 | 117 | */ |
| 117 | 118 | public void initView() { |
| 118 | - | |
| 119 | - UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 120 | - if (userStepEntity != null) { | |
| 121 | - StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); | |
| 122 | - } | |
| 119 | + uid = CommonInfo.getUserId(getContext()); | |
| 123 | 120 | initLocationClient(); |
| 124 | 121 | fragment.binding.llRunMainRoot.setVisibility(View.GONE); |
| 125 | 122 | ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false); |
| ... | ... | @@ -179,41 +176,41 @@ public class RunMainFragmentView implements MvpView { |
| 179 | 176 | |
| 180 | 177 | } |
| 181 | 178 | }); |
| 182 | - | |
| 183 | -// boolean isRunStep = CommonInfo.getIsRunStepService(getContext()); | |
| 179 | + boolean isFirstShowTime = CommonInfo.getIsFirstShowTimeTip(getContext()); | |
| 184 | 180 | //当前用户已经在运动 |
| 185 | -// if (!isRunStep) { | |
| 186 | - //依次倒计时 | |
| 187 | - handler.postDelayed(runnable, 1000); | |
| 188 | -// } else { | |
| 189 | -// //隐藏计时界面 | |
| 190 | -// fragment.binding.llStartTimeTip.setVisibility(View.GONE); | |
| 191 | -// fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE); | |
| 192 | -// new Handler().postDelayed(new Runnable() { | |
| 193 | -// @Override | |
| 194 | -// public void run() { | |
| 195 | -// //开始计时 | |
| 196 | -// if (firstTimeFlag) { | |
| 197 | -// firstTimeFlag = false; | |
| 198 | -// if (userStepEntity != null) { | |
| 199 | -// if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) { | |
| 200 | -// fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime())); | |
| 201 | -// } else { | |
| 202 | -// fragment.binding.chronometer.setFormat("00:00:01"); | |
| 203 | -// fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | |
| 204 | -// } | |
| 205 | -// //设置步数 | |
| 206 | -// if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { | |
| 207 | -// fragment.binding.tvStepCount.setText(userStepEntity.getStepCount()); | |
| 208 | -// } | |
| 209 | -// } | |
| 210 | -// fragment.binding.chronometer.start(); | |
| 211 | -// } | |
| 212 | -// } | |
| 213 | -// }, 10); | |
| 214 | -// //开启计步服务 | |
| 215 | -// startStepService(getContext(), uid); | |
| 216 | -// } | |
| 181 | + if (isFirstShowTime) { | |
| 182 | + //依次倒计时 | |
| 183 | + handler.postDelayed(runnable, 1000); | |
| 184 | + CommonInfo.setIsFirstShowTimeTip(getContext(), false); | |
| 185 | + } else { | |
| 186 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 187 | + //隐藏计时界面 | |
| 188 | + fragment.binding.llStartTimeTip.setVisibility(View.GONE); | |
| 189 | + fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE); | |
| 190 | + new Handler().postDelayed(new Runnable() { | |
| 191 | + @Override | |
| 192 | + public void run() { | |
| 193 | + //开始计时 | |
| 194 | + if (firstTimeFlag) { | |
| 195 | + firstTimeFlag = false; | |
| 196 | + if (userStepEntity != null) { | |
| 197 | + if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) { | |
| 198 | + fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime())); | |
| 199 | + } else { | |
| 200 | + fragment.binding.chronometer.setFormat("00:00:01"); | |
| 201 | + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | |
| 202 | + } | |
| 203 | + //设置步数 | |
| 204 | + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { | |
| 205 | + fragment.binding.tvStepCount.setText(userStepEntity.getStepCount()); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + fragment.binding.chronometer.start(); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + }, 10); | |
| 212 | + | |
| 213 | + } | |
| 217 | 214 | |
| 218 | 215 | //设置继续按钮,缩放效果 |
| 219 | 216 | fragment.binding.flContinue.setOnTouchListener(new View.OnTouchListener() { |
| ... | ... | @@ -246,20 +243,19 @@ public class RunMainFragmentView implements MvpView { |
| 246 | 243 | StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener); |
| 247 | 244 | } |
| 248 | 245 | needWriteDataFlag = true; |
| 246 | + //todo 第二阶段使用 | |
| 249 | 247 | //将当前计时器时间戳写入数据库 |
| 250 | - setSQLPauseTime(uid); | |
| 248 | + // setSQLPauseTime(uid); | |
| 251 | 249 | //为了点击时可以显示缩放动画,这里延迟一个动画时间进行(包括放大和缩小) |
| 252 | 250 | handler.postDelayed(new Runnable() { |
| 253 | 251 | @Override |
| 254 | 252 | public void run() { |
| 255 | - // | |
| 256 | 253 | //隐藏两个按钮 |
| 257 | 254 | fragment.binding.flStopTip.setVisibility(View.INVISIBLE); |
| 258 | 255 | fragment.binding.llTwoBottomButton.setVisibility(View.GONE); |
| 259 | 256 | ButtonAnimUtil.setViewShowZoomIn(fragment.binding.llPause); |
| 260 | 257 | //显示暂停按钮 |
| 261 | 258 | fragment.binding.llPause.setVisibility(View.VISIBLE); |
| 262 | - // | |
| 263 | 259 | } |
| 264 | 260 | }, ButtonAnimUtil.DEFAULT_ZOOM_DURATION * 2); |
| 265 | 261 | //继续计步 |
| ... | ... | @@ -269,8 +265,6 @@ public class RunMainFragmentView implements MvpView { |
| 269 | 265 | fragment.binding.chronometer.setBase(fragment.binding.chronometer.getBase() + (SystemClock.elapsedRealtime() - mRecordTime)); |
| 270 | 266 | } |
| 271 | 267 | fragment.binding.chronometer.start(); |
| 272 | - | |
| 273 | - | |
| 274 | 268 | } |
| 275 | 269 | }); |
| 276 | 270 | //设置停止按钮缩放特效 |
| ... | ... | @@ -308,17 +302,14 @@ public class RunMainFragmentView implements MvpView { |
| 308 | 302 | SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() { |
| 309 | 303 | @Override |
| 310 | 304 | public void onClick(SelectDialog dialog) { |
| 311 | - CommonInfo.setIsRunKeepAliveService(getContext(), false); | |
| 312 | - CommonInfo.setIsWriteUserStep(getContext(), false); | |
| 313 | - //设置运动结束时间 | |
| 305 | + //设置状态标志位 | |
| 306 | + setStopStartFlag(); | |
| 307 | + //设置运动结束时间戳 | |
| 308 | + StepUtil.setUserFinishTimeStamp(getContext(), uid); | |
| 314 | 309 | CommonInfo.setStepEndTime(getContext(), TimeUtil.getNowTimeStamp()); |
| 315 | 310 | fragment.binding.cpCurrent.setVisibility(View.GONE); |
| 316 | 311 | ButtonAnimUtil.setViewDefault(fragment.binding.flStop); |
| 317 | 312 | dialog.dismiss(); |
| 318 | - if (StepService.mClient != null) { | |
| 319 | - StepService.mClient.stopGather(StepService.traceListener); | |
| 320 | - } | |
| 321 | - fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); | |
| 322 | 313 | RunningFinishBean runningFinishBean = new RunningFinishBean(); |
| 323 | 314 | runningFinishBean.setStartPoint("开始地点"); |
| 324 | 315 | runningFinishBean.setEndPoint("结束地点"); |
| ... | ... | @@ -396,17 +387,43 @@ public class RunMainFragmentView implements MvpView { |
| 396 | 387 | fragment.binding.llPause.setVisibility(View.GONE); |
| 397 | 388 | } |
| 398 | 389 | }, ButtonAnimUtil.HIDE_VIEW_ZOOM_DURATION); |
| 399 | - //显示继续按钮 | |
| 400 | - fragment.binding.llTwoBottomButton.setVisibility(View.VISIBLE); | |
| 401 | - ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flContinue); | |
| 402 | - ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flStop); | |
| 403 | - //停止计时 | |
| 404 | - fragment.binding.chronometer.stop(); | |
| 405 | - mRecordTime = SystemClock.elapsedRealtime(); | |
| 406 | - //暂停计步 | |
| 407 | - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, "")); | |
| 408 | - //重置速度 | |
| 409 | -// resetSpeed(); | |
| 390 | + | |
| 391 | + //获取当前用户暂停次数 | |
| 392 | + int userPauseCount = StepUtil.getUserPauseCount(getContext(), uid); | |
| 393 | + if (userPauseCount != -1) { | |
| 394 | + if (userPauseCount > 1) { | |
| 395 | + //设置停止标志位,关闭相关服务 | |
| 396 | + setStopStartFlag(); | |
| 397 | + //清除数据库 | |
| 398 | + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); | |
| 399 | + //进行提示 | |
| 400 | + TipDialog tipDialog = new TipDialog(getContext(), getContext().getString(R.string.more_than_pause_count_tip), "我知道了", R.color.green_round, new TipDialog.DialogInterface() { | |
| 401 | + @Override | |
| 402 | + public void onClick(TipDialog dialog) { | |
| 403 | + //关闭当前对话框 | |
| 404 | + dialog.dismiss(); | |
| 405 | + //关闭当前页面 | |
| 406 | + if (getContext() == null) { | |
| 407 | + return; | |
| 408 | + } | |
| 409 | + fragment.getActivity().finish(); | |
| 410 | + } | |
| 411 | + }); | |
| 412 | + tipDialog.setCanceledOnTouchOutside(false); | |
| 413 | + tipDialog.setCancelable(false); | |
| 414 | + tipDialog.show(); | |
| 415 | + | |
| 416 | + } | |
| 417 | + //显示继续按钮 | |
| 418 | + fragment.binding.llTwoBottomButton.setVisibility(View.VISIBLE); | |
| 419 | + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flContinue); | |
| 420 | + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flStop); | |
| 421 | + //停止计时 | |
| 422 | + fragment.binding.chronometer.stop(); | |
| 423 | + mRecordTime = SystemClock.elapsedRealtime(); | |
| 424 | + //暂停计步 | |
| 425 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, "")); | |
| 426 | + } | |
| 410 | 427 | } |
| 411 | 428 | }); |
| 412 | 429 | //gps点击事件 |
| ... | ... | @@ -431,6 +448,16 @@ public class RunMainFragmentView implements MvpView { |
| 431 | 448 | RunningMapActivity.startActivity(fragment.getActivity(), runningMapBean); |
| 432 | 449 | } |
| 433 | 450 | }); |
| 451 | + //返回按钮点击事件 | |
| 452 | + fragment.binding.ivBack.setOnClickListener(new View.OnClickListener() { | |
| 453 | + @Override | |
| 454 | + public void onClick(View view) { | |
| 455 | + if (getContext() == null) { | |
| 456 | + return; | |
| 457 | + } | |
| 458 | + fragment.getActivity().finish(); | |
| 459 | + } | |
| 460 | + }); | |
| 434 | 461 | |
| 435 | 462 | fragment.binding.rlClose.setOnClickListener(new View.OnClickListener() { |
| 436 | 463 | @Override |
| ... | ... | @@ -450,6 +477,8 @@ public class RunMainFragmentView implements MvpView { |
| 450 | 477 | userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); |
| 451 | 478 | //设置当前暂停的时间戳 |
| 452 | 479 | userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); |
| 480 | + //设置暂停次数 | |
| 481 | + userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1); | |
| 453 | 482 | //更新数据 |
| 454 | 483 | StepUtil.updateStepData(fragment.getActivity(), userStepEntity); |
| 455 | 484 | } |
| ... | ... | @@ -457,6 +486,20 @@ public class RunMainFragmentView implements MvpView { |
| 457 | 486 | } |
| 458 | 487 | } |
| 459 | 488 | |
| 489 | + public void setFragmentPauseTime(String id) { | |
| 490 | + if (!TextUtils.isEmpty(id)) { | |
| 491 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); | |
| 492 | + if (userStepEntity != null) { | |
| 493 | + userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); | |
| 494 | + userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); | |
| 495 | + //设置当前暂停的时间戳 | |
| 496 | + userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp()); | |
| 497 | + //更新数据 | |
| 498 | + StepUtil.updateStepData(fragment.getActivity(), userStepEntity); | |
| 499 | + } | |
| 500 | + } | |
| 501 | + } | |
| 502 | + | |
| 460 | 503 | |
| 461 | 504 | /** |
| 462 | 505 | * 更新行走距离 |
| ... | ... | @@ -551,6 +594,20 @@ public class RunMainFragmentView implements MvpView { |
| 551 | 594 | } |
| 552 | 595 | } |
| 553 | 596 | } |
| 597 | + | |
| 598 | + } | |
| 599 | + | |
| 600 | + /** | |
| 601 | + * 设置停止状态标志位 | |
| 602 | + */ | |
| 603 | + private void setStopStartFlag() { | |
| 604 | + CommonInfo.setTsRunBaiduTraceService(getContext(), false); | |
| 605 | + CommonInfo.setIsRunKeepAliveService(getContext(), false); | |
| 606 | + CommonInfo.setIsWriteUserStep(getContext(), false); | |
| 607 | + if (StepService.mClient != null) { | |
| 608 | + StepService.mClient.stopGather(StepService.traceListener); | |
| 609 | + } | |
| 610 | + fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); | |
| 554 | 611 | } |
| 555 | 612 | |
| 556 | 613 | public void onDestroy() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -51,17 +51,22 @@ import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; |
| 51 | 51 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 52 | 52 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 53 | 53 | import com.cnlive.moudle.pedometer.service.KeepLiveService; |
| 54 | +import com.cnlive.moudle.pedometer.service.StepService; | |
| 55 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 54 | 56 | import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; |
| 55 | 57 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; |
| 56 | 58 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; |
| 57 | 59 | import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity; |
| 58 | 60 | import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; |
| 61 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 59 | 62 | import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 60 | 63 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 61 | 64 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 62 | 65 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 63 | 66 | import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; |
| 64 | 67 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; |
| 68 | +import com.cnlive.moudle.pedometer.utils.ServiceUtils; | |
| 69 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 65 | 70 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 66 | 71 | import com.cnlive.strike.application.GlideApp; |
| 67 | 72 | import com.example.moudle_pedometer.R; |
| ... | ... | @@ -112,6 +117,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 112 | 117 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 |
| 113 | 118 | private List<LatLng> trackPoints; |
| 114 | 119 | private RunRaceDetailInfo runRaceDetailInfo; |
| 120 | + private UserStepEntity userStepEntity; | |
| 121 | + private boolean isDifferentStreet = false; | |
| 115 | 122 | |
| 116 | 123 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { |
| 117 | 124 | this.fragment = fragment; |
| ... | ... | @@ -314,6 +321,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 314 | 321 | fragment.binding.rlScrollViewStartBtn.setTag("1"); |
| 315 | 322 | fragment.binding.tvRunNow.setText("现在开始"); |
| 316 | 323 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); |
| 324 | + checkStartBtnState(); | |
| 317 | 325 | } else { |
| 318 | 326 | fragment.binding.rlScrollViewStartBtn.setTag("0"); |
| 319 | 327 | fragment.binding.tvRunNow.setText("立即报名"); |
| ... | ... | @@ -374,9 +382,46 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 374 | 382 | //立即报名 |
| 375 | 383 | if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { |
| 376 | 384 | RegistrationInfoActivity.newInstance(fragment.getActivity()); |
| 377 | - } else { | |
| 385 | + } | |
| 386 | + //现在开始 | |
| 387 | + else if ("1".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | |
| 378 | 388 | startStepService(getContext()); |
| 379 | 389 | } |
| 390 | + //继续运动 | |
| 391 | + else if ("2".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | |
| 392 | + if (!isDifferentStreet) { | |
| 393 | + checkBaiduServiceState(); | |
| 394 | + } | |
| 395 | + | |
| 396 | + //赛事id不同 | |
| 397 | + else { | |
| 398 | + SelectDialog selectDialog = new SelectDialog(getContext(), "您正在进行另一赛事,是否回到当前进行赛事?", "否", new SelectDialog.DialogInterface() { | |
| 399 | + @Override | |
| 400 | + public void onClick(SelectDialog dialog) { | |
| 401 | + dialog.dismiss(); | |
| 402 | + //清空上次保存数据 | |
| 403 | + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); | |
| 404 | + //停止服务 | |
| 405 | + stopStepService(); | |
| 406 | + //清除数据 | |
| 407 | + CommonInfo.resetRace(getContext()); | |
| 408 | + //更改当前按钮 | |
| 409 | + fragment.binding.tvRunNow.setText("立即开始"); | |
| 410 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 411 | + | |
| 412 | + } | |
| 413 | + }, "是", new SelectDialog.DialogInterface() { | |
| 414 | + @Override | |
| 415 | + public void onClick(SelectDialog dialog) { | |
| 416 | + dialog.dismiss(); | |
| 417 | + checkBaiduServiceState(); | |
| 418 | + } | |
| 419 | + }); | |
| 420 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 421 | + selectDialog.setCancelable(false); | |
| 422 | + selectDialog.show(); | |
| 423 | + } | |
| 424 | + } | |
| 380 | 425 | } |
| 381 | 426 | }); |
| 382 | 427 | //查看全部成绩点击事件 |
| ... | ... | @@ -409,6 +454,32 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 409 | 454 | }); |
| 410 | 455 | } |
| 411 | 456 | |
| 457 | + private void checkBaiduServiceState() { | |
| 458 | + boolean isRunBaidu = CommonInfo.getIsRunBaiduTraceService(getContext()); | |
| 459 | + if (isRunBaidu) { | |
| 460 | + //判断百度服务是否运行 | |
| 461 | + if (!ServiceUtils.isServiceRunning(getContext(), "com.baidu.trace.LBSTraceService")) { | |
| 462 | + stopStepService(); | |
| 463 | + startStepService(getContext()); | |
| 464 | + } else { | |
| 465 | + PedometerMainActivity.startActivity(fragment.getActivity()); | |
| 466 | + } | |
| 467 | + } else { | |
| 468 | + PedometerMainActivity.startActivity(fragment.getActivity()); | |
| 469 | + } | |
| 470 | + } | |
| 471 | + | |
| 472 | + private void stopStepService() { | |
| 473 | + CommonInfo.setTsRunBaiduTraceService(getContext(), false); | |
| 474 | + CommonInfo.setIsRunKeepAliveService(getContext(), false); | |
| 475 | + CommonInfo.setIsWriteUserStep(getContext(), false); | |
| 476 | + CommonInfo.setIsFirstStepSendTraceTip(getContext(), true); | |
| 477 | + if (StepService.mClient != null) { | |
| 478 | + StepService.mClient.stopGather(StepService.traceListener); | |
| 479 | + } | |
| 480 | + fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); | |
| 481 | + } | |
| 482 | + | |
| 412 | 483 | public void initMap() { |
| 413 | 484 | //隐藏底部滑动卡片 |
| 414 | 485 | fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); |
| ... | ... | @@ -721,9 +792,50 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 721 | 792 | } |
| 722 | 793 | |
| 723 | 794 | public void onResume() { |
| 795 | + if (getContext() == null) { | |
| 796 | + return; | |
| 797 | + } | |
| 724 | 798 | if (mMapView != null) { |
| 725 | 799 | mMapView.onResume(); |
| 726 | 800 | } |
| 801 | + | |
| 802 | + } | |
| 803 | + | |
| 804 | + public void checkStartBtnState() { | |
| 805 | + //判断是否有进行中的赛事 | |
| 806 | + userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext())); | |
| 807 | + Log.e(TAG, "checkStartBtnState: " + userStepEntity); | |
| 808 | + if (userStepEntity != null) { | |
| 809 | + //判断赛事id是否一致 | |
| 810 | + String currentStreetId = CommonInfo.getStreetId(getContext()); | |
| 811 | + //数据库保存的id | |
| 812 | + String dbStreetId = userStepEntity.getStreetId(); | |
| 813 | + //获取当前时间戳 | |
| 814 | + long currnetTime = TimeUtil.getNowTimeStamp(); | |
| 815 | + //获取用户暂停的时间戳 | |
| 816 | + long userPauseTime = userStepEntity.getUserPauseTimeStamp(); | |
| 817 | + //判断时间是否小于9小时 | |
| 818 | + if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { | |
| 819 | + fragment.binding.tvRunNow.setText("继续运动"); | |
| 820 | + fragment.binding.rlScrollViewStartBtn.setTag("2"); | |
| 821 | + } else { | |
| 822 | + fragment.binding.tvRunNow.setText("立即开始"); | |
| 823 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 824 | + } | |
| 825 | + | |
| 826 | + if (currentStreetId.equals(dbStreetId)) { | |
| 827 | + isDifferentStreet = false; | |
| 828 | + } | |
| 829 | + //当前id与赛事id不一样 | |
| 830 | + else { | |
| 831 | + isDifferentStreet = true; | |
| 832 | + } | |
| 833 | + | |
| 834 | + } else { | |
| 835 | + fragment.binding.tvRunNow.setText("立即开始"); | |
| 836 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 837 | + } | |
| 838 | + | |
| 727 | 839 | } |
| 728 | 840 | |
| 729 | 841 | public void onPause() { |
| ... | ... | @@ -866,9 +978,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 866 | 978 | public void startStepService(Context context) { |
| 867 | 979 | CommonInfo.setIsFirstStepSendTraceTip(getContext(), true); |
| 868 | 980 | QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false); |
| 869 | - if (CommonInfo.getStepStartTime(context) == 0) { | |
| 870 | - CommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 871 | - } | |
| 872 | 981 | CommonInfo.setIsRunKeepAliveService(context, true); |
| 873 | 982 | CommonInfo.setIsRunStepService(context, true); |
| 874 | 983 | CommonInfo.setTsRunBaiduTraceService(context, true); |
| ... | ... | @@ -887,4 +996,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 887 | 996 | fragment.binding.tvRunNow.setText("现在开始"); |
| 888 | 997 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); |
| 889 | 998 | } |
| 999 | + | |
| 1000 | + | |
| 890 | 1001 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningFinishFragmentView.java
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.content.Context; |
| 4 | +import android.text.TextUtils; | |
| 5 | +import android.util.Log; | |
| 4 | 6 | import android.view.View; |
| 5 | 7 | |
| 8 | +import com.bumptech.glide.Glide; | |
| 9 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 6 | 10 | import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 7 | 11 | import com.cnlive.moudle.pedometer.ui.fragment.RunningFinishFragment; |
| 8 | 12 | import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 9 | 13 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 10 | 14 | |
| 15 | + | |
| 11 | 16 | public class RunningFinishFragmentView implements MvpView { |
| 17 | + private final String TAG = "RunningFinishView"; | |
| 12 | 18 | private RunningFinishFragment fragment; |
| 13 | 19 | |
| 14 | 20 | public RunningFinishFragmentView(RunningFinishFragment fragment) { |
| ... | ... | @@ -20,16 +26,34 @@ public class RunningFinishFragmentView implements MvpView { |
| 20 | 26 | } |
| 21 | 27 | |
| 22 | 28 | public void initView(RunningFinishBean runningFinishBean) { |
| 29 | + //设置用户头像 | |
| 30 | + String faceUrl = CommonInfo.getUserIcon(getContext()); | |
| 31 | + if (!TextUtils.isEmpty(faceUrl)) { | |
| 32 | + Glide.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon); | |
| 33 | + } | |
| 34 | + //设置用户昵称 | |
| 35 | + String nickName = CommonInfo.getUserNickName(getContext()); | |
| 36 | + if (!TextUtils.isEmpty(nickName)) { | |
| 37 | + fragment.binding.includeFinishUserInfo.tvUserNickName.setText(nickName); | |
| 38 | + } | |
| 23 | 39 | //设置距离 |
| 24 | 40 | fragment.binding.includeFinishUserInfo.tvDistance.setText(runningFinishBean.getRunDistance()); |
| 25 | 41 | //设置配速 |
| 26 | - fragment.binding.includeFinishUserInfo.tvSpeed.setText(runningFinishBean.getSpeed()); | |
| 42 | + if ("--".equals(runningFinishBean.getSpeed())) { | |
| 43 | + fragment.binding.includeFinishUserInfo.tvSpeed.setText("0"); | |
| 44 | + } else { | |
| 45 | + fragment.binding.includeFinishUserInfo.tvSpeed.setText(runningFinishBean.getSpeed()); | |
| 46 | + } | |
| 27 | 47 | //设置用时 |
| 28 | 48 | fragment.binding.includeFinishUserInfo.tvTimer.setText(runningFinishBean.getTime()); |
| 29 | 49 | //设置日期 |
| 30 | 50 | fragment.binding.includeFinishUserInfo.tvDate.setText(runningFinishBean.getDate()); |
| 31 | 51 | //设置步数 |
| 32 | - fragment.binding.includeFinishStep.tvStep.setText(runningFinishBean.getStep()); | |
| 52 | + if ("--".equals(runningFinishBean.getStep())) { | |
| 53 | + fragment.binding.includeFinishStep.tvStep.setText("0"); | |
| 54 | + } else { | |
| 55 | + fragment.binding.includeFinishStep.tvStep.setText(runningFinishBean.getStep()); | |
| 56 | + } | |
| 33 | 57 | //设置起点位置 |
| 34 | 58 | fragment.binding.includeFinishRunRoute.tvStartPoint.setText(runningFinishBean.getStartPoint()); |
| 35 | 59 | //设置终点位置 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
| ... | ... | @@ -48,7 +48,7 @@ import java.util.HashMap; |
| 48 | 48 | import java.util.List; |
| 49 | 49 | |
| 50 | 50 | public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 51 | - private static final String TAG = "CollRunningMapFragmentView"; | |
| 51 | + private static final String TAG = "RunningMapFragmentView"; | |
| 52 | 52 | private RunningMapFragment fragment; |
| 53 | 53 | public BaiduMap baiduMap; |
| 54 | 54 | private MapView mMapView; |
| ... | ... | @@ -180,7 +180,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 180 | 180 | fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() { |
| 181 | 181 | @Override |
| 182 | 182 | public boolean onTouch(View view, MotionEvent motionEvent) { |
| 183 | - Log.e(TAG, "onTouch: " + motionEvent.getAction()); | |
| 184 | 183 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
| 185 | 184 | ButtonAnimUtil.setViewZoomIn(fragment.binding.flBack); |
| 186 | 185 | } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java
| ... | ... | @@ -44,7 +44,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 44 | 44 | public static boolean isKeepService = true; |
| 45 | 45 | public static KeepLiveService instance; |
| 46 | 46 | private int startId; |
| 47 | - private final String TAG = "CollKeepLiveService"; | |
| 47 | + private final String TAG = "KeepLiveService"; | |
| 48 | 48 | private Handler handler; |
| 49 | 49 | private Runnable runnable; |
| 50 | 50 | |
| ... | ... | @@ -108,7 +108,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 108 | 108 | // intentFilter.addAction(Intent.ACTION_TIME_CHANGED); |
| 109 | 109 | // intentFilter.addAction(Intent.ACTION_POWER_CONNECTED); |
| 110 | 110 | // intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); |
| 111 | - intentFilter.addAction("com.cnlive.strike.receiver.CollServiceReceiver"); | |
| 111 | + intentFilter.addAction("com.cnlive.strike.receiver.ServiceReceiver"); | |
| 112 | 112 | intentFilter.addAction("close.KeepService"); |
| 113 | 113 | registerReceiver(myReceiver, intentFilter); |
| 114 | 114 | } |
| ... | ... | @@ -136,7 +136,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 136 | 136 | //判断是否运行计步服务 |
| 137 | 137 | boolean isRunStepService = CommonInfo.getIsRunStepService(getApplicationContext()); |
| 138 | 138 | if (isRunStepService) { |
| 139 | - if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.CollStepService")) { | |
| 139 | + if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.StepService")) { | |
| 140 | 140 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 141 | 141 | startForegroundService(new Intent(getApplicationContext(), StepService.class)); |
| 142 | 142 | } else { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
| ... | ... | @@ -37,18 +37,16 @@ import com.baidu.trace.model.LocationMode; |
| 37 | 37 | import com.baidu.trace.model.OnTraceListener; |
| 38 | 38 | import com.baidu.trace.model.PushMessage; |
| 39 | 39 | import com.baidu.trace.model.StatusCodes; |
| 40 | -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 41 | 40 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 42 | 41 | import com.cnlive.moudle.pedometer.model.Constant; |
| 43 | 42 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| 44 | 43 | import com.cnlive.moudle.pedometer.model.step.StepCount; |
| 45 | 44 | import com.cnlive.moudle.pedometer.model.step.StepValuePassListener; |
| 46 | -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 47 | 45 | import com.cnlive.moudle.pedometer.sql.db.DbCore; |
| 48 | 46 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 49 | 47 | import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; |
| 50 | -import com.cnlive.moudle.pedometer.utils.MySpHelper; | |
| 51 | 48 | import com.cnlive.moudle.pedometer.utils.ServiceUtils; |
| 49 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 52 | 50 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 53 | 51 | import com.example.moudle_pedometer.R; |
| 54 | 52 | |
| ... | ... | @@ -58,15 +56,11 @@ import org.greenrobot.eventbus.ThreadMode; |
| 58 | 56 | |
| 59 | 57 | import java.text.SimpleDateFormat; |
| 60 | 58 | import java.util.Date; |
| 61 | -import java.util.List; | |
| 62 | -import java.util.UUID; | |
| 63 | 59 | |
| 64 | 60 | |
| 65 | 61 | public class StepService extends Service implements SensorEventListener { |
| 66 | 62 | |
| 67 | - private String TAG = "CollStepService"; | |
| 68 | - public static boolean isKeep = true; | |
| 69 | - | |
| 63 | + private String TAG = "StepService"; | |
| 70 | 64 | /** |
| 71 | 65 | * 通知栏相关 |
| 72 | 66 | */ |
| ... | ... | @@ -353,9 +347,10 @@ public class StepService extends Service implements SensorEventListener { |
| 353 | 347 | //开启轨迹服务 |
| 354 | 348 | if (mClient != null) { |
| 355 | 349 | mClient.startTrace(mTrace, traceListener); |
| 356 | - long stepStartTime = CommonInfo.getStepStartTime(getApplicationContext()); | |
| 357 | - if (stepStartTime == 0) { | |
| 358 | - CommonInfo.setStepStartTime(getApplicationContext(), TimeUtil.getCurrentTime()); | |
| 350 | + //设置用户开始时间以及赛事ID | |
| 351 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | |
| 352 | + if (userStepEntity == null) { | |
| 353 | + StepUtil.setStepStartData(getApplicationContext(), userId, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getApplicationContext())); | |
| 359 | 354 | } |
| 360 | 355 | } |
| 361 | 356 | |
| ... | ... | @@ -548,17 +543,13 @@ public class StepService extends Service implements SensorEventListener { |
| 548 | 543 | return; |
| 549 | 544 | } |
| 550 | 545 | //获取当天的数据,用于展示 CURRENT_DATE |
| 551 | - List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(userId), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list(); | |
| 552 | - if (list == null) { | |
| 553 | - return; | |
| 554 | - } | |
| 555 | - if (list.size() == 0 || list.isEmpty()) { | |
| 546 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | |
| 547 | + if (userStepEntity == null) { | |
| 556 | 548 | CURRENT_STEP = 0; |
| 557 | - } else if (list.size() == 1) { | |
| 558 | - Log.e(TAG, "StepData=" + list.get(0).toString()); | |
| 559 | - CURRENT_STEP = Integer.parseInt(list.get(0).getStepCount()); | |
| 560 | 549 | } else { |
| 561 | - Log.e(TAG, "出错了!"); | |
| 550 | + if (userStepEntity.getStepCount() != null) { | |
| 551 | + CURRENT_STEP = Integer.parseInt(userStepEntity.getStepCount()); | |
| 552 | + } | |
| 562 | 553 | } |
| 563 | 554 | if (mStepCount != null) { |
| 564 | 555 | mStepCount.setSteps(CURRENT_STEP); |
| ... | ... | @@ -915,19 +906,16 @@ public class StepService extends Service implements SensorEventListener { |
| 915 | 906 | return; |
| 916 | 907 | } |
| 917 | 908 | int tempStep = CURRENT_STEP; |
| 918 | - List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(userId), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list(); | |
| 919 | - if (list.size() == 0 || list.isEmpty()) { | |
| 909 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); | |
| 910 | + if (userStepEntity == null) { | |
| 920 | 911 | UserStepEntity data = new UserStepEntity(); |
| 921 | - data.setUuid(UUID.randomUUID().toString()); | |
| 922 | 912 | data.setUserId(userId); |
| 923 | 913 | data.setDate(CURRENT_DATE); |
| 924 | 914 | data.setStepCount(tempStep + ""); |
| 925 | - DbCore.getDaoSession().getUserStepEntityDao().insert(data); | |
| 926 | - } else if (list.size() == 1) { | |
| 927 | - UserStepEntity data = list.get(0); | |
| 928 | - data.setStepCount(tempStep + ""); | |
| 929 | - DbCore.getDaoSession().getUserStepEntityDao().update(data); | |
| 915 | + StepUtil.insertStepData(getApplicationContext(), data); | |
| 930 | 916 | } else { |
| 917 | + userStepEntity.setStepCount(tempStep + ""); | |
| 918 | + StepUtil.updateStepData(getApplicationContext(), userStepEntity); | |
| 931 | 919 | } |
| 932 | 920 | } |
| 933 | 921 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
| ... | ... | @@ -21,14 +21,14 @@ public class DaoMaster extends AbstractDaoMaster { |
| 21 | 21 | |
| 22 | 22 | /** Creates underlying database table using DAOs. */ |
| 23 | 23 | public static void createAllTables(Database db, boolean ifNotExists) { |
| 24 | - UserStepEntityDao.createTable(db, ifNotExists); | |
| 25 | 24 | CollUserStepEntityDao.createTable(db, ifNotExists); |
| 25 | + UserStepEntityDao.createTable(db, ifNotExists); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** Drops underlying database table using DAOs. */ |
| 29 | 29 | public static void dropAllTables(Database db, boolean ifExists) { |
| 30 | - UserStepEntityDao.dropTable(db, ifExists); | |
| 31 | 30 | CollUserStepEntityDao.dropTable(db, ifExists); |
| 31 | + UserStepEntityDao.dropTable(db, ifExists); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| ... | ... | @@ -47,8 +47,8 @@ public class DaoMaster extends AbstractDaoMaster { |
| 47 | 47 | |
| 48 | 48 | public DaoMaster(Database db) { |
| 49 | 49 | super(db, SCHEMA_VERSION); |
| 50 | - registerDaoClass(UserStepEntityDao.class); | |
| 51 | 50 | registerDaoClass(CollUserStepEntityDao.class); |
| 51 | + registerDaoClass(UserStepEntityDao.class); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public DaoSession newSession() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
| ... | ... | @@ -8,11 +8,11 @@ import org.greenrobot.greendao.database.Database; |
| 8 | 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; |
| 9 | 9 | import org.greenrobot.greendao.internal.DaoConfig; |
| 10 | 10 | |
| 11 | -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 12 | 11 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 12 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 13 | 13 | |
| 14 | -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 15 | 14 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 15 | +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 16 | 16 | |
| 17 | 17 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 18 | 18 | |
| ... | ... | @@ -23,40 +23,40 @@ import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 23 | 23 | */ |
| 24 | 24 | public class DaoSession extends AbstractDaoSession { |
| 25 | 25 | |
| 26 | - private final DaoConfig userStepEntityDaoConfig; | |
| 27 | 26 | private final DaoConfig collUserStepEntityDaoConfig; |
| 27 | + private final DaoConfig userStepEntityDaoConfig; | |
| 28 | 28 | |
| 29 | - private final UserStepEntityDao userStepEntityDao; | |
| 30 | 29 | private final CollUserStepEntityDao collUserStepEntityDao; |
| 30 | + private final UserStepEntityDao userStepEntityDao; | |
| 31 | 31 | |
| 32 | 32 | public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> |
| 33 | 33 | daoConfigMap) { |
| 34 | 34 | super(db); |
| 35 | 35 | |
| 36 | - userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 37 | - userStepEntityDaoConfig.initIdentityScope(type); | |
| 38 | - | |
| 39 | 36 | collUserStepEntityDaoConfig = daoConfigMap.get(CollUserStepEntityDao.class).clone(); |
| 40 | 37 | collUserStepEntityDaoConfig.initIdentityScope(type); |
| 41 | 38 | |
| 42 | - userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 39 | + userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 40 | + userStepEntityDaoConfig.initIdentityScope(type); | |
| 41 | + | |
| 43 | 42 | collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this); |
| 43 | + userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 44 | 44 | |
| 45 | - registerDao(UserStepEntity.class, userStepEntityDao); | |
| 46 | 45 | registerDao(CollUserStepEntity.class, collUserStepEntityDao); |
| 46 | + registerDao(UserStepEntity.class, userStepEntityDao); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public void clear() { |
| 50 | - userStepEntityDaoConfig.clearIdentityScope(); | |
| 51 | 50 | collUserStepEntityDaoConfig.clearIdentityScope(); |
| 52 | - } | |
| 53 | - | |
| 54 | - public UserStepEntityDao getUserStepEntityDao() { | |
| 55 | - return userStepEntityDao; | |
| 51 | + userStepEntityDaoConfig.clearIdentityScope(); | |
| 56 | 52 | } |
| 57 | 53 | |
| 58 | 54 | public CollUserStepEntityDao getCollUserStepEntityDao() { |
| 59 | 55 | return collUserStepEntityDao; |
| 60 | 56 | } |
| 61 | 57 | |
| 58 | + public UserStepEntityDao getUserStepEntityDao() { | |
| 59 | + return userStepEntityDao; | |
| 60 | + } | |
| 61 | + | |
| 62 | 62 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
| ... | ... | @@ -24,14 +24,20 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 24 | 24 | * Can be used for QueryBuilder and for referencing column names. |
| 25 | 25 | */ |
| 26 | 26 | public static class Properties { |
| 27 | - public final static Property Uuid = new Property(0, String.class, "uuid", true, "UUID"); | |
| 28 | - public final static Property UserId = new Property(1, String.class, "userId", false, "USER_ID"); | |
| 29 | - public final static Property Date = new Property(2, String.class, "date", false, "DATE"); | |
| 30 | - public final static Property StepCount = new Property(3, String.class, "stepCount", false, "STEP_COUNT"); | |
| 31 | - public final static Property PauseTimeStamp = new Property(4, long.class, "pauseTimeStamp", false, "PAUSE_TIME_STAMP"); | |
| 32 | - public final static Property RecordTime = new Property(5, long.class, "recordTime", false, "RECORD_TIME"); | |
| 33 | - public final static Property CaloriesCount = new Property(6, double.class, "caloriesCount", false, "CALORIES_COUNT"); | |
| 34 | - public final static Property ServerTraceData = new Property(7, String.class, "serverTraceData", false, "SERVER_TRACE_DATA"); | |
| 27 | + public final static Property UserId = new Property(0, String.class, "userId", true, "USER_ID"); | |
| 28 | + public final static Property Date = new Property(1, String.class, "date", false, "DATE"); | |
| 29 | + public final static Property StepCount = new Property(2, String.class, "stepCount", false, "STEP_COUNT"); | |
| 30 | + public final static Property PauseTimeStamp = new Property(3, long.class, "pauseTimeStamp", false, "PAUSE_TIME_STAMP"); | |
| 31 | + public final static Property RecordTime = new Property(4, long.class, "recordTime", false, "RECORD_TIME"); | |
| 32 | + public final static Property CaloriesCount = new Property(5, double.class, "caloriesCount", false, "CALORIES_COUNT"); | |
| 33 | + public final static Property ServerTraceData = new Property(6, String.class, "serverTraceData", false, "SERVER_TRACE_DATA"); | |
| 34 | + public final static Property StartPoint = new Property(7, String.class, "startPoint", false, "START_POINT"); | |
| 35 | + public final static Property EndPoint = new Property(8, String.class, "endPoint", false, "END_POINT"); | |
| 36 | + public final static Property StartTimeStamp = new Property(9, long.class, "startTimeStamp", false, "START_TIME_STAMP"); | |
| 37 | + public final static Property FinishTimeStamp = new Property(10, long.class, "finishTimeStamp", false, "FINISH_TIME_STAMP"); | |
| 38 | + public final static Property StreetId = new Property(11, String.class, "streetId", false, "STREET_ID"); | |
| 39 | + public final static Property PauseCount = new Property(12, int.class, "pauseCount", false, "PAUSE_COUNT"); | |
| 40 | + public final static Property UserPauseTimeStamp = new Property(13, long.class, "userPauseTimeStamp", false, "USER_PAUSE_TIME_STAMP"); | |
| 35 | 41 | } |
| 36 | 42 | |
| 37 | 43 | |
| ... | ... | @@ -47,14 +53,20 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 47 | 53 | public static void createTable(Database db, boolean ifNotExists) { |
| 48 | 54 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; |
| 49 | 55 | db.execSQL("CREATE TABLE " + constraint + "\"USER_STEP_ENTITY\" (" + // |
| 50 | - "\"UUID\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid | |
| 51 | - "\"USER_ID\" TEXT," + // 1: userId | |
| 52 | - "\"DATE\" TEXT," + // 2: date | |
| 53 | - "\"STEP_COUNT\" TEXT," + // 3: stepCount | |
| 54 | - "\"PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 4: pauseTimeStamp | |
| 55 | - "\"RECORD_TIME\" INTEGER NOT NULL ," + // 5: recordTime | |
| 56 | - "\"CALORIES_COUNT\" REAL NOT NULL ," + // 6: caloriesCount | |
| 57 | - "\"SERVER_TRACE_DATA\" TEXT);"); // 7: serverTraceData | |
| 56 | + "\"USER_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: userId | |
| 57 | + "\"DATE\" TEXT," + // 1: date | |
| 58 | + "\"STEP_COUNT\" TEXT," + // 2: stepCount | |
| 59 | + "\"PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 3: pauseTimeStamp | |
| 60 | + "\"RECORD_TIME\" INTEGER NOT NULL ," + // 4: recordTime | |
| 61 | + "\"CALORIES_COUNT\" REAL NOT NULL ," + // 5: caloriesCount | |
| 62 | + "\"SERVER_TRACE_DATA\" TEXT," + // 6: serverTraceData | |
| 63 | + "\"START_POINT\" TEXT," + // 7: startPoint | |
| 64 | + "\"END_POINT\" TEXT," + // 8: endPoint | |
| 65 | + "\"START_TIME_STAMP\" INTEGER NOT NULL ," + // 9: startTimeStamp | |
| 66 | + "\"FINISH_TIME_STAMP\" INTEGER NOT NULL ," + // 10: finishTimeStamp | |
| 67 | + "\"STREET_ID\" TEXT," + // 11: streetId | |
| 68 | + "\"PAUSE_COUNT\" INTEGER NOT NULL ," + // 12: pauseCount | |
| 69 | + "\"USER_PAUSE_TIME_STAMP\" INTEGER NOT NULL );"); // 13: userPauseTimeStamp | |
| 58 | 70 | } |
| 59 | 71 | |
| 60 | 72 | /** Drops the underlying database table. */ |
| ... | ... | @@ -67,66 +79,94 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 67 | 79 | protected final void bindValues(DatabaseStatement stmt, UserStepEntity entity) { |
| 68 | 80 | stmt.clearBindings(); |
| 69 | 81 | |
| 70 | - String uuid = entity.getUuid(); | |
| 71 | - if (uuid != null) { | |
| 72 | - stmt.bindString(1, uuid); | |
| 73 | - } | |
| 74 | - | |
| 75 | 82 | String userId = entity.getUserId(); |
| 76 | 83 | if (userId != null) { |
| 77 | - stmt.bindString(2, userId); | |
| 84 | + stmt.bindString(1, userId); | |
| 78 | 85 | } |
| 79 | 86 | |
| 80 | 87 | String date = entity.getDate(); |
| 81 | 88 | if (date != null) { |
| 82 | - stmt.bindString(3, date); | |
| 89 | + stmt.bindString(2, date); | |
| 83 | 90 | } |
| 84 | 91 | |
| 85 | 92 | String stepCount = entity.getStepCount(); |
| 86 | 93 | if (stepCount != null) { |
| 87 | - stmt.bindString(4, stepCount); | |
| 94 | + stmt.bindString(3, stepCount); | |
| 88 | 95 | } |
| 89 | - stmt.bindLong(5, entity.getPauseTimeStamp()); | |
| 90 | - stmt.bindLong(6, entity.getRecordTime()); | |
| 91 | - stmt.bindDouble(7, entity.getCaloriesCount()); | |
| 96 | + stmt.bindLong(4, entity.getPauseTimeStamp()); | |
| 97 | + stmt.bindLong(5, entity.getRecordTime()); | |
| 98 | + stmt.bindDouble(6, entity.getCaloriesCount()); | |
| 92 | 99 | |
| 93 | 100 | String serverTraceData = entity.getServerTraceData(); |
| 94 | 101 | if (serverTraceData != null) { |
| 95 | - stmt.bindString(8, serverTraceData); | |
| 102 | + stmt.bindString(7, serverTraceData); | |
| 103 | + } | |
| 104 | + | |
| 105 | + String startPoint = entity.getStartPoint(); | |
| 106 | + if (startPoint != null) { | |
| 107 | + stmt.bindString(8, startPoint); | |
| 108 | + } | |
| 109 | + | |
| 110 | + String endPoint = entity.getEndPoint(); | |
| 111 | + if (endPoint != null) { | |
| 112 | + stmt.bindString(9, endPoint); | |
| 113 | + } | |
| 114 | + stmt.bindLong(10, entity.getStartTimeStamp()); | |
| 115 | + stmt.bindLong(11, entity.getFinishTimeStamp()); | |
| 116 | + | |
| 117 | + String streetId = entity.getStreetId(); | |
| 118 | + if (streetId != null) { | |
| 119 | + stmt.bindString(12, streetId); | |
| 96 | 120 | } |
| 121 | + stmt.bindLong(13, entity.getPauseCount()); | |
| 122 | + stmt.bindLong(14, entity.getUserPauseTimeStamp()); | |
| 97 | 123 | } |
| 98 | 124 | |
| 99 | 125 | @Override |
| 100 | 126 | protected final void bindValues(SQLiteStatement stmt, UserStepEntity entity) { |
| 101 | 127 | stmt.clearBindings(); |
| 102 | 128 | |
| 103 | - String uuid = entity.getUuid(); | |
| 104 | - if (uuid != null) { | |
| 105 | - stmt.bindString(1, uuid); | |
| 106 | - } | |
| 107 | - | |
| 108 | 129 | String userId = entity.getUserId(); |
| 109 | 130 | if (userId != null) { |
| 110 | - stmt.bindString(2, userId); | |
| 131 | + stmt.bindString(1, userId); | |
| 111 | 132 | } |
| 112 | 133 | |
| 113 | 134 | String date = entity.getDate(); |
| 114 | 135 | if (date != null) { |
| 115 | - stmt.bindString(3, date); | |
| 136 | + stmt.bindString(2, date); | |
| 116 | 137 | } |
| 117 | 138 | |
| 118 | 139 | String stepCount = entity.getStepCount(); |
| 119 | 140 | if (stepCount != null) { |
| 120 | - stmt.bindString(4, stepCount); | |
| 141 | + stmt.bindString(3, stepCount); | |
| 121 | 142 | } |
| 122 | - stmt.bindLong(5, entity.getPauseTimeStamp()); | |
| 123 | - stmt.bindLong(6, entity.getRecordTime()); | |
| 124 | - stmt.bindDouble(7, entity.getCaloriesCount()); | |
| 143 | + stmt.bindLong(4, entity.getPauseTimeStamp()); | |
| 144 | + stmt.bindLong(5, entity.getRecordTime()); | |
| 145 | + stmt.bindDouble(6, entity.getCaloriesCount()); | |
| 125 | 146 | |
| 126 | 147 | String serverTraceData = entity.getServerTraceData(); |
| 127 | 148 | if (serverTraceData != null) { |
| 128 | - stmt.bindString(8, serverTraceData); | |
| 149 | + stmt.bindString(7, serverTraceData); | |
| 150 | + } | |
| 151 | + | |
| 152 | + String startPoint = entity.getStartPoint(); | |
| 153 | + if (startPoint != null) { | |
| 154 | + stmt.bindString(8, startPoint); | |
| 155 | + } | |
| 156 | + | |
| 157 | + String endPoint = entity.getEndPoint(); | |
| 158 | + if (endPoint != null) { | |
| 159 | + stmt.bindString(9, endPoint); | |
| 160 | + } | |
| 161 | + stmt.bindLong(10, entity.getStartTimeStamp()); | |
| 162 | + stmt.bindLong(11, entity.getFinishTimeStamp()); | |
| 163 | + | |
| 164 | + String streetId = entity.getStreetId(); | |
| 165 | + if (streetId != null) { | |
| 166 | + stmt.bindString(12, streetId); | |
| 129 | 167 | } |
| 168 | + stmt.bindLong(13, entity.getPauseCount()); | |
| 169 | + stmt.bindLong(14, entity.getUserPauseTimeStamp()); | |
| 130 | 170 | } |
| 131 | 171 | |
| 132 | 172 | @Override |
| ... | ... | @@ -137,39 +177,51 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 137 | 177 | @Override |
| 138 | 178 | public UserStepEntity readEntity(Cursor cursor, int offset) { |
| 139 | 179 | UserStepEntity entity = new UserStepEntity( // |
| 140 | - cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // uuid | |
| 141 | - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userId | |
| 142 | - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // date | |
| 143 | - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // stepCount | |
| 144 | - cursor.getLong(offset + 4), // pauseTimeStamp | |
| 145 | - cursor.getLong(offset + 5), // recordTime | |
| 146 | - cursor.getDouble(offset + 6), // caloriesCount | |
| 147 | - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // serverTraceData | |
| 180 | + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // userId | |
| 181 | + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // date | |
| 182 | + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // stepCount | |
| 183 | + cursor.getLong(offset + 3), // pauseTimeStamp | |
| 184 | + cursor.getLong(offset + 4), // recordTime | |
| 185 | + cursor.getDouble(offset + 5), // caloriesCount | |
| 186 | + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // serverTraceData | |
| 187 | + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // startPoint | |
| 188 | + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // endPoint | |
| 189 | + cursor.getLong(offset + 9), // startTimeStamp | |
| 190 | + cursor.getLong(offset + 10), // finishTimeStamp | |
| 191 | + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // streetId | |
| 192 | + cursor.getInt(offset + 12), // pauseCount | |
| 193 | + cursor.getLong(offset + 13) // userPauseTimeStamp | |
| 148 | 194 | ); |
| 149 | 195 | return entity; |
| 150 | 196 | } |
| 151 | 197 | |
| 152 | 198 | @Override |
| 153 | 199 | public void readEntity(Cursor cursor, UserStepEntity entity, int offset) { |
| 154 | - entity.setUuid(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); | |
| 155 | - entity.setUserId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); | |
| 156 | - entity.setDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); | |
| 157 | - entity.setStepCount(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); | |
| 158 | - entity.setPauseTimeStamp(cursor.getLong(offset + 4)); | |
| 159 | - entity.setRecordTime(cursor.getLong(offset + 5)); | |
| 160 | - entity.setCaloriesCount(cursor.getDouble(offset + 6)); | |
| 161 | - entity.setServerTraceData(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); | |
| 200 | + entity.setUserId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); | |
| 201 | + entity.setDate(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); | |
| 202 | + entity.setStepCount(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); | |
| 203 | + entity.setPauseTimeStamp(cursor.getLong(offset + 3)); | |
| 204 | + entity.setRecordTime(cursor.getLong(offset + 4)); | |
| 205 | + entity.setCaloriesCount(cursor.getDouble(offset + 5)); | |
| 206 | + entity.setServerTraceData(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); | |
| 207 | + entity.setStartPoint(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); | |
| 208 | + entity.setEndPoint(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); | |
| 209 | + entity.setStartTimeStamp(cursor.getLong(offset + 9)); | |
| 210 | + entity.setFinishTimeStamp(cursor.getLong(offset + 10)); | |
| 211 | + entity.setStreetId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); | |
| 212 | + entity.setPauseCount(cursor.getInt(offset + 12)); | |
| 213 | + entity.setUserPauseTimeStamp(cursor.getLong(offset + 13)); | |
| 162 | 214 | } |
| 163 | 215 | |
| 164 | 216 | @Override |
| 165 | 217 | protected final String updateKeyAfterInsert(UserStepEntity entity, long rowId) { |
| 166 | - return entity.getUuid(); | |
| 218 | + return entity.getUserId(); | |
| 167 | 219 | } |
| 168 | 220 | |
| 169 | 221 | @Override |
| 170 | 222 | public String getKey(UserStepEntity entity) { |
| 171 | 223 | if(entity != null) { |
| 172 | - return entity.getUuid(); | |
| 224 | + return entity.getUserId(); | |
| 173 | 225 | } else { |
| 174 | 226 | return null; |
| 175 | 227 | } |
| ... | ... | @@ -177,7 +229,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 177 | 229 | |
| 178 | 230 | @Override |
| 179 | 231 | public boolean hasKey(UserStepEntity entity) { |
| 180 | - return entity.getUuid() != null; | |
| 232 | + return entity.getUserId() != null; | |
| 181 | 233 | } |
| 182 | 234 | |
| 183 | 235 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
| ... | ... | @@ -7,7 +7,6 @@ import org.greenrobot.greendao.annotation.Id; |
| 7 | 7 | @Entity |
| 8 | 8 | public class UserStepEntity { |
| 9 | 9 | @Id |
| 10 | - private String uuid; | |
| 11 | 10 | private String userId; |
| 12 | 11 | private String date; |
| 13 | 12 | private String stepCount; |
| ... | ... | @@ -15,12 +14,18 @@ public class UserStepEntity { |
| 15 | 14 | private long recordTime;//暂停时间 |
| 16 | 15 | private double caloriesCount;//卡路里 |
| 17 | 16 | private String serverTraceData;//服务端赛道数据 |
| 18 | - | |
| 19 | - @Generated(hash = 1521646580) | |
| 20 | - public UserStepEntity(String uuid, String userId, String date, String stepCount, | |
| 21 | - long pauseTimeStamp, long recordTime, double caloriesCount, | |
| 22 | - String serverTraceData) { | |
| 23 | - this.uuid = uuid; | |
| 17 | + private String startPoint; | |
| 18 | + private String endPoint; | |
| 19 | + private long startTimeStamp; | |
| 20 | + private long finishTimeStamp; | |
| 21 | + private String streetId;//赛事ID | |
| 22 | + private int pauseCount;//暂停次数 | |
| 23 | + private long userPauseTimeStamp;//暂停时间戳 | |
| 24 | + | |
| 25 | + @Generated(hash = 446594441) | |
| 26 | + public UserStepEntity(String userId, String date, String stepCount, long pauseTimeStamp, long recordTime, double caloriesCount, | |
| 27 | + String serverTraceData, String startPoint, String endPoint, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, | |
| 28 | + long userPauseTimeStamp) { | |
| 24 | 29 | this.userId = userId; |
| 25 | 30 | this.date = date; |
| 26 | 31 | this.stepCount = stepCount; |
| ... | ... | @@ -28,6 +33,13 @@ public class UserStepEntity { |
| 28 | 33 | this.recordTime = recordTime; |
| 29 | 34 | this.caloriesCount = caloriesCount; |
| 30 | 35 | this.serverTraceData = serverTraceData; |
| 36 | + this.startPoint = startPoint; | |
| 37 | + this.endPoint = endPoint; | |
| 38 | + this.startTimeStamp = startTimeStamp; | |
| 39 | + this.finishTimeStamp = finishTimeStamp; | |
| 40 | + this.streetId = streetId; | |
| 41 | + this.pauseCount = pauseCount; | |
| 42 | + this.userPauseTimeStamp = userPauseTimeStamp; | |
| 31 | 43 | } |
| 32 | 44 | |
| 33 | 45 | @Generated(hash = 273857141) |
| ... | ... | @@ -58,14 +70,6 @@ public class UserStepEntity { |
| 58 | 70 | this.stepCount = stepCount; |
| 59 | 71 | } |
| 60 | 72 | |
| 61 | - public String getUuid() { | |
| 62 | - return this.uuid; | |
| 63 | - } | |
| 64 | - | |
| 65 | - public void setUuid(String uuid) { | |
| 66 | - this.uuid = uuid; | |
| 67 | - } | |
| 68 | - | |
| 69 | 73 | public long getPauseTimeStamp() { |
| 70 | 74 | return this.pauseTimeStamp; |
| 71 | 75 | } |
| ... | ... | @@ -74,14 +78,6 @@ public class UserStepEntity { |
| 74 | 78 | this.pauseTimeStamp = pauseTimeStamp; |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | - public double getCaloriesCount() { | |
| 78 | - return this.caloriesCount; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public void setCaloriesCount(double caloriesCount) { | |
| 82 | - this.caloriesCount = caloriesCount; | |
| 83 | - } | |
| 84 | - | |
| 85 | 81 | public long getRecordTime() { |
| 86 | 82 | return this.recordTime; |
| 87 | 83 | } |
| ... | ... | @@ -90,6 +86,14 @@ public class UserStepEntity { |
| 90 | 86 | this.recordTime = recordTime; |
| 91 | 87 | } |
| 92 | 88 | |
| 89 | + public double getCaloriesCount() { | |
| 90 | + return this.caloriesCount; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public void setCaloriesCount(double caloriesCount) { | |
| 94 | + this.caloriesCount = caloriesCount; | |
| 95 | + } | |
| 96 | + | |
| 93 | 97 | public String getServerTraceData() { |
| 94 | 98 | return this.serverTraceData; |
| 95 | 99 | } |
| ... | ... | @@ -98,5 +102,61 @@ public class UserStepEntity { |
| 98 | 102 | this.serverTraceData = serverTraceData; |
| 99 | 103 | } |
| 100 | 104 | |
| 105 | + public String getStartPoint() { | |
| 106 | + return this.startPoint; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void setStartPoint(String startPoint) { | |
| 110 | + this.startPoint = startPoint; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public String getEndPoint() { | |
| 114 | + return this.endPoint; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public void setEndPoint(String endPoint) { | |
| 118 | + this.endPoint = endPoint; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public long getStartTimeStamp() { | |
| 122 | + return this.startTimeStamp; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void setStartTimeStamp(long startTimeStamp) { | |
| 126 | + this.startTimeStamp = startTimeStamp; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public long getFinishTimeStamp() { | |
| 130 | + return this.finishTimeStamp; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setFinishTimeStamp(long finishTimeStamp) { | |
| 134 | + this.finishTimeStamp = finishTimeStamp; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public String getStreetId() { | |
| 138 | + return this.streetId; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setStreetId(String streetId) { | |
| 142 | + this.streetId = streetId; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public int getPauseCount() { | |
| 146 | + return this.pauseCount; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setPauseCount(int pauseCount) { | |
| 150 | + this.pauseCount = pauseCount; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public long getUserPauseTimeStamp() { | |
| 154 | + return this.userPauseTimeStamp; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setUserPauseTimeStamp(long userPauseTimeStamp) { | |
| 158 | + this.userPauseTimeStamp = userPauseTimeStamp; | |
| 159 | + } | |
| 160 | + | |
| 101 | 161 | |
| 102 | 162 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunLineActivity.java
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
| ... | ... | @@ -10,6 +10,7 @@ import android.view.View; |
| 10 | 10 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 11 | 11 | import com.cnlive.libs.base.util.StatusBarUtil; |
| 12 | 12 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 13 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 13 | 14 | import com.cnlive.moudle.pedometer.frame.presenter.RunMainFragmentPresenter; |
| 14 | 15 | import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView; |
| 15 | 16 | import com.cnlive.moudle.pedometer.model.Constant; |
| ... | ... | @@ -57,10 +58,11 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 57 | 58 | @Override |
| 58 | 59 | public void onPause() { |
| 59 | 60 | super.onPause(); |
| 61 | + //todo 第二期在用 | |
| 60 | 62 | //记录当前计时器相关数据 |
| 61 | 63 | if (getMvpView() != null) { |
| 62 | - if (!TextUtils.isEmpty(userId)) { | |
| 63 | - getMvpView().setSQLPauseTime(userId); | |
| 64 | + if (!TextUtils.isEmpty(CommonInfo.getUserId(getActivity()))) { | |
| 65 | + getMvpView().setFragmentPauseTime(userId); | |
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
| ... | ... | @@ -89,12 +89,14 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 89 | 89 | super.onResume(); |
| 90 | 90 | if (getMvpView() != null) { |
| 91 | 91 | getMvpView().onResume(); |
| 92 | + getMvpView().checkStartBtnState(); | |
| 92 | 93 | } |
| 93 | 94 | if (getMvpView() != null) { |
| 94 | 95 | //为系统的方向传感器注册监听器 |
| 95 | 96 | mSensorManager.registerListener(getMvpView(), mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), |
| 96 | 97 | SensorManager.SENSOR_DELAY_UI); |
| 97 | 98 | } |
| 99 | + | |
| 98 | 100 | } |
| 99 | 101 | |
| 100 | 102 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
| ... | ... | @@ -109,7 +109,8 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run |
| 109 | 109 | } |
| 110 | 110 | //开始进行历史轨迹查询 |
| 111 | 111 | if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) { |
| 112 | - long stepStartTime = CommonInfo.getStepStartTime(getActivity()); | |
| 112 | + long stepStartTime = 0; | |
| 113 | +// CommonInfo.getStepStartTime(getActivity()); | |
| 113 | 114 | Log.e(TAG, "onViewCreated: 时间"+stepStartTime ); |
| 114 | 115 | long startTime = 0; |
| 115 | 116 | if (stepStartTime != 0) { |
| ... | ... | @@ -117,7 +118,7 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run |
| 117 | 118 | } else { |
| 118 | 119 | startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60); |
| 119 | 120 | } |
| 120 | - long current = TimeUtil.getCurrentTime(); | |
| 121 | + long current = TimeUtil.getNowTimeStamp(); | |
| 121 | 122 | // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; |
| 122 | 123 | long endTime = current; |
| 123 | 124 | // Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
| ... | ... | @@ -90,14 +90,11 @@ public class StepUtil { |
| 90 | 90 | */ |
| 91 | 91 | public static void clearRunData(Context context, String uid) { |
| 92 | 92 | DbCore.init(context, dbName); |
| 93 | - String CURRENT_DATE = getTodayDate(); | |
| 94 | - List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list(); | |
| 93 | + List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 95 | 94 | if (list != null && list.size() > 0) { |
| 96 | 95 | Log.e(TAG, "clearRunData: " + list.size()); |
| 97 | -// for (int i = 0; i < list.size(); i++) { | |
| 98 | - DbCore.getDaoSession().getUserStepEntityDao().deleteByKey(list.get(0).getUuid()); | |
| 96 | + DbCore.getDaoSession().getUserStepEntityDao().delete(list.get(0)); | |
| 99 | 97 | DbCore.getDaoSession().getUserStepEntityDao().detachAll(); |
| 100 | -// } | |
| 101 | 98 | } |
| 102 | 99 | } |
| 103 | 100 | |
| ... | ... | @@ -111,10 +108,7 @@ public class StepUtil { |
| 111 | 108 | public static UserStepEntity getUserStepData(Context context, String uid) { |
| 112 | 109 | if (!TextUtils.isEmpty(uid)) { |
| 113 | 110 | DbCore.init(context, dbName); |
| 114 | - DbCore.getDaoSession().getUserStepEntityDao().detachAll(); | |
| 115 | - DbCore.getDaoSession().clear(); | |
| 116 | - String CURRENT_DATE = getTodayDate(); | |
| 117 | - List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list(); | |
| 111 | + List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 118 | 112 | if (list != null && list.size() > 0) { |
| 119 | 113 | return list.get(0); |
| 120 | 114 | } else { |
| ... | ... | @@ -126,18 +120,70 @@ public class StepUtil { |
| 126 | 120 | } |
| 127 | 121 | |
| 128 | 122 | /** |
| 129 | - * 获取用户数据 | |
| 123 | + * 设置用户数据 | |
| 130 | 124 | * |
| 131 | 125 | * @param context |
| 132 | 126 | * @param uid |
| 133 | 127 | * @return |
| 134 | 128 | */ |
| 135 | - public static void setServerTraceData(Context context, String uid, UserStepEntity userStepEntity) { | |
| 129 | + public static void setUserStepData(Context context, String uid, UserStepEntity userStepEntity) { | |
| 130 | + if (getUserStepData(context, uid) != null) { | |
| 131 | + UserStepEntity entity = getUserStepData(context, uid); | |
| 132 | + } else { | |
| 133 | + | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + public static void setStepStartData(Context context, String uid, long startStamp, String streetId) { | |
| 136 | 138 | if (getUserStepData(context, uid) != null) { |
| 137 | 139 | UserStepEntity entity = getUserStepData(context, uid); |
| 138 | -// entity.setServerTraceData(); | |
| 140 | + entity.setStartTimeStamp(startStamp); | |
| 141 | + entity.setStreetId(streetId); | |
| 142 | + //更新数据 | |
| 143 | + updateStepData(context, entity); | |
| 139 | 144 | } else { |
| 145 | + //创建数据 | |
| 146 | + UserStepEntity userStepEntity = new UserStepEntity(); | |
| 147 | + userStepEntity.setUserId(uid); | |
| 148 | + userStepEntity.setStartTimeStamp(startStamp); | |
| 149 | + userStepEntity.setStreetId(streetId); | |
| 150 | + insertStepData(context, userStepEntity); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + | |
| 154 | + public static void insertStepData(Context context, UserStepEntity userStepEntity) { | |
| 155 | + DbCore.init(context, dbName); | |
| 156 | + DbCore.getDaoSession().getUserStepEntityDao().insert(userStepEntity); | |
| 157 | + } | |
| 140 | 158 | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * 获取用户暂停次数 | |
| 162 | + * | |
| 163 | + * @param context | |
| 164 | + * @param uid | |
| 165 | + * @return | |
| 166 | + */ | |
| 167 | + public static int getUserPauseCount(Context context, String uid) { | |
| 168 | + UserStepEntity userStepEntity = getUserStepData(context, uid); | |
| 169 | + if (userStepEntity != null) { | |
| 170 | + return userStepEntity.getPauseCount(); | |
| 171 | + } else { | |
| 172 | + return -1; | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * 设置用户完成时间戳 | |
| 178 | + * | |
| 179 | + * @param context | |
| 180 | + */ | |
| 181 | + public static void setUserFinishTimeStamp(Context context, String uid) { | |
| 182 | + UserStepEntity userStepEntity = getUserStepData(context, uid); | |
| 183 | + if (userStepEntity != null) { | |
| 184 | + userStepEntity.setFinishTimeStamp(TimeUtil.getNowTimeStamp()); | |
| 185 | + //更新 | |
| 186 | + updateStepData(context, userStepEntity); | |
| 141 | 187 | } |
| 142 | 188 | } |
| 143 | 189 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/TimeUtil.java
| ... | ... | @@ -10,14 +10,6 @@ import java.util.Date; |
| 10 | 10 | * @author ShinnyYang |
| 11 | 11 | */ |
| 12 | 12 | public class TimeUtil { |
| 13 | - /** | |
| 14 | - * 获取当前时间戳(单位:秒) | |
| 15 | - * | |
| 16 | - * @return | |
| 17 | - */ | |
| 18 | - public static long getCurrentTime() { | |
| 19 | - return System.currentTimeMillis(); | |
| 20 | - } | |
| 21 | 13 | |
| 22 | 14 | /** |
| 23 | 15 | * 日期格式字符串转换成时间戳 | ... | ... |
moudle_pedometer/src/main/res/layout/dialog_tip.xml
| ... | ... | @@ -11,16 +11,17 @@ |
| 11 | 11 | android:layout_height="wrap_content" |
| 12 | 12 | android:background="@drawable/free_dialog_bg" |
| 13 | 13 | android:orientation="vertical" |
| 14 | - android:paddingTop="10dp" | |
| 15 | - > | |
| 14 | + android:paddingTop="10dp"> | |
| 16 | 15 | |
| 17 | 16 | <TextView |
| 18 | 17 | android:id="@+id/tv_dialog_tip" |
| 19 | 18 | android:layout_width="wrap_content" |
| 20 | 19 | android:layout_height="wrap_content" |
| 21 | - android:minHeight="75dp" | |
| 22 | - android:gravity="center" | |
| 23 | 20 | android:layout_gravity="center" |
| 21 | + android:layout_marginLeft="10dp" | |
| 22 | + android:layout_marginRight="10dp" | |
| 23 | + android:gravity="center" | |
| 24 | + android:minHeight="75dp" | |
| 24 | 25 | android:text="标题" |
| 25 | 26 | android:textColor="@color/black" |
| 26 | 27 | android:textSize="17sp" |
| ... | ... | @@ -59,7 +60,6 @@ |
| 59 | 60 | </LinearLayout> |
| 60 | 61 | |
| 61 | 62 | |
| 62 | - | |
| 63 | 63 | </LinearLayout> |
| 64 | 64 | </LinearLayout> |
| 65 | 65 | </LinearLayout> | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_finish_run_map.xml
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | sothree:umanoFadeColor="@color/black_20" |
| 16 | 16 | sothree:umanoOverlay="true" |
| 17 | 17 | sothree:umanoPanelHeight="310dp" |
| 18 | - sothree:umanoParallaxOffset="100dp" | |
| 18 | + sothree:umanoParallaxOffset="0dp" | |
| 19 | 19 | sothree:umanoScrollableView="@+id/scrollView" |
| 20 | 20 | sothree:umanoShadowHeight="0dp"> |
| 21 | 21 | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_run_main.xml
| ... | ... | @@ -31,32 +31,42 @@ |
| 31 | 31 | android:src="@drawable/icon_right_close" /> |
| 32 | 32 | </RelativeLayout> |
| 33 | 33 | <!--公里数显示--> |
| 34 | - <LinearLayout | |
| 34 | + <FrameLayout | |
| 35 | 35 | android:layout_width="match_parent" |
| 36 | 36 | android:layout_height="0dp" |
| 37 | - android:layout_weight="1.2" | |
| 38 | - android:gravity="center" | |
| 39 | - android:paddingLeft="50dp"> | |
| 37 | + android:layout_weight="1.2"> | |
| 40 | 38 | |
| 39 | + <LinearLayout | |
| 40 | + android:layout_width="match_parent" | |
| 41 | + android:layout_height="match_parent" | |
| 42 | + android:gravity="center" | |
| 43 | + android:paddingLeft="50dp"> | |
| 41 | 44 | |
| 42 | - <TextView | |
| 43 | - android:id="@+id/tv_run_distance" | |
| 44 | - android:layout_width="wrap_content" | |
| 45 | - android:layout_height="wrap_content" | |
| 46 | - android:text="0.00" | |
| 47 | - android:textColor="@color/white" | |
| 48 | - android:textSize="70sp" | |
| 49 | - android:textStyle="bold" /> | |
| 45 | + <TextView | |
| 46 | + android:id="@+id/tv_run_distance" | |
| 47 | + android:layout_width="wrap_content" | |
| 48 | + android:layout_height="wrap_content" | |
| 49 | + android:text="0.00" | |
| 50 | + android:textColor="@color/white" | |
| 51 | + android:textSize="70sp" | |
| 52 | + android:textStyle="bold" /> | |
| 50 | 53 | |
| 51 | - <TextView | |
| 52 | - android:layout_width="wrap_content" | |
| 53 | - android:layout_height="wrap_content" | |
| 54 | - android:layout_marginLeft="10dp" | |
| 55 | - android:layout_marginTop="20dp" | |
| 56 | - android:text="公里" | |
| 57 | - android:textColor="@color/white" | |
| 58 | - android:textSize="15sp" /> | |
| 59 | - </LinearLayout> | |
| 54 | + <TextView | |
| 55 | + android:layout_width="wrap_content" | |
| 56 | + android:layout_height="wrap_content" | |
| 57 | + android:layout_marginLeft="10dp" | |
| 58 | + android:layout_marginTop="20dp" | |
| 59 | + android:text="公里" | |
| 60 | + android:textColor="@color/white" | |
| 61 | + android:textSize="15sp" /> | |
| 62 | + </LinearLayout> | |
| 63 | + | |
| 64 | + <ImageView | |
| 65 | + android:id="@+id/iv_back" | |
| 66 | + android:layout_width="20dp" | |
| 67 | + android:layout_height="40dp" | |
| 68 | + android:background="@drawable/back" /> | |
| 69 | + </FrameLayout> | |
| 60 | 70 | <!--GPS信息--> |
| 61 | 71 | <LinearLayout |
| 62 | 72 | android:layout_width="match_parent" | ... | ... |
moudle_pedometer/src/main/res/values/strings.xml
| ... | ... | @@ -83,6 +83,7 @@ |
| 83 | 83 | <string name="up_fail">上传失败</string> |
| 84 | 84 | <string name="enter_range_tip">您已回归轨迹 继续参与运动吧</string> |
| 85 | 85 | <string name="exit_range_tip">您已偏离路径轨迹 请您计时回归路径!</string> |
| 86 | + <string name="more_than_pause_count_tip">您已超过最大暂停次数,无法继续比赛!</string> | |
| 86 | 87 | |
| 87 | 88 | |
| 88 | 89 | </resources> | ... | ... |