Commit feca720b133d6d2721d8b51bdc2cb5e5cab0bb08

Authored by 韩亚云
2 parents 405ef56b 91bd63f4

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

Showing 30 changed files with 579 additions and 227 deletions
config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "0.7.8", 24 + version: "0.7.19",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningFinishFragmetPresenter.java
@@ -43,10 +43,13 @@ import io.reactivex.disposables.Disposable; @@ -43,10 +43,13 @@ import io.reactivex.disposables.Disposable;
43 public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> { 43 public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> {
44 44
45 public void uploadTraceDateToServer(Activity context, CollUserStepEntity userStepEntity, String roadmap) { 45 public void uploadTraceDateToServer(Activity context, CollUserStepEntity userStepEntity, String roadmap) {
  46 + if (null == getView()) {
  47 + return;
  48 + }
46 if (null != getView()) { 49 if (null != getView()) {
47 getView().limitUploadBtnTouch(); 50 getView().limitUploadBtnTouch();
48 } 51 }
49 - QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); 52 + getView().showLoading("正在上传数据");
50 Map<String, String> paramsMap = new HashMap<>(); 53 Map<String, String> paramsMap = new HashMap<>();
51 //赛事id 54 //赛事id
52 if (!TextUtils.isEmpty(userStepEntity.getStreetId())) { 55 if (!TextUtils.isEmpty(userStepEntity.getStreetId())) {
@@ -120,6 +123,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -120,6 +123,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
120 if (getView() == null) { 123 if (getView() == null) {
121 return; 124 return;
122 } 125 }
  126 + getView().hideLoading();
123 if (null != getView()) { 127 if (null != getView()) {
124 getView().allowUploadBtnTouch(); 128 getView().allowUploadBtnTouch();
125 } 129 }
@@ -132,7 +136,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -132,7 +136,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
132 }, "重试", new SelectDialog.DialogInterface() { 136 }, "重试", new SelectDialog.DialogInterface() {
133 @Override 137 @Override
134 public void onClick(SelectDialog dialog) { 138 public void onClick(SelectDialog dialog) {
135 - dialog.dismiss(); 139 + getView().hideLoading();
136 uploadTraceDateToServer(context, userStepEntity, roadmap); 140 uploadTraceDateToServer(context, userStepEntity, roadmap);
137 } 141 }
138 }); 142 });
@@ -149,7 +153,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -149,7 +153,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
149 return; 153 return;
150 } 154 }
151 EventBus.getDefault().post(new MessageEvent(Constant.UPDATA_COLL_TRACE_LIST, "")); 155 EventBus.getDefault().post(new MessageEvent(Constant.UPDATA_COLL_TRACE_LIST, ""));
152 - QMUITipDialogUtil.dismessDialog(); 156 + getView().hideLoading();
153 QMUITipDialogUtil.successDialog(context, "数据上传成功", 1); 157 QMUITipDialogUtil.successDialog(context, "数据上传成功", 1);
154 //清空数据 158 //清空数据
155 CollStepUtil.clearRunData(context, CollCommonInfo.getUserId(context)); 159 CollStepUtil.clearRunData(context, CollCommonInfo.getUserId(context));
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningMapFragmentPresenter.java
@@ -140,7 +140,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin @@ -140,7 +140,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin
140 //自动判断交通方式 140 //自动判断交通方式
141 processOption.setTransportMode(TransportMode.walking); 141 processOption.setTransportMode(TransportMode.walking);
142 // 设置精度过滤值(定位精度大于100米的过滤掉) 142 // 设置精度过滤值(定位精度大于100米的过滤掉)
143 - processOption.setRadiusThreshold(9); 143 + processOption.setRadiusThreshold(20);
144 // 设置纠偏选项 144 // 设置纠偏选项
145 historyTrackRequest.setProcessOption(processOption); 145 historyTrackRequest.setProcessOption(processOption);
146 // 设置里程填充方式为驾车 146 // 设置里程填充方式为驾车
@@ -208,7 +208,6 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin @@ -208,7 +208,6 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin
208 queryHistoryTrace(context, entityName, startTime, endTime); 208 queryHistoryTrace(context, entityName, startTime, endTime);
209 } else { 209 } else {
210 if (getView() != null) { 210 if (getView() != null) {
211 -  
212 //开始比较(杨帅的思路) 211 //开始比较(杨帅的思路)
213 // for (int i = 0; i < trackPoints.size(); i++) { 212 // for (int i = 0; i < trackPoints.size(); i++) {
214 // if (matchIndex < importPoints.size() - 1) { 213 // if (matchIndex < importPoints.size() - 1) {
@@ -236,34 +235,14 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin @@ -236,34 +235,14 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin
236 // } else { 235 // } else {
237 // Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); 236 // Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show();
238 // } 237 // }
239 - //郭瑞鹏的思路  
240 - int index = 0;  
241 - for (int i = 0; i < importPoints.size(); i++) {  
242 - LatLng importLatLng = importPoints.get(i);  
243 - for (int j = index; j < trackPoints.size(); j++) {  
244 - double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j));  
245 - if (distance<100){  
246 - importHash.put(i,true);  
247 - index=j;  
248 - }  
249 - }  
250 - }  
251 - //输出  
252 - int result = 0;  
253 - for (int i = 0; i < importHash.size(); i++) {  
254 - if (!importHash.get(i)) {  
255 - result++;  
256 - Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i));  
257 - }  
258 - }  
259 - if (result > importPoints.size() * 0.4) {  
260 - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();  
261 -  
262 - } else {  
263 - Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show();  
264 - }  
265 - Log.e(TAG, "结果: " + result);  
266 - Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints)); 238 +// if (result > importPoints.size() * 0.4) {
  239 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
  240 +//
  241 +// } else {
  242 +// Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show();
  243 +// }
  244 +// Log.e(TAG, "结果: " + result);
  245 +// Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints));
267 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); 246 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
268 // MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red); 247 // MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red);
269 } 248 }
@@ -274,7 +253,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin @@ -274,7 +253,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter&lt;CollRunnin
274 public void onDistanceCallback(DistanceResponse distanceResponse) { 253 public void onDistanceCallback(DistanceResponse distanceResponse) {
275 super.onDistanceCallback(distanceResponse); 254 super.onDistanceCallback(distanceResponse);
276 // Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show(); 255 // Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show();
277 - Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance()); 256 +// Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance());
278 } 257 }
279 }; 258 };
280 //开始查询历史轨迹 259 //开始查询历史轨迹
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
@@ -669,7 +669,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen @@ -669,7 +669,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
669 if (isFirstLoc) { 669 if (isFirstLoc) {
670 isFirstLoc = false; 670 isFirstLoc = false;
671 if (location.getRadius() > Constant.LOCA_ACCURACY) { 671 if (location.getRadius() > Constant.LOCA_ACCURACY) {
672 - Toast.makeText(getContext(), "当前定位误差为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); 672 + Toast.makeText(getContext(), "当前定位误差为:" + (int)location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
673 } 673 }
674 } else { 674 } else {
675 //过滤定位精度 675 //过滤定位精度
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
@@ -8,6 +8,7 @@ import android.text.TextUtils; @@ -8,6 +8,7 @@ import android.text.TextUtils;
8 import android.util.Log; 8 import android.util.Log;
9 import android.view.MotionEvent; 9 import android.view.MotionEvent;
10 import android.view.View; 10 import android.view.View;
  11 +import android.widget.TextView;
11 12
12 import com.baidu.mapapi.map.BaiduMap; 13 import com.baidu.mapapi.map.BaiduMap;
13 import com.baidu.mapapi.map.MapView; 14 import com.baidu.mapapi.map.MapView;
@@ -122,7 +123,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -122,7 +123,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
122 String faceUrl = CommonInfo.getUserIcon(getContext()); 123 String faceUrl = CommonInfo.getUserIcon(getContext());
123 if (!TextUtils.isEmpty(faceUrl)) { 124 if (!TextUtils.isEmpty(faceUrl)) {
124 GlideApp.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 125 GlideApp.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
125 - }else { 126 + } else {
126 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 127 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
127 } 128 }
128 //设置标题 129 //设置标题
@@ -207,7 +208,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -207,7 +208,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
207 } 208 }
208 } 209 }
209 dialog.dismiss(); 210 dialog.dismiss();
210 - QMUITipDialogUtil.loadingDialog(getContext(), "正在截取赛事图片,请稍后", false); 211 + showLoading("正在截取赛事图片,请稍后");
211 //延迟一秒进行截图,以免把打的点都截取到 212 //延迟一秒进行截图,以免把打的点都截取到
212 new Handler().postDelayed(new Runnable() { 213 new Handler().postDelayed(new Runnable() {
213 @Override 214 @Override
@@ -358,8 +359,8 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -358,8 +359,8 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
358 baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { 359 baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() {
359 @Override 360 @Override
360 public void onSnapshotReady(Bitmap bitmap) { 361 public void onSnapshotReady(Bitmap bitmap) {
361 - QMUITipDialogUtil.dismessDialog();  
362 if (null == bitmap) { 362 if (null == bitmap) {
  363 + hideLoading();
363 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); 364 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2);
364 return; 365 return;
365 } 366 }
@@ -376,7 +377,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -376,7 +377,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
376 //开始上传 377 //开始上传
377 uploadRoadMapPic(roadMapPath); 378 uploadRoadMapPic(roadMapPath);
378 } catch (Exception e) { 379 } catch (Exception e) {
379 - QMUITipDialogUtil.dismessDialog(); 380 + hideLoading();
380 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); 381 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2);
381 //允许点击 382 //允许点击
382 allowUploadBtnTouch(); 383 allowUploadBtnTouch();
@@ -395,14 +396,14 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -395,14 +396,14 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
395 //禁止点击 396 //禁止点击
396 limitUploadBtnTouch(); 397 limitUploadBtnTouch();
397 if (!TextUtils.isEmpty(roadMapPath)) { 398 if (!TextUtils.isEmpty(roadMapPath)) {
398 - QMUITipDialogUtil.loadingDialog(getContext(), "正在上传赛事图片,请稍后", false); 399 + showLoading("正在上传赛事图片,请稍后");
399 List<String> imagePaths = new ArrayList<>(); 400 List<String> imagePaths = new ArrayList<>();
400 imagePaths.add(roadMapPath); 401 imagePaths.add(roadMapPath);
401 UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>() 402 UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>()
402 .setFailureCallback(new FailureCallback() { 403 .setFailureCallback(new FailureCallback() {
403 @Override 404 @Override
404 public void onFailure(int i, String s) { 405 public void onFailure(int i, String s) {
405 - QMUITipDialogUtil.dismessDialog(); 406 + hideLoading();
406 SelectDialog selectDialog = new SelectDialog(getContext(), "赛事图片上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() { 407 SelectDialog selectDialog = new SelectDialog(getContext(), "赛事图片上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() {
407 @Override 408 @Override
408 public void onClick(SelectDialog dialog) { 409 public void onClick(SelectDialog dialog) {
@@ -428,7 +429,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -428,7 +429,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
428 .setSuccessCallback(new SuccessCallback<String>() { 429 .setSuccessCallback(new SuccessCallback<String>() {
429 @Override 430 @Override
430 public void onSuccess(String data) { 431 public void onSuccess(String data) {
431 - QMUITipDialogUtil.dismessDialog(); 432 + hideLoading();
432 //开始把数据传到服务端 433 //开始把数据传到服务端
433 collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext())); 434 collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext()));
434 if (null != fragment.getPresenter() || null == fragment.getActivity() || null == collUserStepEntity || TextUtils.isEmpty(data)) { 435 if (null != fragment.getPresenter() || null == fragment.getActivity() || null == collUserStepEntity || TextUtils.isEmpty(data)) {
@@ -441,6 +442,26 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -441,6 +442,26 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
441 } 442 }
442 } 443 }
443 444
  445 + public void showLoading(String tip) {
  446 + if (null == getContext() || null == fragment.binding.llLoading || null == fragment.binding.tvLoadingTip) {
  447 + return;
  448 + }
  449 + if (fragment.binding.llLoading.getVisibility() == View.GONE) {
  450 + fragment.binding.llLoading.setVisibility(View.VISIBLE);
  451 + }
  452 + if (!TextUtils.isEmpty(tip)) {
  453 + fragment.binding.tvLoadingTip.setText(tip);
  454 + }
  455 +
  456 + }
  457 + public void hideLoading() {
  458 + if (null == getContext() || null == fragment.binding.llLoading || null == fragment.binding.tvLoadingTip) {
  459 + return;
  460 + }
  461 + if (fragment.binding.llLoading.getVisibility() == View.VISIBLE) {
  462 + fragment.binding.llLoading.setVisibility(View.GONE);
  463 + }
  464 + }
444 465
445 public void initMap() { 466 public void initMap() {
446 this.mMapView = fragment.binding.mapView; 467 this.mMapView = fragment.binding.mapView;
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
@@ -36,6 +36,7 @@ import com.baidu.mapapi.utils.DistanceUtil; @@ -36,6 +36,7 @@ import com.baidu.mapapi.utils.DistanceUtil;
36 import com.baidu.trace.model.SortType; 36 import com.baidu.trace.model.SortType;
37 import com.cnlive.libs.base.util.AlertUtil; 37 import com.cnlive.libs.base.util.AlertUtil;
38 import com.cnlive.moudle.collectionTrace.model.CollectPoint; 38 import com.cnlive.moudle.collectionTrace.model.CollectPoint;
  39 +import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
39 import com.cnlive.moudle.collectionTrace.service.CollStepService; 40 import com.cnlive.moudle.collectionTrace.service.CollStepService;
40 import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity; 41 import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity;
41 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; 42 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
@@ -303,7 +304,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -303,7 +304,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
303 public void onClick(View view) { 304 public void onClick(View view) {
304 //先获取打点数量 305 //先获取打点数量
305 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext())); 306 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext()));
306 - if (canTakePointCount<2) { 307 + if (canTakePointCount < 2) {
307 AlertUtil.showDeftToast(getContext(), "请至少打两个点后结束"); 308 AlertUtil.showDeftToast(getContext(), "请至少打两个点后结束");
308 } else { 309 } else {
309 if (null != followMyLocation) { 310 if (null != followMyLocation) {
@@ -444,12 +445,15 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -444,12 +445,15 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
444 private void stopStepService() { 445 private void stopStepService() {
445 CollCommonInfo.setTsRunBaiduTraceService(getContext(), false); 446 CollCommonInfo.setTsRunBaiduTraceService(getContext(), false);
446 CollCommonInfo.setIsRunKeepAliveService(getContext(), false); 447 CollCommonInfo.setIsRunKeepAliveService(getContext(), false);
  448 + CollCommonInfo.setIsRunStepService(getContext(), false);
447 CollCommonInfo.setIsWriteUserStep(getContext(), false); 449 CollCommonInfo.setIsWriteUserStep(getContext(), false);
448 CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true); 450 CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
449 if (CollStepService.mClient != null) { 451 if (CollStepService.mClient != null) {
450 CollStepService.mClient.stopGather(StepService.traceListener); 452 CollStepService.mClient.stopGather(StepService.traceListener);
451 } 453 }
  454 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class));
452 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class)); 455 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
  456 +
453 } 457 }
454 458
455 private void initChrom() { 459 private void initChrom() {
@@ -561,7 +565,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -561,7 +565,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
561 //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔 565 //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔
562 //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔 566 //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔
563 //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW 567 //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW
564 - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); 568 +// option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
565 //可选,定位SDK内部是一个service,并放到了独立进程。 569 //可选,定位SDK内部是一个service,并放到了独立进程。
566 //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) 570 //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)
567 option.setIgnoreKillProcess(true); 571 option.setIgnoreKillProcess(true);
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollTraceListDetailFragmentView.java
@@ -4,6 +4,7 @@ import android.app.Activity; @@ -4,6 +4,7 @@ import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 import android.graphics.Bitmap; 5 import android.graphics.Bitmap;
6 import android.graphics.BitmapFactory; 6 import android.graphics.BitmapFactory;
  7 +import android.graphics.Point;
7 import android.os.Handler; 8 import android.os.Handler;
8 import android.support.v7.widget.LinearLayoutManager; 9 import android.support.v7.widget.LinearLayoutManager;
9 import android.text.TextUtils; 10 import android.text.TextUtils;
@@ -12,6 +13,8 @@ import android.view.MotionEvent; @@ -12,6 +13,8 @@ import android.view.MotionEvent;
12 import android.view.View; 13 import android.view.View;
13 14
14 import com.baidu.mapapi.map.BaiduMap; 15 import com.baidu.mapapi.map.BaiduMap;
  16 +import com.baidu.mapapi.map.MapStatus;
  17 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
15 import com.baidu.mapapi.map.MapView; 18 import com.baidu.mapapi.map.MapView;
16 import com.baidu.mapapi.map.Overlay; 19 import com.baidu.mapapi.map.Overlay;
17 import com.baidu.mapapi.map.UiSettings; 20 import com.baidu.mapapi.map.UiSettings;
@@ -298,7 +301,15 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -298,7 +301,15 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
298 } 301 }
299 302
300 } 303 }
301 - // 304 + //设置显示位置
  305 + if (null != getContext()) {
  306 + MapStatus.Builder builder = new MapStatus.Builder();
  307 + Point screenPoint = ScreenUtil.getScreenPoint(getContext());
  308 + if (null != screenPoint) {
  309 + builder.targetScreen(new Point(screenPoint.x / 2, screenPoint.y / 3));
  310 + }
  311 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  312 + }
302 } 313 }
303 } 314 }
304 315
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
@@ -133,6 +133,9 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -133,6 +133,9 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
133 MyMapUtil.getGeoCoderResult(new LatLng(followMyLocation.latitude, followMyLocation.longitude), new MyMapUtil.GeoCodeResult() { 133 MyMapUtil.getGeoCoderResult(new LatLng(followMyLocation.latitude, followMyLocation.longitude), new MyMapUtil.GeoCodeResult() {
134 @Override 134 @Override
135 public void success(String address) { 135 public void success(String address) {
  136 + if (null==getContext()){
  137 + return;
  138 + }
136 QMUITipDialogUtil.dismessDialog(); 139 QMUITipDialogUtil.dismessDialog();
137 if (null != address && !TextUtils.isEmpty(address)) { 140 if (null != address && !TextUtils.isEmpty(address)) {
138 currentAddress = address; 141 currentAddress = address;
@@ -301,9 +304,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -301,9 +304,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
301 if (CollStepService.mClient != null) { 304 if (CollStepService.mClient != null) {
302 CollStepService.mClient.stopGather(CollStepService.traceListener); 305 CollStepService.mClient.stopGather(CollStepService.traceListener);
303 } 306 }
304 - fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));  
305 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class)); 307 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class));
306 - 308 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
307 } 309 }
308 310
309 /** 311 /**
@@ -358,7 +360,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -358,7 +360,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
358 //可选,设置是否需要设备方向结果 360 //可选,设置是否需要设备方向结果
359 option.setNeedDeviceDirect(false); 361 option.setNeedDeviceDirect(false);
360 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 362 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
361 - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); 363 +// option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
  364 + option.setOpenAutoNotifyMode();
362 mLocClient.setLocOption(option); 365 mLocClient.setLocOption(option);
363 mLocClient.start(); 366 mLocClient.start();
364 //设置地图加载完毕监听 367 //设置地图加载完毕监听
@@ -429,7 +432,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -429,7 +432,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
429 } 432 }
430 if (isFirstLoc) { 433 if (isFirstLoc) {
431 isFirstLoc = false; 434 isFirstLoc = false;
432 - Toast.makeText(getContext(), "当前定位误差为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); 435 + Toast.makeText(getContext(), "当前定位误差为:" + (int)location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
433 //过滤定位精度 436 //过滤定位精度
434 if (location.getRadius() > Constant.LOCA_ACCURACY) { 437 if (location.getRadius() > Constant.LOCA_ACCURACY) {
435 return; 438 return;
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
@@ -44,7 +44,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -44,7 +44,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
44 private NotificationManager mNM; 44 private NotificationManager mNM;
45 private Notification notification = null; 45 private Notification notification = null;
46 //是否在后台运行 46 //是否在后台运行
47 - public static boolean isKeepService = true; 47 + public static boolean isKeepService = false;
48 public static CollKeepLiveService instance; 48 public static CollKeepLiveService instance;
49 private final String TAG = "CollKeepLiveService"; 49 private final String TAG = "CollKeepLiveService";
50 private Handler handler; 50 private Handler handler;
@@ -152,8 +152,20 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -152,8 +152,20 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
152 if (isRun) { 152 if (isRun) {
153 showHideForegroundNotification(); 153 showHideForegroundNotification();
154 startPlaySong(); 154 startPlaySong();
155 - if (runnable != null) {  
156 - handler.postDelayed(runnable, 5000); 155 +// if (runnable != null) {
  156 +// handler.postDelayed(runnable, 5000);
  157 +// }
  158 + } else {
  159 + try {
  160 + if (myReceiver != null && isRegisterReceiver) {
  161 + unregisterReceiver(myReceiver);
  162 + }
  163 + } catch (Exception e) {
  164 + Log.e(TAG, "run: ");
  165 + }
  166 + stopPlaySong();
  167 + if (isStartForegroundService) {
  168 + stopForeground(true);
157 } 169 }
158 } 170 }
159 return START_STICKY; 171 return START_STICKY;
@@ -207,9 +219,9 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -207,9 +219,9 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
207 channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE); 219 channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE);
208 mNM.createNotificationChannel(channel); 220 mNM.createNotificationChannel(channel);
209 } 221 }
210 - Intent notificationIntent = new Intent(this, CollRunningMapActivity.class); 222 +// Intent notificationIntent = new Intent(this, CollRunningMapActivity.class);
211 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 223 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
212 - .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) 224 +// .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
213 .setSmallIcon(R.mipmap.ic_launcher) 225 .setSmallIcon(R.mipmap.ic_launcher)
214 // .setCustomContentView(remoteViews) 226 // .setCustomContentView(remoteViews)
215 .setContentTitle(getResources().getString(R.string.app_name)) 227 .setContentTitle(getResources().getString(R.string.app_name))
@@ -279,11 +291,11 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -279,11 +291,11 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
279 if (isRun) { 291 if (isRun) {
280 Log.e(TAG, "重新播放"); 292 Log.e(TAG, "重新播放");
281 mediaPlayer.start(); 293 mediaPlayer.start();
282 - Intent intent = new Intent("com.cnlive.strike.receiver.CollServiceReceiver");  
283 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {  
284 - intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.CollServiceReceiver"));//高版本Android发送广播需要加这句  
285 - }  
286 - sendBroadcast(intent); 294 +// Intent intent = new Intent("com.cnlive.strike.receiver.CollServiceReceiver");
  295 +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  296 +// intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.CollServiceReceiver"));//高版本Android发送广播需要加这句
  297 +// }
  298 +// sendBroadcast(intent);
287 } else { 299 } else {
288 Log.e(TAG, "停止重新播放"); 300 Log.e(TAG, "停止重新播放");
289 stopPlaySong(); 301 stopPlaySong();
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
@@ -439,9 +439,9 @@ public class CollStepService extends Service implements SensorEventListener { @@ -439,9 +439,9 @@ public class CollStepService extends Service implements SensorEventListener {
439 } 439 }
440 440
441 441
442 - Intent notificationIntent = new Intent(this, CollRunningMapActivity.class); 442 +// Intent notificationIntent = new Intent(this, CollRunningMapActivity.class);
443 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 443 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
444 - .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) 444 +// .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
445 .setSmallIcon(R.mipmap.ic_launcher) 445 .setSmallIcon(R.mipmap.ic_launcher)
446 // .setCustomContentView(remoteViews) 446 // .setCustomContentView(remoteViews)
447 .setContentTitle(getResources().getString(R.string.app_name)) 447 .setContentTitle(getResources().getString(R.string.app_name))
@@ -721,10 +721,10 @@ public class CollStepService extends Service implements SensorEventListener { @@ -721,10 +721,10 @@ public class CollStepService extends Service implements SensorEventListener {
721 * 监听晚上0点变化初始化数据 721 * 监听晚上0点变化初始化数据
722 */ 722 */
723 private void isNewDay() { 723 private void isNewDay() {
724 - String time = "00:00";  
725 - if (time.equals(new SimpleDateFormat("HH:mm").format(new Date())) || !CURRENT_DATE.equals(getTodayDate())) {  
726 - initTodayData(userId);  
727 - } 724 +// String time = "00:00";
  725 +// if (time.equals(new SimpleDateFormat("HH:mm").format(new Date())) || !CURRENT_DATE.equals(getTodayDate())) {
  726 +// initTodayData(userId);
  727 +// }
728 } 728 }
729 729
730 // /** 730 // /**
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/ALLScoreDetailFragmentPresenter.java
1 package com.cnlive.moudle.pedometer.frame.presenter; 1 package com.cnlive.moudle.pedometer.frame.presenter;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
  4 +import android.graphics.Point;
4 import android.text.TextUtils; 5 import android.text.TextUtils;
5 import android.widget.Toast; 6 import android.widget.Toast;
6 7
  8 +import com.baidu.mapapi.map.MapStatus;
  9 +import com.baidu.mapapi.map.MapStatusUpdate;
  10 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
7 import com.baidu.mapapi.model.LatLng; 11 import com.baidu.mapapi.model.LatLng;
8 import com.baidu.trace.LBSTraceClient; 12 import com.baidu.trace.LBSTraceClient;
9 import com.baidu.trace.model.SortType; 13 import com.baidu.trace.model.SortType;
@@ -16,6 +20,7 @@ import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; @@ -16,6 +20,7 @@ import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
16 import com.cnlive.moudle.pedometer.utils.GsonUtil; 20 import com.cnlive.moudle.pedometer.utils.GsonUtil;
17 import com.cnlive.moudle.pedometer.utils.MyMapUtil; 21 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
18 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; 22 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
  23 +import com.cnlive.moudle.pedometer.utils.ScreenUtil;
19 import com.example.moudle_pedometer.R; 24 import com.example.moudle_pedometer.R;
20 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; 25 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
21 26
@@ -77,7 +82,15 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter&lt;ALLScoreDe @@ -77,7 +82,15 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter&lt;ALLScoreDe
77 MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -0.8f); 82 MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -0.8f);
78 } 83 }
79 } 84 }
80 - 85 + //设置显示位置
  86 + if (null != getView()) {
  87 + MapStatus.Builder builder = new MapStatus.Builder();
  88 + Point screenPoint = ScreenUtil.getScreenPoint(context);
  89 + if (null != screenPoint) {
  90 + builder.targetScreen(new Point(screenPoint.x / 2, screenPoint.y / 3));
  91 + }
  92 + getView().baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  93 + }
81 } 94 }
82 //如果用户点击暂停按钮,进行分段查询 95 //如果用户点击暂停按钮,进行分段查询
83 if (runningFinishBean.isPause()) { 96 if (runningFinishBean.isPause()) {
@@ -98,6 +111,15 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter&lt;ALLScoreDe @@ -98,6 +111,15 @@ public class ALLScoreDetailFragmentPresenter extends MvpBasePresenter&lt;ALLScoreDe
98 //设置地图自动缩放 111 //设置地图自动缩放
99 allResultList.addAll(resultPoints); 112 allResultList.addAll(resultPoints);
100 MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultList, -0.8f); 113 MyMapUtil.setMapAutoZoom(getView().baiduMap, allResultList, -0.8f);
  114 + //设置显示位置
  115 + if (null != getView()) {
  116 + MapStatus.Builder builder = new MapStatus.Builder();
  117 + Point screenPoint = ScreenUtil.getScreenPoint(context);
  118 + if (null != screenPoint) {
  119 + builder.targetScreen(new Point(screenPoint.x / 2, screenPoint.y / 3));
  120 + }
  121 + getView().baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  122 + }
101 } 123 }
102 } 124 }
103 }); 125 });
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/LineUpAgainPresenter.java
@@ -82,10 +82,10 @@ public class LineUpAgainPresenter extends MvpBasePresenter&lt;LineUpAgainView&gt; { @@ -82,10 +82,10 @@ public class LineUpAgainPresenter extends MvpBasePresenter&lt;LineUpAgainView&gt; {
82 //判断是否完成 82 //判断是否完成
83 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE); 83 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE);
84 if (isFinish) { 84 if (isFinish) {
85 - Toast.makeText(context, "完成", Toast.LENGTH_LONG).show(); 85 +// Toast.makeText(context, "完成", Toast.LENGTH_LONG).show();
86 failedEntity.setIsFinish("1"); 86 failedEntity.setIsFinish("1");
87 } else { 87 } else {
88 - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); 88 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
89 failedEntity.setIsFinish("0"); 89 failedEntity.setIsFinish("0");
90 } 90 }
91 saveRouteData(context, failedEntity, onResultListener); 91 saveRouteData(context, failedEntity, onResultListener);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
@@ -2,10 +2,13 @@ package com.cnlive.moudle.pedometer.frame.presenter; @@ -2,10 +2,13 @@ package com.cnlive.moudle.pedometer.frame.presenter;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
  5 +import android.graphics.Point;
5 import android.text.TextUtils; 6 import android.text.TextUtils;
6 import android.util.Log; 7 import android.util.Log;
7 import android.widget.Toast; 8 import android.widget.Toast;
8 9
  10 +import com.baidu.mapapi.map.MapStatus;
  11 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
9 import com.baidu.mapapi.model.LatLng; 12 import com.baidu.mapapi.model.LatLng;
10 import com.baidu.mapapi.utils.DistanceUtil; 13 import com.baidu.mapapi.utils.DistanceUtil;
11 import com.baidu.trace.LBSTraceClient; 14 import com.baidu.trace.LBSTraceClient;
@@ -29,6 +32,7 @@ import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; @@ -29,6 +32,7 @@ import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
29 import com.cnlive.moudle.pedometer.utils.GsonUtil; 32 import com.cnlive.moudle.pedometer.utils.GsonUtil;
30 import com.cnlive.moudle.pedometer.utils.MyMapUtil; 33 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
31 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; 34 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
  35 +import com.cnlive.moudle.pedometer.utils.ScreenUtil;
32 import com.cnlive.moudle.pedometer.utils.StepUtil; 36 import com.cnlive.moudle.pedometer.utils.StepUtil;
33 import com.example.moudle_pedometer.R; 37 import com.example.moudle_pedometer.R;
34 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; 38 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
@@ -58,10 +62,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -58,10 +62,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
58 String employTime = runningFinishBean.getEmployTime(); 62 String employTime = runningFinishBean.getEmployTime();
59 //路线全程里数 63 //路线全程里数
60 String mileage = ""; 64 String mileage = "";
61 - if ("--".equals(runningFinishBean.getRunDistance())) { 65 + if (null == userStepEntity.getStepCount() || TextUtils.isEmpty(userStepEntity.getStepCount())) {
62 mileage = "0"; 66 mileage = "0";
63 } else { 67 } else {
64 - mileage = runningFinishBean.getRunDistance(); 68 + mileage = StepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + "";
65 } 69 }
66 //配速 70 //配速
67 String pace = ""; 71 String pace = "";
@@ -218,7 +222,14 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -218,7 +222,14 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
218 if (userStepEntity.getPauseCount() == 0) { 222 if (userStepEntity.getPauseCount() == 0) {
219 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); 223 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
220 MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -1.5f); 224 MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -1.5f);
221 - 225 + if (null != getView()) {
  226 + MapStatus.Builder builder = new MapStatus.Builder();
  227 + Point screenPoint = ScreenUtil.getScreenPoint(context);
  228 + if (null != screenPoint) {
  229 + builder.targetScreen(new Point(screenPoint.x / 2, screenPoint.y / 3));
  230 + }
  231 + getView().baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  232 + }
222 //没有点击暂停 233 //没有点击暂停
223 //先判断是否到达终点 234 //先判断是否到达终点
224 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context); 235 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context);
@@ -241,8 +252,16 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -241,8 +252,16 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
241 if (importPoints != null) { 252 if (importPoints != null) {
242 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end); 253 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end);
243 MyMapUtil.setMapAutoZoom(getView().baiduMap, allResults, -2f); 254 MyMapUtil.setMapAutoZoom(getView().baiduMap, allResults, -2f);
  255 + if (null != getView()) {
  256 + MapStatus.Builder builder = new MapStatus.Builder();
  257 + Point screenPoint = ScreenUtil.getScreenPoint(context);
  258 + if (null != screenPoint) {
  259 + builder.targetScreen(new Point(screenPoint.x / 2, screenPoint.y / 3));
  260 + }
  261 + getView().baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  262 + }
244 //先判断是否到达终点 263 //先判断是否到达终点
245 - checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context); 264 + checkUserIsFinish(allResults, userStepEntity, runningFinishBean, context);
246 saveRouteData(context, userStepEntity, runningFinishBean); 265 saveRouteData(context, userStepEntity, runningFinishBean);
247 } 266 }
248 267
@@ -315,10 +334,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -315,10 +334,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
315 //判断是否完成 334 //判断是否完成
316 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE); 335 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE);
317 if (isFinish) { 336 if (isFinish) {
318 - Toast.makeText(context, "完成", Toast.LENGTH_LONG).show(); 337 +// Toast.makeText(context, "完成", Toast.LENGTH_LONG).show();
319 runningFinishBean.setIsFinish("1"); 338 runningFinishBean.setIsFinish("1");
320 } else { 339 } else {
321 - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); 340 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
322 runningFinishBean.setIsFinish("0"); 341 runningFinishBean.setIsFinish("0");
323 } 342 }
324 } 343 }
@@ -352,7 +371,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -352,7 +371,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
352 StepUtil.clearRunData(context, CommonInfo.getUserId(context)); 371 StepUtil.clearRunData(context, CommonInfo.getUserId(context));
353 CommonInfo.reset(context); 372 CommonInfo.reset(context);
354 //用户跑完了,更新一下按钮 373 //用户跑完了,更新一下按钮
355 - EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_RACE_STATE_BTN,"")); 374 + EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_RACE_STATE_BTN, ""));
356 //跳转到上传失败列表 375 //跳转到上传失败列表
357 LineUpAgainActivity.newInstance(context); 376 LineUpAgainActivity.newInstance(context);
358 //关闭当前窗口 377 //关闭当前窗口
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/UploadFailDetailFragmentPresenter.java
@@ -115,13 +115,13 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter&lt;UploadFa @@ -115,13 +115,13 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter&lt;UploadFa
115 //判断是否完成 115 //判断是否完成
116 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE); 116 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE);
117 if (isFinish) { 117 if (isFinish) {
118 - Toast.makeText(context, "完成", Toast.LENGTH_LONG).show(); 118 +// Toast.makeText(context, "完成", Toast.LENGTH_LONG).show();
119 failedEntity.setIsFinish("1"); 119 failedEntity.setIsFinish("1");
120 if (getView() != null) { 120 if (getView() != null) {
121 getView().updateIsFinish("1"); 121 getView().updateIsFinish("1");
122 } 122 }
123 } else { 123 } else {
124 - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); 124 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
125 failedEntity.setIsFinish("0"); 125 failedEntity.setIsFinish("0");
126 if (getView() != null) { 126 if (getView() != null) {
127 getView().updateIsFinish("0"); 127 getView().updateIsFinish("0");
@@ -158,13 +158,13 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter&lt;UploadFa @@ -158,13 +158,13 @@ public class UploadFailDetailFragmentPresenter extends MvpBasePresenter&lt;UploadFa
158 //判断是否完成 158 //判断是否完成
159 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, allResultPoints, Constant.PASS_RATE); 159 boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, allResultPoints, Constant.PASS_RATE);
160 if (isFinish) { 160 if (isFinish) {
161 - Toast.makeText(context, "完成", Toast.LENGTH_LONG).show(); 161 +// Toast.makeText(context, "完成", Toast.LENGTH_LONG).show();
162 failedEntity.setIsFinish("1"); 162 failedEntity.setIsFinish("1");
163 if (getView() != null) { 163 if (getView() != null) {
164 getView().updateIsFinish("1"); 164 getView().updateIsFinish("1");
165 } 165 }
166 } else { 166 } else {
167 - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); 167 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
168 failedEntity.setIsFinish("0"); 168 failedEntity.setIsFinish("0");
169 if (getView() != null) { 169 if (getView() != null) {
170 getView().updateIsFinish("0"); 170 getView().updateIsFinish("0");
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
@@ -74,7 +74,7 @@ public class RunMainFragmentView implements MvpView { @@ -74,7 +74,7 @@ public class RunMainFragmentView implements MvpView {
74 public MyLocationListenner myListener = new MyLocationListenner(); 74 public MyLocationListenner myListener = new MyLocationListenner();
75 private String employTime = ""; 75 private String employTime = "";
76 private LatLng endLatLng;//终点坐标 76 private LatLng endLatLng;//终点坐标
77 - private TipDialog tipDialog; 77 + private TipDialog endTipDialog;
78 //创建震动服务对象 78 //创建震动服务对象
79 private Vibrator mVibrator; 79 private Vibrator mVibrator;
80 private boolean isfirstEndTip = true; 80 private boolean isfirstEndTip = true;
@@ -131,6 +131,10 @@ public class RunMainFragmentView implements MvpView { @@ -131,6 +131,10 @@ public class RunMainFragmentView implements MvpView {
131 * 初始化相关视图 131 * 初始化相关视图
132 */ 132 */
133 public void initView(RunRaceDetailInfo runRaceDetailInfo) { 133 public void initView(RunRaceDetailInfo runRaceDetailInfo) {
  134 + if (getContext() == null) {
  135 + return;
  136 + }
  137 + initEndTipDialog();
134 //获取手机震动服务 138 //获取手机震动服务
135 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); 139 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE);
136 uid = CommonInfo.getUserId(getContext()); 140 uid = CommonInfo.getUserId(getContext());
@@ -342,6 +346,9 @@ public class RunMainFragmentView implements MvpView { @@ -342,6 +346,9 @@ public class RunMainFragmentView implements MvpView {
342 //继续记录轨迹 346 //继续记录轨迹
343 if (StepService.mClient != null && StepService.traceListener != null) { 347 if (StepService.mClient != null && StepService.traceListener != null) {
344 CommonInfo.setTsRunBaiduTraceService(getContext(), true); 348 CommonInfo.setTsRunBaiduTraceService(getContext(), true);
  349 + CommonInfo.setIsRunKeepAliveService(getContext(), true);
  350 + CommonInfo.setIsRunStepService(getContext(), true);
  351 + CommonInfo.setIsWriteUserStep(getContext(), true);
345 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener); 352 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener);
346 } 353 }
347 needWriteDataFlag = true; 354 needWriteDataFlag = true;
@@ -405,8 +412,8 @@ public class RunMainFragmentView implements MvpView { @@ -405,8 +412,8 @@ public class RunMainFragmentView implements MvpView {
405 public void onClick(SelectDialog dialog) { 412 public void onClick(SelectDialog dialog) {
406 //停止计时 413 //停止计时
407 fragment.binding.chronometer.stop(); 414 fragment.binding.chronometer.stop();
408 - //设置状态标志位  
409 - setStopStartFlag(); 415 + //停止服务
  416 + stopRunService();
410 //设置运动结束时间戳 417 //设置运动结束时间戳
411 StepUtil.setUserFinishTimeStamp(getContext(), uid); 418 StepUtil.setUserFinishTimeStamp(getContext(), uid);
412 fragment.binding.cpCurrent.setVisibility(View.GONE); 419 fragment.binding.cpCurrent.setVisibility(View.GONE);
@@ -576,6 +583,17 @@ public class RunMainFragmentView implements MvpView { @@ -576,6 +583,17 @@ public class RunMainFragmentView implements MvpView {
576 }); 583 });
577 } 584 }
578 585
  586 + private void initEndTipDialog() {
  587 + endTipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  588 + @Override
  589 + public void onClick(TipDialog dialog) {
  590 + dialog.dismiss();
  591 + }
  592 + });
  593 + endTipDialog.setCancelable(false);
  594 + endTipDialog.setCanceledOnTouchOutside(false);
  595 + }
  596 +
579 /** 597 /**
580 * 暂停按钮 598 * 暂停按钮
581 */ 599 */
@@ -641,18 +659,18 @@ public class RunMainFragmentView implements MvpView { @@ -641,18 +659,18 @@ public class RunMainFragmentView implements MvpView {
641 Log.e(TAG, "setSQLPauseTime: "); 659 Log.e(TAG, "setSQLPauseTime: ");
642 // if (needWriteDataFlag) { 660 // if (needWriteDataFlag) {
643 //将当前计时器时间戳写入数据库 661 //将当前计时器时间戳写入数据库
644 - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), id);  
645 - if (userStepEntity != null) {  
646 - userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());  
647 - //设置当前暂停的时间戳  
648 - userStepEntity.setRecordTime(SystemClock.elapsedRealtime());  
649 - //设置当前用户暂停的时间戳  
650 - userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());  
651 - //设置暂停次数  
652 - userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1);  
653 - //更新数据  
654 - StepUtil.updateStepData(fragment.getActivity(), userStepEntity);  
655 - } 662 + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), id);
  663 + if (userStepEntity != null) {
  664 + userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());
  665 + //设置当前暂停的时间戳
  666 + userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
  667 + //设置当前用户暂停的时间戳
  668 + userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());
  669 + //设置暂停次数
  670 + userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1);
  671 + //更新数据
  672 + StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
  673 + }
656 // } 674 // }
657 } 675 }
658 676
@@ -785,7 +803,7 @@ public class RunMainFragmentView implements MvpView { @@ -785,7 +803,7 @@ public class RunMainFragmentView implements MvpView {
785 LatLng current = new LatLng(location.getLatitude(), location.getLongitude()); 803 LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
786 if (null != current) { 804 if (null != current) {
787 //开始比较数据 805 //开始比较数据
788 - double distance = DistanceUtil.getDistance(current, endLatLng); 806 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
789 if (distance < Constant.LOCA_END_POINT_ACCURACY) { 807 if (distance < Constant.LOCA_END_POINT_ACCURACY) {
790 //设置数据 808 //设置数据
791 if (userStepEntity != null) { 809 if (userStepEntity != null) {
@@ -800,25 +818,7 @@ public class RunMainFragmentView implements MvpView { @@ -800,25 +818,7 @@ public class RunMainFragmentView implements MvpView {
800 isfirstEndTip = false; 818 isfirstEndTip = false;
801 } 819 }
802 //进行提示 820 //进行提示
803 - if (null == tipDialog) {  
804 - ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");  
805 - if (mVibrator != null) {  
806 - //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,  
807 - //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始  
808 - mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);  
809 - }  
810 - tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {  
811 - @Override  
812 - public void onClick(TipDialog dialog) {  
813 - dialog.dismiss();  
814 - }  
815 - });  
816 - tipDialog.setCancelable(false);  
817 - tipDialog.setCanceledOnTouchOutside(false);  
818 - }  
819 - if (!tipDialog.isShowing()) {  
820 - tipDialog.show();  
821 - } 821 + showEndTipDialog();
822 } 822 }
823 } 823 }
824 } 824 }
@@ -826,23 +826,57 @@ public class RunMainFragmentView implements MvpView { @@ -826,23 +826,57 @@ public class RunMainFragmentView implements MvpView {
826 826
827 } 827 }
828 828
  829 + public void showEndTipDialog() {
  830 + if (null == getContext()) {
  831 + return;
  832 + }
  833 + //进行提示
  834 + if (null != endTipDialog && !endTipDialog.isShowing()) {
  835 + endTipDialog.show();
  836 + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");
  837 + if (mVibrator != null) {
  838 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  839 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  840 + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);
  841 + }
  842 + }
  843 + }
  844 +
829 /** 845 /**
830 * 设置停止状态标志位 846 * 设置停止状态标志位
831 */ 847 */
832 private void setStopStartFlag() { 848 private void setStopStartFlag() {
833 CommonInfo.setTsRunBaiduTraceService(getContext(), false); 849 CommonInfo.setTsRunBaiduTraceService(getContext(), false);
834 CommonInfo.setIsRunKeepAliveService(getContext(), false); 850 CommonInfo.setIsRunKeepAliveService(getContext(), false);
  851 + CommonInfo.setIsRunStepService(getContext(), false);
835 CommonInfo.setIsWriteUserStep(getContext(), false); 852 CommonInfo.setIsWriteUserStep(getContext(), false);
836 if (StepService.mClient != null) { 853 if (StepService.mClient != null) {
837 StepService.mClient.stopGather(StepService.traceListener); 854 StepService.mClient.stopGather(StepService.traceListener);
838 // StepService.CURRENT_STEP = 0; 855 // StepService.CURRENT_STEP = 0;
839 } 856 }
  857 +// fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
  858 + }
  859 +
  860 + /**
  861 + * 停止计步服务
  862 + */
  863 + private void stopRunService() {
  864 + CommonInfo.setTsRunBaiduTraceService(getContext(), false);
  865 + CommonInfo.setIsRunKeepAliveService(getContext(), false);
  866 + CommonInfo.setIsRunStepService(getContext(), false);
  867 + CommonInfo.setIsWriteUserStep(getContext(), false);
  868 + if (StepService.mClient != null) {
  869 + StepService.mClient.stopGather(StepService.traceListener);
  870 + }
840 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 871 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
  872 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), KeepLiveService.class));
  873 +
841 } 874 }
842 875
843 public void onDestroy() { 876 public void onDestroy() {
844 if (mLocClient != null) { 877 if (mLocClient != null) {
845 mLocClient.stop(); 878 mLocClient.stop();
  879 + mLocClient = null;
846 } 880 }
847 } 881 }
848 882
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -591,8 +591,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -591,8 +591,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
591 CommonInfo.resetRace(getContext()); 591 CommonInfo.resetRace(getContext());
592 dialog.dismiss(); 592 dialog.dismiss();
593 //重置按钮 593 //重置按钮
594 - fragment.binding.tvRunNow.setText("立即开始");  
595 - fragment.binding.rlScrollViewStartBtn.setTag(BTN_START_RACE); 594 + if (null != runRaceDetailInfo) {
  595 + initStartBtnState(runRaceDetailInfo);
  596 + }
596 } 597 }
597 }, "是", new SelectDialog.DialogInterface() { 598 }, "是", new SelectDialog.DialogInterface() {
598 @Override 599 @Override
@@ -620,8 +621,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -620,8 +621,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
620 //清除数据 621 //清除数据
621 CommonInfo.resetRace(getContext()); 622 CommonInfo.resetRace(getContext());
622 //更改当前按钮 623 //更改当前按钮
623 - fragment.binding.tvRunNow.setText("立即开始");  
624 - fragment.binding.rlScrollViewStartBtn.setTag(BTN_START_RACE); 624 + if (null != runRaceDetailInfo) {
  625 + initStartBtnState(runRaceDetailInfo);
  626 + }
625 627
626 } 628 }
627 }, "是", new SelectDialog.DialogInterface() { 629 }, "是", new SelectDialog.DialogInterface() {
@@ -743,11 +745,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -743,11 +745,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
743 private void stopStepService() { 745 private void stopStepService() {
744 CommonInfo.setTsRunBaiduTraceService(getContext(), false); 746 CommonInfo.setTsRunBaiduTraceService(getContext(), false);
745 CommonInfo.setIsRunKeepAliveService(getContext(), false); 747 CommonInfo.setIsRunKeepAliveService(getContext(), false);
  748 + CommonInfo.setIsRunStepService(getContext(), false);
746 CommonInfo.setIsWriteUserStep(getContext(), false); 749 CommonInfo.setIsWriteUserStep(getContext(), false);
747 CommonInfo.setIsFirstStepSendTraceTip(getContext(), true); 750 CommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
748 if (StepService.mClient != null) { 751 if (StepService.mClient != null) {
749 StepService.mClient.stopGather(StepService.traceListener); 752 StepService.mClient.stopGather(StepService.traceListener);
750 } 753 }
  754 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), KeepLiveService.class));
751 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 755 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
752 } 756 }
753 757
@@ -808,7 +812,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -808,7 +812,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
808 //可选,设置是否需要设备方向结果 812 //可选,设置是否需要设备方向结果
809 option.setNeedDeviceDirect(false); 813 option.setNeedDeviceDirect(false);
810 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 814 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
811 - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); 815 +// option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
812 mLocClient.setLocOption(option); 816 mLocClient.setLocOption(option);
813 mLocClient.start(); 817 mLocClient.start();
814 //设置地图加载完毕监听 818 //设置地图加载完毕监听
@@ -1100,9 +1104,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -1100,9 +1104,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1100 if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { 1104 if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) {
1101 Log.e(TAG, "小于9小时"); 1105 Log.e(TAG, "小于9小时");
1102 fragment.binding.tvRunNow.setText("继续运动"); 1106 fragment.binding.tvRunNow.setText("继续运动");
  1107 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.green_round));
1103 fragment.binding.rlScrollViewStartBtn.setTag(BTN_CONTINUE_RACE); 1108 fragment.binding.rlScrollViewStartBtn.setTag(BTN_CONTINUE_RACE);
1104 } else { 1109 } else {
1105 Log.e(TAG, "大于9小时"); 1110 Log.e(TAG, "大于9小时");
  1111 + //停止服务
  1112 + stopStepService();
1106 //重置数据 1113 //重置数据
1107 CommonInfo.resetRace(getContext()); 1114 CommonInfo.resetRace(getContext());
1108 //清空数据库 1115 //清空数据库
@@ -1203,7 +1210,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -1203,7 +1210,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1203 if (isFirstLoc) { 1210 if (isFirstLoc) {
1204 isFirstLoc = false; 1211 isFirstLoc = false;
1205 if (location.getRadius() > Constant.LOCA_ACCURACY) { 1212 if (location.getRadius() > Constant.LOCA_ACCURACY) {
1206 - Toast.makeText(getContext(), "当前定位误差为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); 1213 + Toast.makeText(getContext(), "当前定位误差为:" + (int) location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
1207 } 1214 }
1208 1215
1209 } else { 1216 } else {
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
@@ -89,7 +89,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -89,7 +89,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
89 private List<LatLng> currentPoints; 89 private List<LatLng> currentPoints;
90 private LatLng endLatLng;//终点坐标 90 private LatLng endLatLng;//终点坐标
91 private UserStepEntity userStepEntity; 91 private UserStepEntity userStepEntity;
92 - private TipDialog tipDialog; 92 + private TipDialog endTipDialog;
93 //创建震动服务对象 93 //创建震动服务对象
94 private Vibrator mVibrator; 94 private Vibrator mVibrator;
95 private boolean isfirstEndTip = true;//是否是第一次提示到达终点 95 private boolean isfirstEndTip = true;//是否是第一次提示到达终点
@@ -106,6 +106,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -106,6 +106,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
106 if (getContext() == null) { 106 if (getContext() == null) {
107 return; 107 return;
108 } 108 }
  109 + initEndTipDialog();
109 //获取手机震动服务 110 //获取手机震动服务
110 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); 111 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE);
111 userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext())); 112 userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
@@ -213,7 +214,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -213,7 +214,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
213 //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔 214 //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔
214 //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔 215 //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔
215 //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW 216 //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW
216 - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); 217 +// option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
217 //可选,定位SDK内部是一个service,并放到了独立进程。 218 //可选,定位SDK内部是一个service,并放到了独立进程。
218 //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) 219 //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)
219 option.setIgnoreKillProcess(true); 220 option.setIgnoreKillProcess(true);
@@ -318,7 +319,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -318,7 +319,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
318 if (isFirstLoc) { 319 if (isFirstLoc) {
319 isFirstLoc = false; 320 isFirstLoc = false;
320 if (location.getRadius() > Constant.LOCA_ACCURACY) { 321 if (location.getRadius() > Constant.LOCA_ACCURACY) {
321 - Toast.makeText(getContext(), "当前定位误差为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); 322 + Toast.makeText(getContext(), "当前定位误差为:" + (int)location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
322 } 323 }
323 324
324 325
@@ -345,7 +346,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -345,7 +346,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
345 LatLng current = new LatLng(location.getLatitude(), location.getLongitude()); 346 LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
346 if (null != current) { 347 if (null != current) {
347 //开始比较数据 348 //开始比较数据
348 - double distance = DistanceUtil.getDistance(current, endLatLng); 349 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
349 if (distance < Constant.LOCA_END_POINT_ACCURACY) { 350 if (distance < Constant.LOCA_END_POINT_ACCURACY) {
350 //设置数据 351 //设置数据
351 if (userStepEntity != null) { 352 if (userStepEntity != null) {
@@ -361,26 +362,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -361,26 +362,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
361 isfirstEndTip = false; 362 isfirstEndTip = false;
362 } 363 }
363 //进行提示 364 //进行提示
364 - if (null == tipDialog) {  
365 - ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");  
366 - if (mVibrator != null) {  
367 - //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,  
368 - //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始  
369 - mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);  
370 - }  
371 -  
372 - tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {  
373 - @Override  
374 - public void onClick(TipDialog dialog) {  
375 - dialog.dismiss();  
376 - }  
377 - });  
378 - tipDialog.setCancelable(false);  
379 - tipDialog.setCanceledOnTouchOutside(false);  
380 - }  
381 - if (!tipDialog.isShowing()) {  
382 - tipDialog.show();  
383 - } 365 + showEndTipDialog();
384 } 366 }
385 } 367 }
386 } 368 }
@@ -430,6 +412,32 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -430,6 +412,32 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
430 } 412 }
431 } 413 }
432 414
  415 + private void initEndTipDialog() {
  416 + endTipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  417 + @Override
  418 + public void onClick(TipDialog dialog) {
  419 + dialog.dismiss();
  420 + }
  421 + });
  422 + endTipDialog.setCancelable(false);
  423 + endTipDialog.setCanceledOnTouchOutside(false);
  424 + }
  425 +
  426 + public void showEndTipDialog() {
  427 + if (null == getContext()) {
  428 + return;
  429 + }
  430 + //进行提示
  431 + if (null != endTipDialog && !endTipDialog.isShowing()) {
  432 + endTipDialog.show();
  433 + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");
  434 + if (mVibrator != null) {
  435 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  436 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  437 + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);
  438 + }
  439 + }
  440 + }
433 441
434 /** 442 /**
435 * 同步计时器 443 * 同步计时器
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
@@ -24,6 +24,7 @@ public class Constant { @@ -24,6 +24,7 @@ public class Constant {
24 public static final int COLL_SERVICE_STEP_COUNT_ONRESUME = 15;//运营从后台回到前台,更新步数 24 public static final int COLL_SERVICE_STEP_COUNT_ONRESUME = 15;//运营从后台回到前台,更新步数
25 public static final int UPDATA_COLL_TRACE_LIST = 16;//更新轨迹列表 25 public static final int UPDATA_COLL_TRACE_LIST = 16;//更新轨迹列表
26 public static final int UPDATE_RACE_STATE_BTN = 17;//更新赛事详情页按钮数据 26 public static final int UPDATE_RACE_STATE_BTN = 17;//更新赛事详情页按钮数据
  27 + public static final int ARRIVE_END_POINT = 18;//到达终点附近
27 /*************************************用户其他值,非标志位************************************************************/ 28 /*************************************用户其他值,非标志位************************************************************/
28 public static long SERVICE_ID = 0;//公司账号 29 public static long SERVICE_ID = 0;//公司账号
29 // public static final long SERVICE_ID = 213553; 30 // public static final long SERVICE_ID = 213553;
@@ -31,7 +32,7 @@ public class Constant { @@ -31,7 +32,7 @@ public class Constant {
31 public static final int GATHER_INTERVAL = 2;//位置采集周期 32 public static final int GATHER_INTERVAL = 2;//位置采集周期
32 public static final int PACK_INTERVAL = 10;//位置采集周期 33 public static final int PACK_INTERVAL = 10;//位置采集周期
33 public static final int VIBRATOR_DELAY_TIME = 100;//震动等待时间(ms) 34 public static final int VIBRATOR_DELAY_TIME = 100;//震动等待时间(ms)
34 - public static final int VIBRATOR_RUN_TIME = 1000;//震动执行时间(ms) 35 + public static final int VIBRATOR_RUN_TIME = 2000;//震动执行时间(ms)
35 public static final int VIBRATOR_REPEAT_TIME = -1;//震动重复次数(-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始) 36 public static final int VIBRATOR_REPEAT_TIME = -1;//震动重复次数(-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始)
36 /*****************************************运营工具其他值,非标志位****************************************************/ 37 /*****************************************运营工具其他值,非标志位****************************************************/
37 public static final double PASS_RATE = 0.7;//通过率70% 38 public static final double PASS_RATE = 0.7;//通过率70%
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/receivers/ServiceReceiver.java
@@ -23,6 +23,7 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -23,6 +23,7 @@ public class ServiceReceiver extends BroadcastReceiver {
23 //唤醒锁 23 //唤醒锁
24 private PowerManager.WakeLock wakeLock = null; 24 private PowerManager.WakeLock wakeLock = null;
25 private final String TAG = "ServiceReceiver"; 25 private final String TAG = "ServiceReceiver";
  26 + private AudioManager audioManager;
26 27
27 public ServiceReceiver() { 28 public ServiceReceiver() {
28 29
@@ -105,7 +106,9 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -105,7 +106,9 @@ public class ServiceReceiver extends BroadcastReceiver {
105 106
106 private void initSound(Context context) { 107 private void initSound(Context context) {
107 try { 108 try {
108 - AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); 109 + if (null==audioManager){
  110 + audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
  111 + }
109 int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 112 int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
110 if (0 == currentVolume) { 113 if (0 == currentVolume) {
111 audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND); 114 audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java
@@ -43,7 +43,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -43,7 +43,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
43 private NotificationManager mNM; 43 private NotificationManager mNM;
44 private Notification notification = null; 44 private Notification notification = null;
45 //是否在后台运行 45 //是否在后台运行
46 - public static boolean isKeepService = true; 46 + public static boolean isKeepService = false;
47 public static KeepLiveService instance; 47 public static KeepLiveService instance;
48 private int startId; 48 private int startId;
49 private final String TAG = "KeepLiveService"; 49 private final String TAG = "KeepLiveService";
@@ -52,6 +52,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -52,6 +52,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
52 private boolean isRegisterReceiver = false; 52 private boolean isRegisterReceiver = false;
53 private boolean isStartForeground = false; 53 private boolean isStartForeground = false;
54 private final int NOTIFICATION_ID = 1; 54 private final int NOTIFICATION_ID = 1;
  55 +
55 public KeepLiveService() { 56 public KeepLiveService() {
56 } 57 }
57 58
@@ -159,13 +160,25 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -159,13 +160,25 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
159 Log.e("isRun onStartCommand", "" + isRun); 160 Log.e("isRun onStartCommand", "" + isRun);
160 161
161 if (isRun) { 162 if (isRun) {
162 - if (runnable != null) {  
163 - handler.postDelayed(runnable, 5000);  
164 - } 163 +// if (runnable != null) {
  164 +// handler.postDelayed(runnable, 5000);
  165 +// }
165 showHideForegroundNotification(); 166 showHideForegroundNotification();
166 // startService(new Intent(getApplicationContext(), HideKeepTipService.class)); 167 // startService(new Intent(getApplicationContext(), HideKeepTipService.class));
167 // Log.e(TAG, "启动HideKeepTipService"); 168 // Log.e(TAG, "启动HideKeepTipService");
168 startPlaySong(); 169 startPlaySong();
  170 + } else {
  171 + try {
  172 + if (myReceiver != null && isRegisterReceiver) {
  173 + unregisterReceiver(myReceiver);
  174 + }
  175 + } catch (Exception e) {
  176 + Log.e(TAG, "run: ");
  177 + }
  178 + stopPlaySong();
  179 + if (isStartForeground) {
  180 + stopForeground(true);
  181 + }
169 } 182 }
170 return START_STICKY; 183 return START_STICKY;
171 } 184 }
@@ -224,9 +237,9 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -224,9 +237,9 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
224 // .setContentText("正在计步,请勿关闭") 237 // .setContentText("正在计步,请勿关闭")
225 // .setSound(null) 238 // .setSound(null)
226 // .build(); 239 // .build();
227 - Intent notificationIntent = new Intent(this, PedometerMainActivity.class); 240 +// Intent notificationIntent = new Intent(this, PedometerMainActivity.class);
228 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 241 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
229 - .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) 242 +// .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
230 .setSmallIcon(R.mipmap.ic_launcher) 243 .setSmallIcon(R.mipmap.ic_launcher)
231 // .setCustomContentView(remoteViews) 244 // .setCustomContentView(remoteViews)
232 .setContentTitle(getResources().getString(R.string.app_name)) 245 .setContentTitle(getResources().getString(R.string.app_name))
@@ -237,7 +250,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -237,7 +250,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
237 .build(); 250 .build();
238 // 0 隐藏前台服务通知 251 // 0 隐藏前台服务通知
239 startForeground(NOTIFICATION_ID, notification); 252 startForeground(NOTIFICATION_ID, notification);
240 - isStartForeground=true; 253 + isStartForeground = true;
241 } 254 }
242 255
243 @Override 256 @Override
@@ -295,11 +308,11 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -295,11 +308,11 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
295 if (isRun) { 308 if (isRun) {
296 Log.e(TAG, "重新播放"); 309 Log.e(TAG, "重新播放");
297 mediaPlayer.start(); 310 mediaPlayer.start();
298 - Intent intent = new Intent("com.cnlive.strike.receiver.CollServiceReceiver");  
299 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {  
300 - intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.CollServiceReceiver"));//高版本Android发送广播需要加这句  
301 - }  
302 - sendBroadcast(intent); 311 +// Intent intent = new Intent("com.cnlive.strike.receiver.CollServiceReceiver");
  312 +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  313 +// intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.CollServiceReceiver"));//高版本Android发送广播需要加这句
  314 +// }
  315 +// sendBroadcast(intent);
303 } else { 316 } else {
304 Log.e(TAG, "停止重新播放"); 317 Log.e(TAG, "停止重新播放");
305 stopPlaySong(); 318 stopPlaySong();
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -26,6 +26,15 @@ import android.util.Log; @@ -26,6 +26,15 @@ import android.util.Log;
26 import android.widget.RemoteViews; 26 import android.widget.RemoteViews;
27 import android.widget.Toast; 27 import android.widget.Toast;
28 28
  29 +import com.baidu.location.BDAbstractLocationListener;
  30 +import com.baidu.location.BDLocation;
  31 +import com.baidu.location.LocationClient;
  32 +import com.baidu.location.LocationClientOption;
  33 +import com.baidu.mapapi.map.MapStatus;
  34 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
  35 +import com.baidu.mapapi.map.MyLocationData;
  36 +import com.baidu.mapapi.model.LatLng;
  37 +import com.baidu.mapapi.utils.DistanceUtil;
29 import com.baidu.trace.LBSTraceClient; 38 import com.baidu.trace.LBSTraceClient;
30 import com.baidu.trace.Trace; 39 import com.baidu.trace.Trace;
31 import com.baidu.trace.api.fence.AddMonitoredPersonResponse; 40 import com.baidu.trace.api.fence.AddMonitoredPersonResponse;
@@ -52,6 +61,7 @@ import com.baidu.trace.model.OnTraceListener; @@ -52,6 +61,7 @@ import com.baidu.trace.model.OnTraceListener;
52 import com.baidu.trace.model.PushMessage; 61 import com.baidu.trace.model.PushMessage;
53 import com.baidu.trace.model.StatusCodes; 62 import com.baidu.trace.model.StatusCodes;
54 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; 63 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  64 +import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView;
55 import com.cnlive.moudle.pedometer.model.Constant; 65 import com.cnlive.moudle.pedometer.model.Constant;
56 import com.cnlive.moudle.pedometer.model.MessageEvent; 66 import com.cnlive.moudle.pedometer.model.MessageEvent;
57 import com.cnlive.moudle.pedometer.model.step.StepCount; 67 import com.cnlive.moudle.pedometer.model.step.StepCount;
@@ -59,6 +69,7 @@ import com.cnlive.moudle.pedometer.model.step.StepValuePassListener; @@ -59,6 +69,7 @@ import com.cnlive.moudle.pedometer.model.step.StepValuePassListener;
59 import com.cnlive.moudle.pedometer.sql.db.DbCore; 69 import com.cnlive.moudle.pedometer.sql.db.DbCore;
60 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; 70 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
61 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; 71 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
  72 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
62 import com.cnlive.moudle.pedometer.utils.ServiceUtils; 73 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
63 import com.cnlive.moudle.pedometer.utils.StepUtil; 74 import com.cnlive.moudle.pedometer.utils.StepUtil;
64 import com.cnlive.moudle.pedometer.utils.TimeUtil; 75 import com.cnlive.moudle.pedometer.utils.TimeUtil;
@@ -141,7 +152,8 @@ public class StepService extends Service implements SensorEventListener { @@ -141,7 +152,8 @@ public class StepService extends Service implements SensorEventListener {
141 private static boolean pauseFlag;//是否暂停 152 private static boolean pauseFlag;//是否暂停
142 private static int speedCurrentStep;//用于检测速度步数 153 private static int speedCurrentStep;//用于检测速度步数
143 private boolean updateSpeedStepFlag;//是否是已经更新速度 154 private boolean updateSpeedStepFlag;//是否是已经更新速度
144 - 155 + private LatLng endLatLng;//终点坐标
  156 + private UserStepEntity userStepEntity;
145 /****************************************************鹰眼轨迹相关************************************************/ 157 /****************************************************鹰眼轨迹相关************************************************/
146 /** 158 /**
147 * 轨迹服务监听器 159 * 轨迹服务监听器
@@ -163,6 +175,10 @@ public class StepService extends Service implements SensorEventListener { @@ -163,6 +175,10 @@ public class StepService extends Service implements SensorEventListener {
163 * 轨迹服务 175 * 轨迹服务
164 */ 176 */
165 public static Trace mTrace = null; 177 public static Trace mTrace = null;
  178 + //定位
  179 + public MyLocationListenner myListener = new MyLocationListenner();
  180 + private LocationClient mLocClient;
  181 + private boolean isHasSendEndTip = true;//是否发送到达终点提示
166 182
167 public StepService() { 183 public StepService() {
168 184
@@ -506,7 +522,7 @@ public class StepService extends Service implements SensorEventListener { @@ -506,7 +522,7 @@ public class StepService extends Service implements SensorEventListener {
506 Log.e(TAG, "onListMonitoredPersonCallback: "); 522 Log.e(TAG, "onListMonitoredPersonCallback: ");
507 } 523 }
508 }; 524 };
509 - if (userStepEntity != null &&!TextUtils.isEmpty(userStepEntity.getFenceId())) { 525 + if (userStepEntity != null && !TextUtils.isEmpty(userStepEntity.getFenceId())) {
510 List<Long> fenids = new ArrayList<>(); 526 List<Long> fenids = new ArrayList<>();
511 fenids.add(Long.parseLong(userStepEntity.getFenceId())); 527 fenids.add(Long.parseLong(userStepEntity.getFenceId()));
512 MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, 528 MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG,
@@ -553,6 +569,7 @@ public class StepService extends Service implements SensorEventListener { @@ -553,6 +569,7 @@ public class StepService extends Service implements SensorEventListener {
553 } 569 }
554 }).start(); 570 }).start();
555 startTimeCount(); 571 startTimeCount();
  572 + initLocationClient();
556 } else { 573 } else {
557 EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, "")); 574 EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, ""));
558 } 575 }
@@ -613,9 +630,9 @@ public class StepService extends Service implements SensorEventListener { @@ -613,9 +630,9 @@ public class StepService extends Service implements SensorEventListener {
613 } 630 }
614 631
615 632
616 - Intent notificationIntent = new Intent(this, PedometerMainActivity.class); 633 +// Intent notificationIntent = new Intent(this, PedometerMainActivity.class);
617 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 634 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
618 - .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) 635 +// .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
619 .setSmallIcon(R.mipmap.ic_launcher) 636 .setSmallIcon(R.mipmap.ic_launcher)
620 // .setCustomContentView(remoteViews) 637 // .setCustomContentView(remoteViews)
621 .setContentTitle(getResources().getString(R.string.app_name)) 638 .setContentTitle(getResources().getString(R.string.app_name))
@@ -640,6 +657,10 @@ public class StepService extends Service implements SensorEventListener { @@ -640,6 +657,10 @@ public class StepService extends Service implements SensorEventListener {
640 @Override 657 @Override
641 public void onDestroy() { 658 public void onDestroy() {
642 super.onDestroy(); 659 super.onDestroy();
  660 + if (null != mLocClient) {
  661 + mLocClient.stop();
  662 + mLocClient = null;
  663 + }
643 //取消前台进程 664 //取消前台进程
644 stopForeground(true); 665 stopForeground(true);
645 if (mBatInfoReceiver != null) { 666 if (mBatInfoReceiver != null) {
@@ -856,12 +877,12 @@ public class StepService extends Service implements SensorEventListener { @@ -856,12 +877,12 @@ public class StepService extends Service implements SensorEventListener {
856 } else if (Intent.ACTION_DATE_CHANGED.equals(action)) {//日期变化步数重置为0 877 } else if (Intent.ACTION_DATE_CHANGED.equals(action)) {//日期变化步数重置为0
857 // Logger.d("重置步数" + StepDcretor.CURRENT_STEP); 878 // Logger.d("重置步数" + StepDcretor.CURRENT_STEP);
858 save(); 879 save();
859 - isNewDay(); 880 +// isNewDay();
860 } else if (Intent.ACTION_TIME_CHANGED.equals(action)) { 881 } else if (Intent.ACTION_TIME_CHANGED.equals(action)) {
861 //时间变化步数重置为0 882 //时间变化步数重置为0
862 // isCall(); 883 // isCall();
863 save(); 884 save();
864 - isNewDay(); 885 +// isNewDay();
865 } else if (Intent.ACTION_TIME_TICK.equals(action)) {//日期变化步数重置为0 886 } else if (Intent.ACTION_TIME_TICK.equals(action)) {//日期变化步数重置为0
866 // isCall(); 887 // isCall();
867 // Logger.d("重置步数" + StepDcretor.CURRENT_STEP); 888 // Logger.d("重置步数" + StepDcretor.CURRENT_STEP);
@@ -890,10 +911,10 @@ public class StepService extends Service implements SensorEventListener { @@ -890,10 +911,10 @@ public class StepService extends Service implements SensorEventListener {
890 * 监听晚上0点变化初始化数据 911 * 监听晚上0点变化初始化数据
891 */ 912 */
892 private void isNewDay() { 913 private void isNewDay() {
893 - String time = "00:00";  
894 - if (time.equals(new SimpleDateFormat("HH:mm").format(new Date())) || !CURRENT_DATE.equals(getTodayDate())) {  
895 - initTodayData(userId);  
896 - } 914 +// String time = "00:00";
  915 +// if (time.equals(new SimpleDateFormat("HH:mm").format(new Date())) || !CURRENT_DATE.equals(getTodayDate())) {
  916 +// initTodayData(userId);
  917 +// }
897 } 918 }
898 919
899 // /** 920 // /**
@@ -1203,5 +1224,97 @@ public class StepService extends Service implements SensorEventListener { @@ -1203,5 +1224,97 @@ public class StepService extends Service implements SensorEventListener {
1203 return String.format("%02d:%02d:%02d", h, m, s); 1224 return String.format("%02d:%02d:%02d", h, m, s);
1204 } 1225 }
1205 1226
  1227 + private void initLocationClient() {
  1228 + if (null == mLocClient) {
  1229 + // 定位初始化
  1230 + mLocClient = new LocationClient(getApplicationContext());
  1231 + mLocClient.registerLocationListener(myListener);
  1232 + }
  1233 + LocationClientOption option = new LocationClientOption();
  1234 + option.setOpenGps(true); // 打开gps
  1235 + //可选,设置返回经纬度坐标类型,默认GCJ02
  1236 + //GCJ02:国测局坐标;
  1237 + //BD09ll:百度经纬度坐标;
  1238 + //BD09:百度墨卡托坐标;
  1239 + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标
  1240 + option.setCoorType("gcj02"); // 设置坐标类型
  1241 + //可选,默认false,设置是否开启Gps定位
  1242 + option.setOpenGps(true);
  1243 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者
  1244 + option.setOpenAutoNotifyMode();
  1245 + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  1246 + //LocationMode.Hight_Accuracy:高精度;
  1247 + //LocationMode. Battery_Saving:低功耗;
  1248 + //LocationMode. Device_Sensors:仅使用设备;
  1249 + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
  1250 + //可选,设置是否需要地址信息,默认不需要
  1251 + option.setIsNeedAddress(false);
  1252 + //可选,设置是否需要地址描述
  1253 + option.setIsNeedLocationDescribe(false);
  1254 + //可选,设置是否需要设备方向结果
  1255 + option.setNeedDeviceDirect(false);
  1256 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
  1257 + //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔
  1258 + //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔
  1259 + //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW
  1260 + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
  1261 + //可选,定位SDK内部是一个service,并放到了独立进程。
  1262 + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)
  1263 + option.setIgnoreKillProcess(true);
  1264 + mLocClient.setLocOption(option);
  1265 + mLocClient.start();
  1266 + }
  1267 +
  1268 + /**
  1269 + * //设置定位监听器,获取到用户当前位置 杨帅
  1270 + * 定位SDK监听函数
  1271 + */
  1272 + public class MyLocationListenner extends BDAbstractLocationListener {
1206 1273
  1274 + @Override
  1275 + public void onReceiveLocation(BDLocation location) {
  1276 + // map view 销毁后不在处理新接收的位置
  1277 + if (location == null || null == getApplicationContext()) {
  1278 + return;
  1279 + }
  1280 + //进行精度过滤
  1281 +// if (location.getRadius() > Constant.LOCA_ACCURACY) {
  1282 +// return;
  1283 +// }
  1284 + //进行数据比较(先看看数据库是否有数据)
  1285 + if (null == endLatLng) {
  1286 + userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
  1287 + if (null != userStepEntity) {
  1288 + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  1289 + endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class);
  1290 + }
  1291 + }
  1292 + }
  1293 + //开始比较数据
  1294 + if (null != endLatLng) {
  1295 + LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
  1296 + if (null != current) {
  1297 + //开始比较数据
  1298 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
  1299 + if (distance < Constant.LOCA_END_POINT_ACCURACY) {
  1300 + if (isHasSendEndTip) {
  1301 + isHasSendEndTip = false;
  1302 + Log.e(TAG, "onReceiveLocation: 到达" );
  1303 + //发送到达终点通知
  1304 + EventBus.getDefault().post(new MessageEvent(Constant.ARRIVE_END_POINT, ""));
  1305 + }
  1306 + if (null == userStepEntity) {
  1307 + userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
  1308 + }
  1309 + //设置数据
  1310 + if (userStepEntity != null) {
  1311 + userStepEntity.setIsArriveEndPoint(true);
  1312 + //更新数据
  1313 + StepUtil.updateStepData(getApplicationContext(), userStepEntity);
  1314 + }
  1315 + }
  1316 + }
  1317 + }
  1318 + }
  1319 + }
1207 } 1320 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/db/DbCore.java
@@ -62,8 +62,9 @@ public class DbCore { @@ -62,8 +62,9 @@ public class DbCore {
62 if (daoMaster == null) { 62 if (daoMaster == null) {
63 daoMaster = getDaoMaster(); 63 daoMaster = getDaoMaster();
64 } 64 }
65 - //不使用缓存  
66 - daoSession = daoMaster.newSession(IdentityScopeType.None); 65 +// //不使用缓存
  66 +// daoSession = daoMaster.newSession(IdentityScopeType.None);
  67 + daoSession = daoMaster.newSession();
67 } 68 }
68 return daoSession; 69 return daoSession;
69 } 70 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RegistrationInfoFragment.java
@@ -5,7 +5,9 @@ import android.os.Bundle; @@ -5,7 +5,9 @@ import android.os.Bundle;
5 import android.support.annotation.NonNull; 5 import android.support.annotation.NonNull;
6 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
  8 +import android.util.Log;
8 import android.view.View; 9 import android.view.View;
  10 +import android.widget.Toast;
9 11
10 import com.baidu.trace.LBSTraceClient; 12 import com.baidu.trace.LBSTraceClient;
11 import com.baidu.trace.Trace; 13 import com.baidu.trace.Trace;
@@ -30,6 +32,7 @@ import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; @@ -30,6 +32,7 @@ import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
30 import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter; 32 import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter;
31 import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView; 33 import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView;
32 import com.cnlive.moudle.pedometer.model.Constant; 34 import com.cnlive.moudle.pedometer.model.Constant;
  35 +import com.cnlive.moudle.pedometer.utils.NetUtil;
33 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; 36 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
34 import com.example.moudle_pedometer.R; 37 import com.example.moudle_pedometer.R;
35 import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; 38 import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding;
@@ -69,7 +72,14 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -69,7 +72,14 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
69 72
70 public void commitInfo() { 73 public void commitInfo() {
71 if (!TextUtils.isEmpty(fenceId)) { 74 if (!TextUtils.isEmpty(fenceId)) {
72 - addMonitorToFence((int) (Double.parseDouble(fenceId))); 75 + if (NetUtil.isNetworkConnected(getActivity())) {
  76 + addMonitorToFence((int) (Double.parseDouble(fenceId)));
  77 + } else {
  78 + if (null != getMvpView()) {
  79 + getMvpView().allowClickRegistBtn();
  80 + }
  81 + AlertUtil.showDeftToast(getActivity(), "无法连接网络");
  82 + }
73 } 83 }
74 } 84 }
75 85
@@ -79,7 +89,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -79,7 +89,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
79 * @param fenceId 89 * @param fenceId
80 */ 90 */
81 public void addMonitorToFence(int fenceId) { 91 public void addMonitorToFence(int fenceId) {
82 - if (null!=getMvpView()){ 92 + if (null != getMvpView()) {
83 getMvpView().limitClickRegistBtn(); 93 getMvpView().limitClickRegistBtn();
84 } 94 }
85 if (null == getPresenter()) { 95 if (null == getPresenter()) {
@@ -148,7 +158,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -148,7 +158,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
148 binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(), 158 binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(),
149 binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim()); 159 binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim());
150 } else { 160 } else {
151 - if (null!=getMvpView()){ 161 + if (null != getMvpView()) {
152 getMvpView().allowClickRegistBtn(); 162 getMvpView().allowClickRegistBtn();
153 } 163 }
154 QMUITipDialogUtil.dismessDialog(); 164 QMUITipDialogUtil.dismessDialog();
@@ -180,6 +190,9 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -180,6 +190,9 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
180 @Override 190 @Override
181 public void onFailed(String msg) { 191 public void onFailed(String msg) {
182 QMUITipDialogUtil.dismessDialog(); 192 QMUITipDialogUtil.dismessDialog();
  193 + if (null != getMvpView()) {
  194 + getMvpView().allowClickRegistBtn();
  195 + }
183 AlertUtil.showDeftToast(getContext(), msg); 196 AlertUtil.showDeftToast(getContext(), msg);
184 } 197 }
185 198
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
@@ -214,6 +214,13 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr @@ -214,6 +214,13 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
214 tipDialog.show(); 214 tipDialog.show();
215 } 215 }
216 } 216 }
  217 + //到达终点
  218 + else if (messageEvent.getMessageType() == Constant.ARRIVE_END_POINT) {
  219 + if (null == getMvpView()) {
  220 + return;
  221 + }
  222 + getMvpView().showEndTipDialog();
  223 + }
217 } 224 }
218 225
219 @Override 226 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
@@ -217,6 +217,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run @@ -217,6 +217,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
217 tipDialog.show(); 217 tipDialog.show();
218 } 218 }
219 } 219 }
  220 + //到达终点
  221 + else if (messageEvent.getMessageType() == Constant.ARRIVE_END_POINT) {
  222 + if (null == getMvpView()) {
  223 + return;
  224 + }
  225 + getMvpView().showEndTipDialog();
  226 + }
220 } 227 }
221 228
222 private void initTipDialog() { 229 private void initTipDialog() {
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
@@ -69,75 +69,86 @@ public class MyMapUtil { @@ -69,75 +69,86 @@ public class MyMapUtil {
69 * @param geoCodeResult 69 * @param geoCodeResult
70 */ 70 */
71 public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) { 71 public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) {
72 - if (null == latLng) {  
73 - return;  
74 - }  
75 - if (null == mSearch) {  
76 - mSearch = GeoCoder.newInstance();  
77 - }  
78 - mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { 72 + try {
  73 + if (null == latLng) {
  74 + return;
  75 + }
  76 + if (null == mSearch) {
  77 + mSearch = GeoCoder.newInstance();
  78 + }
  79 + mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
79 80
80 - @Override  
81 - public void onGetGeoCodeResult(com.baidu.mapapi.search.geocode.GeoCodeResult geoCodeResult) { 81 + @Override
  82 + public void onGetGeoCodeResult(com.baidu.mapapi.search.geocode.GeoCodeResult geoCodeResult) {
82 83
83 - } 84 + }
84 85
85 - @Override  
86 - public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { 86 + @Override
  87 + public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
87 // Log.e(TAG, "status:" + reverseGeoCodeResult.status + ",error" + reverseGeoCodeResult.error); 88 // Log.e(TAG, "status:" + reverseGeoCodeResult.status + ",error" + reverseGeoCodeResult.error);
88 - //成功  
89 - if (0 == reverseGeoCodeResult.status) {  
90 - queryGeoCount = 0;  
91 - if (null != geoCodeResult) {  
92 - List<PoiInfo> pois = reverseGeoCodeResult.getPoiList();  
93 - if (null != pois && pois.size() > 0) {  
94 - if (!TextUtils.isEmpty(pois.get(0).name)) {  
95 - geoCodeResult.success(pois.get(0).name);  
96 - } else {  
97 - geoCodeResult.success(null);  
98 - }  
99 - } else {  
100 - //如果街道号或者街道为空  
101 - if ((null == reverseGeoCodeResult.getAddressDetail().street || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null == reverseGeoCodeResult.getAddressDetail().streetNumber || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) {  
102 - if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) {  
103 - geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription());  
104 - } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {  
105 - geoCodeResult.success(reverseGeoCodeResult.getAddress()); 89 + if (null == reverseGeoCodeResult) {
  90 + if (null != geoCodeResult) {
  91 + geoCodeResult.success(null);
  92 + }
  93 + }
  94 + //成功
  95 + if (0 == reverseGeoCodeResult.status) {
  96 + queryGeoCount = 0;
  97 + if (null != geoCodeResult) {
  98 + List<PoiInfo> pois = reverseGeoCodeResult.getPoiList();
  99 + if (null != pois && pois.size() > 0) {
  100 + if (!TextUtils.isEmpty(pois.get(0).name)) {
  101 + geoCodeResult.success(pois.get(0).name);
106 } else { 102 } else {
107 geoCodeResult.success(null); 103 geoCodeResult.success(null);
108 } 104 }
109 } else { 105 } else {
110 - if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {  
111 - geoCodeResult.success(reverseGeoCodeResult.getAddress()); 106 + //如果街道号或者街道为空
  107 + if ((null == reverseGeoCodeResult.getAddressDetail().street || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null == reverseGeoCodeResult.getAddressDetail().streetNumber || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) {
  108 + if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) {
  109 + geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription());
  110 + } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {
  111 + geoCodeResult.success(reverseGeoCodeResult.getAddress());
  112 + } else {
  113 + geoCodeResult.success(null);
  114 + }
112 } else { 115 } else {
113 - geoCodeResult.success(null); 116 + if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {
  117 + geoCodeResult.success(reverseGeoCodeResult.getAddress());
  118 + } else {
  119 + geoCodeResult.success(null);
  120 + }
114 } 121 }
115 } 122 }
116 } 123 }
  124 + } else if (104 == reverseGeoCodeResult.status) {
  125 + if (0 == queryGeoCount) {
  126 + queryGeoCount = 1;
  127 + new Handler().postDelayed(new Runnable() {
  128 + @Override
  129 + public void run() {
  130 + getGeoCoderResult(latLng, geoCodeResult);
  131 + }
  132 + }, 1000);
  133 + }
117 } 134 }
118 - } else if (104 == reverseGeoCodeResult.status) {  
119 - if (0 == queryGeoCount) {  
120 - queryGeoCount = 1;  
121 - new Handler().postDelayed(new Runnable() {  
122 - @Override  
123 - public void run() {  
124 - getGeoCoderResult(latLng, geoCodeResult);  
125 - }  
126 - }, 1000);  
127 - }  
128 - }  
129 - //失败  
130 - else {  
131 - queryGeoCount = 0;  
132 - if (null != geoCodeResult) {  
133 - geoCodeResult.success(null); 135 + //失败
  136 + else {
  137 + queryGeoCount = 0;
  138 + if (null != geoCodeResult) {
  139 + geoCodeResult.success(null);
  140 + }
134 } 141 }
135 } 142 }
  143 + });
  144 + mSearch.reverseGeoCode(new ReverseGeoCodeOption()
  145 + .location(latLng)
  146 + .radius(Constant.COLL_GEORESULT_RADIUS));
  147 + } catch (Exception e) {
  148 + if (null != geoCodeResult) {
  149 + geoCodeResult.success(null);
136 } 150 }
137 - });  
138 - mSearch.reverseGeoCode(new ReverseGeoCodeOption()  
139 - .location(latLng)  
140 - .radius(Constant.COLL_GEORESULT_RADIUS)); 151 + }
141 } 152 }
142 153
143 /** 154 /**
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/ScreenUtil.java
@@ -4,7 +4,9 @@ import android.app.Activity; @@ -4,7 +4,9 @@ import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 import android.graphics.Bitmap; 5 import android.graphics.Bitmap;
6 import android.graphics.Matrix; 6 import android.graphics.Matrix;
  7 +import android.graphics.Point;
7 import android.os.Build; 8 import android.os.Build;
  9 +import android.view.Display;
8 import android.view.WindowManager; 10 import android.view.WindowManager;
9 11
10 /*屏幕显示相关设置 12 /*屏幕显示相关设置
@@ -79,6 +81,14 @@ import android.view.WindowManager; @@ -79,6 +81,14 @@ import android.view.WindowManager;
79 } 81 }
80 82
81 83
  84 + public static Point getScreenPoint(Context context) {
  85 + WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  86 + Display display = manager.getDefaultDisplay();
  87 + Point size = new Point();
  88 + display.getSize(size);
  89 + return size;
  90 + }
  91 +
82 public static class ScreenInfo { 92 public static class ScreenInfo {
83 private int width; 93 private int width;
84 private int height; 94 private int height;
@@ -99,4 +109,5 @@ import android.view.WindowManager; @@ -99,4 +109,5 @@ import android.view.WindowManager;
99 this.height = height; 109 this.height = height;
100 } 110 }
101 } 111 }
  112 +
102 } 113 }
moudle_pedometer/src/main/res/drawable/shape_load.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <corners android:radius="20dp" />
  4 + <solid android:color="#CC000000" />
  5 +</shape>
0 \ No newline at end of file 6 \ No newline at end of file
moudle_pedometer/src/main/res/layout/fragment_coll_finish_run_map.xml
@@ -127,5 +127,47 @@ @@ -127,5 +127,47 @@
127 android:textColor="@color/white" 127 android:textColor="@color/white"
128 android:textSize="18sp" /> 128 android:textSize="18sp" />
129 </LinearLayout> 129 </LinearLayout>
  130 + <!--load-->
  131 + <LinearLayout
  132 + android:id="@+id/ll_loading"
  133 + android:layout_width="match_parent"
  134 + android:layout_height="match_parent"
  135 + android:focusable="true"
  136 + android:clickable="true"
  137 + android:visibility="gone"
  138 + android:focusableInTouchMode="true"
  139 + android:gravity="center">
  140 +
  141 + <LinearLayout
  142 + android:layout_width="wrap_content"
  143 + android:layout_height="wrap_content"
  144 + android:layout_gravity="center"
  145 + android:background="@drawable/shape_load"
  146 + android:gravity="center"
  147 + android:orientation="vertical">
  148 +
  149 + <ProgressBar
  150 + android:layout_width="wrap_content"
  151 + android:layout_height="wrap_content"
  152 + android:layout_marginTop="10dp"
  153 + android:indeterminateTint="@color/white"
  154 + android:maxWidth="30dp"
  155 + android:maxHeight="30dp"
  156 + android:minWidth="20dp"
  157 + android:minHeight="20dp"
  158 + android:padding="10dp" />
  159 +
  160 + <TextView
  161 + android:id="@+id/tv_loading_tip"
  162 + android:layout_width="wrap_content"
  163 + android:layout_height="wrap_content"
  164 + android:layout_marginLeft="15dp"
  165 + android:layout_marginRight="15dp"
  166 + android:layout_marginBottom="15dp"
  167 + android:textSize="13sp"
  168 + android:text="正在截取赛事图片,请稍后"
  169 + android:textColor="@color/white" />
  170 + </LinearLayout>
  171 + </LinearLayout>
130 </FrameLayout> 172 </FrameLayout>
131 </layout> 173 </layout>
132 \ No newline at end of file 174 \ No newline at end of file
moudle_pedometer/src/main/res/layout/fragment_finish_run_map.xml
@@ -147,5 +147,6 @@ @@ -147,5 +147,6 @@
147 android:textColor="@color/white" 147 android:textColor="@color/white"
148 android:textSize="18sp" /> 148 android:textSize="18sp" />
149 </LinearLayout> 149 </LinearLayout>
  150 +
150 </FrameLayout> 151 </FrameLayout>
151 </layout> 152 </layout>
152 \ No newline at end of file 153 \ No newline at end of file