Commit 90e7bd0d9c393f686ac3f4e82bdd4afa8749f8a4

Authored by 杨帅
1 parent 79e8a818

1 修改暂停后,实时轨迹显示逻辑

Showing 20 changed files with 497 additions and 228 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
... ... @@ -47,6 +47,7 @@ import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
47 47 import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity;
48 48 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment;
49 49 import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  50 +import com.cnlive.moudle.pedometer.model.Constant;
50 51 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
51 52 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
52 53 import com.cnlive.moudle.pedometer.utils.GsonUtil;
... ... @@ -559,12 +560,12 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
559 560 }
560 561 if (isFirstLoc) {
561 562 isFirstLoc = false;
562   - if (location.getRadius() > 20) {
  563 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
563 564 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
564 565 }
565 566 } else {
566 567 //过滤定位精度
567   - if (location.getRadius() > 20) {
  568 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
568 569 return;
569 570 }
570 571 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
... ... @@ -34,6 +34,7 @@ import com.baidu.mapapi.model.LatLng;
34 34 import com.baidu.mapapi.utils.DistanceUtil;
35 35 import com.baidu.trace.model.SortType;
36 36 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
  37 +import com.cnlive.moudle.pedometer.model.Constant;
37 38 import com.cnlive.moudle.pedometer.model.RunningMapBean;
38 39 import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
39 40 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
... ... @@ -298,14 +299,14 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
298 299  
299 300 if (isFirstLoc) {
300 301 isFirstLoc = false;
301   - if (location.getRadius() > 20) {
  302 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
302 303 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
303 304 }
304 305  
305 306  
306 307 } else {
307 308 //过滤定位精度
308   - if (location.getRadius() > 20) {
  309 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
309 310 return;
310 311 }
311 312 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
... ... @@ -34,6 +34,7 @@ import com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity;
34 34 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment;
35 35 import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment;
36 36 import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  37 +import com.cnlive.moudle.pedometer.model.Constant;
37 38 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
38 39 import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
39 40 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
... ... @@ -254,12 +255,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
254 255 }
255 256 if (isFirstLoc) {
256 257 isFirstLoc = false;
257   - if (location.getRadius() > 20) {
  258 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
258 259 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
259 260 }
260 261 } else {
261 262 //过滤定位精度
262   - if (location.getRadius() > 20) {
  263 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
263 264 return;
264 265 }
265 266 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
... ... @@ -279,11 +279,27 @@ public class CommonInfo {
279 279 }
280 280  
281 281  
282   -
283   -
284   -
285   -
286   -
  282 +// /**
  283 +// * 设置起点经纬度
  284 +// *
  285 +// * @param context
  286 +// * @param startLatLng
  287 +// */
  288 +// public static void setStartLatLng(Context context, String startLatLng) {
  289 +// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStartLatLng", startLatLng);
  290 +//
  291 +// }
  292 +//
  293 +// /**
  294 +// * 设置终点经纬度
  295 +// *
  296 +// * @param context
  297 +// * @param endLatLng
  298 +// */
  299 +// public static void setEndLatLng(Context context, String endLatLng) {
  300 +// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runEndLatLng", endLatLng);
  301 +//
  302 +// }
287 303 /*重置
288 304 * @param context
289 305 */
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
... ... @@ -39,6 +39,7 @@ import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
39 39 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
40 40 import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
41 41 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
  42 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
42 43 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
43 44 import com.cnlive.moudle.pedometer.utils.MySpHelper;
44 45 import com.cnlive.moudle.pedometer.utils.StepUtil;
... ... @@ -69,6 +70,8 @@ public class RunMainFragmentView implements MvpView {
69 70 private LocationClient mLocClient;
70 71 public MyLocationListenner myListener = new MyLocationListenner();
71 72 private String employTime = "";
  73 + private LatLng endLatLng;//终点坐标
  74 + private TipDialog tipDialog;
72 75  
73 76 public RunMainFragmentView(RunMainFragment fragment) {
74 77 this.fragment = fragment;
... ... @@ -144,7 +147,19 @@ public class RunMainFragmentView implements MvpView {
144 147 if (TextUtils.isEmpty(userStepEntity.getStreetId())) {
145 148 StepUtil.setStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getContext()));
146 149 }
147   -
  150 + //设置终点经纬度
  151 + if (TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  152 + if (null != runRaceDetailInfo.getEndLatLng()) {
  153 + //设置终点坐标
  154 + userStepEntity.setEndLatLng(GsonUtil.GsonString(runRaceDetailInfo.getEndLatLng()));
  155 + //更新数据
  156 + StepUtil.updateStepData(getContext(), userStepEntity);
  157 + }
  158 + }
  159 + //设置终点经纬度
  160 + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  161 + endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class);
  162 + }
148 163 }
149 164 initLocationClient();
150 165 fragment.binding.llRunMainRoot.setVisibility(View.GONE);
... ... @@ -661,7 +676,8 @@ public class RunMainFragmentView implements MvpView {
661 676  
662 677 @Override
663 678 public void onReceiveLocation(BDLocation location) {
664   - if (location == null) {
  679 + // map view 销毁后不在处理新接收的位置
  680 + if (location == null || getContext() == null) {
665 681 return;
666 682 }
667 683 //正在搜索GPS信号
... ... @@ -718,6 +734,52 @@ public class RunMainFragmentView implements MvpView {
718 734 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
719 735 }
720 736 }
  737 +
  738 + //进行精度过滤
  739 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
  740 + return;
  741 + }
  742 + //进行数据比较(先看看数据库是否有数据)
  743 + if (null == endLatLng) {
  744 + if (null == userStepEntity) {
  745 + userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
  746 + }
  747 + if (null != userStepEntity) {
  748 + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  749 + endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class);
  750 + }
  751 + }
  752 + }
  753 + //开始比较
  754 + if (null != endLatLng) {
  755 + LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
  756 + if (null != current) {
  757 + //开始比较数据
  758 + double distance = DistanceUtil.getDistance(current, endLatLng);
  759 + if (distance < Constant.LOCA_END_POINT_ACCURACY) {
  760 + //设置数据
  761 + if (userStepEntity != null) {
  762 + userStepEntity.setIsArriveEndPoint(true);
  763 + //更新数据
  764 + StepUtil.updateStepData(getContext(), userStepEntity);
  765 + }
  766 + //进行提示
  767 + if (null == tipDialog) {
  768 + tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  769 + @Override
  770 + public void onClick(TipDialog dialog) {
  771 + dialog.dismiss();
  772 + }
  773 + });
  774 + tipDialog.setCancelable(false);
  775 + tipDialog.setCanceledOnTouchOutside(false);
  776 + }
  777 + if (!tipDialog.isShowing()) {
  778 + tipDialog.show();
  779 + }
  780 + }
  781 + }
  782 + }
721 783 }
722 784  
723 785 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -122,21 +122,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
122 122 public MyLocationListenner myListener = new MyLocationListenner();
123 123 private final int DEFULT_ZOOM = 17;
124 124 private RoutePlanSearch routePlanSearch = null; // 路线规划
125   - private LatLng endLatLng;
126 125 private final int START_MARK = 0;//起始点
127 126 private final int END_MARK = 1;//终止点
128   -
129   - private String startPoint = "首都师范大学南门";
130   - private String endPoint = "首都师范大学篮球场";
131   - // private String test = "[{\"latitude\":39.933889208848,\"latitudeE6\":3.9933889208848E7,\"longitude\":116.30900265517,\"longitudeE6\":1.1630900265517001E8},{\"latitude\":39.933868507347,\"latitudeE6\":3.9933868507347E7,\"longitude\":116.30865416508,\"longitudeE6\":1.1630865416508E8},{\"latitude\":39.934756505077,\"latitudeE6\":3.9934756505077E7,\"longitude\":116.30860516469,\"longitudeE6\":1.1630860516468999E8},{\"latitude\":39.934781620502,\"latitudeE6\":3.9934781620502E7,\"longitude\":116.30961013007,\"longitudeE6\":1.1630961013007E8},{\"latitude\":39.934881620374,\"latitudeE6\":3.9934881620374E7,\"longitude\":116.30960513008,\"longitudeE6\":1.1630960513008E8},{\"latitude\":39.934077623132,\"latitudeE6\":3.9934077623132E7,\"longitude\":116.30965812942,\"longitudeE6\":1.1630965812942E8},{\"latitude\":39.933972618463,\"latitudeE6\":3.9933972618463E7,\"longitude\":116.30962113087,\"longitudeE6\":1.1630962113087E8},{\"latitude\":39.933932608856,\"latitudeE6\":3.9933932608856E7,\"longitude\":116.30953913383,\"longitudeE6\":1.1630953913383E8}]";
132   - private LinkedList<LatLng> importLatLngs;//关键点
133   - private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点
  127 + private LatLng startLatLng;//起始点
134 128 public RunRaceDetailInfo runRaceDetailInfo;
135 129 private UserStepEntity userStepEntity;
136 130 private boolean isDifferentStreet = false;
137 131 private LBSTraceClient mClient = null;
138   - private List<LatLng> resultStreetPoints;
139   - public List<LatLng> importStreetPoints;//运营打的重要的点
  132 + public LatLng endLatLng;//用于终点判断
140 133  
141 134 public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) {
142 135 this.fragment = fragment;
... ... @@ -200,10 +193,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
200 193 return;
201 194 }
202 195 this.runRaceDetailInfo = runRaceDetailInfo;
203   -// //初始化地图点位
204   - if (runRaceDetailInfo.getLatLongitude() != null) {
205   - importStreetPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude().trim(), LatLng.class);
206   - }
207 196 //轨迹开始时间
208 197 long startTime = 0;
209 198 //轨迹结束时间
... ... @@ -220,8 +209,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
220 209 @Override
221 210 public void success(List<LatLng> resultPoints) {
222 211 if (resultPoints != null && resultPoints.size() > 1) {
223   - resultStreetPoints = resultPoints;
224   - Log.e(TAG, "resultPoints: " + resultPoints.size());
  212 + startLatLng = resultPoints.get(0);
  213 + endLatLng = resultPoints.get(resultPoints.size() - 1);
225 214 MyMapUtil.drawServerLineTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
226 215 // //自动计算地图缩放
227 216 // MapStatus.Builder builder = new MapStatus.Builder();
... ... @@ -486,8 +475,28 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
486 475 //现在开始
487 476 else if ("1".equals(fragment.binding.rlScrollViewStartBtn.getTag())) {
488 477 //先判断是否从百度查询到赛事轨迹
489   - if (resultStreetPoints != null) {
490   - startStepService(getContext());
  478 + if (null != endLatLng && null != startLatLng) {
  479 + //开始比较距离
  480 + if (null != firstLatLng) {
  481 + double currentDiatance = DistanceUtil.getDistance(firstLatLng, startLatLng);
  482 + if (currentDiatance < Constant.LOCA_START_POINT_ACCURACY) {
  483 + //设置终点坐标
  484 + runRaceDetailInfo.setEndLatLng(endLatLng);
  485 + startStepService(getContext());
  486 + } else {
  487 + //进行提示
  488 + TipDialog tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_far_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  489 + @Override
  490 + public void onClick(TipDialog dialog) {
  491 + dialog.dismiss();
  492 + }
  493 + });
  494 + tipDialog.setCancelable(false);
  495 + tipDialog.setCanceledOnTouchOutside(false);
  496 + tipDialog.show();
  497 + }
  498 + }
  499 +
491 500 } else {
492 501 QMUITipDialogUtil.textDialog(getContext(), "正在获取轨迹请稍后...", 1);
493 502 }
... ... @@ -653,188 +662,188 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
653 662 });
654 663 }
655 664  
656   - /**
657   - * 开始路线规划
658   - */
659   - public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index, int listSize) {
660   -// Log.e(TAG, "searchRouteResult: ");
661   - float currentZoom = baiduMap.getMapStatus().zoom;
662   - // 设置起终点信息,对于tranist search 来说,城市名无意义
663   - PlanNode stNode = PlanNode.withLocation(StartPoint);
664   - PlanNode enNode = PlanNode.withLocation(EndPoint);
665   - routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() {
666   - @Override
667   - public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {
668   - if (fragment.getActivity() == null) {
669   - return;
670   - }
671   - if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
672   - Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
673   - }
674   - if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
675   - // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
676   - return;
677   - }
678   - List<LatLng> points = new ArrayList<LatLng>();
679   - if (walkingRouteResult.getRouteLines() != null) {
680   - if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
681   - //添加起点坐标
682   - if (index == 0) {
683   - points.add(StartPoint);
684   - }
685   - for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
686   - for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
687   - points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
688   - }
689   - }
690   - }
691   - //添加终点坐标
692   - if (endLatLng != null) {
  665 +// /**
  666 +// * 开始路线规划
  667 +// */
  668 +// public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index, int listSize) {
  669 +//// Log.e(TAG, "searchRouteResult: ");
  670 +// float currentZoom = baiduMap.getMapStatus().zoom;
  671 +// // 设置起终点信息,对于tranist search 来说,城市名无意义
  672 +// PlanNode stNode = PlanNode.withLocation(StartPoint);
  673 +// PlanNode enNode = PlanNode.withLocation(EndPoint);
  674 +// routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() {
  675 +// @Override
  676 +// public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {
  677 +// if (fragment.getActivity() == null) {
  678 +// return;
  679 +// }
  680 +// if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
  681 +// Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
  682 +// }
  683 +// if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
  684 +// // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
  685 +// return;
  686 +// }
  687 +// List<LatLng> points = new ArrayList<LatLng>();
  688 +// if (walkingRouteResult.getRouteLines() != null) {
  689 +// if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
  690 +// //添加起点坐标
  691 +// if (index == 0) {
  692 +// points.add(StartPoint);
  693 +// }
  694 +// for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
  695 +// for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
  696 +// points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
  697 +// }
  698 +// }
  699 +// }
  700 +// //添加终点坐标
  701 +// if (endLatLng != null) {
  702 +//// points.add(endLatLng);
  703 +// }
  704 +//
  705 +// ArrayList<Integer> traffics = new ArrayList<Integer>();
  706 +// for (int i = 0; i < points.size(); i++) {
  707 +// if (i % 2 == 0) {
  708 +// traffics.add(i);
  709 +// }
  710 +// }
  711 +//
  712 +//
  713 +// if (points.size() > 0) {
  714 +//// if (baiduMap != null) {
  715 +//// baiduMap.clear();
  716 +//// if (endLatLng != null) {
  717 +//// markPoi(endLatLng.latitude, endLatLng.longitude);
  718 +//// }
  719 +//// }
  720 +//
  721 +// //设置折线的属性
  722 +//// OverlayOptions mOverlayOptions = new PolylineOptions()
  723 +//// .width(10)
  724 +//// .color(0xAAFF0000)
  725 +//// .points(points);
  726 +// //设置折线的属性
  727 +// OverlayOptions mOverlayOptions = new PolylineOptions()
  728 +// .width(10)
  729 +// .dottedLine(true)
  730 +// .points(points)
  731 +// .customTextureList(getCustomTextureList())
  732 +// .textureIndex(traffics);//设置纹理列表
  733 +// //在地图上绘制起点
  734 +// if (index == 0) {
  735 +// //显示当前位置图标
  736 +// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_start), 30, 30);
  737 +// startMark = new MarkerOptions()
  738 +// .position(StartPoint)
  739 +// .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  740 +//// startMark.anchor(0.5f, 0.55f);
  741 +// baiduMap.addOverlay(startMark);
  742 +// } else if (index == listSize - 1) {
  743 +// //显示当前位置图标
  744 +// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_end), 30, 30);
  745 +// endMark = new MarkerOptions()
  746 +// .position(points.get(points.size() - 1))
  747 +// .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap))
  748 +// .perspective(true)
  749 +//// endMark.anchor(0.5f, 0.5f)
  750 +// .perspective(true);
  751 +// baiduMap.addOverlay(endMark);
  752 +// }
  753 +// //mPloyline 折线对象
  754 +// Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
  755 +// MapStatus.Builder builder = new MapStatus.Builder();
  756 +// builder.zoom(currentZoom);
  757 +// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  758 +//
  759 +// }
  760 +// }
  761 +// }
  762 +//
  763 +// @Override
  764 +// public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) {
  765 +//
  766 +// }
  767 +//
  768 +// @Override
  769 +// public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) {
  770 +//
  771 +// }
  772 +//
  773 +// @Override
  774 +// public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
  775 +// if (fragment.getActivity() == null) {
  776 +// return;
  777 +// }
  778 +//
  779 +// if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
  780 +// Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
  781 +// }
  782 +// if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
  783 +// // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
  784 +// return;
  785 +// }
  786 +// List<LatLng> points = new ArrayList<LatLng>();
  787 +// if (drivingRouteResult.getRouteLines() != null) {
  788 +// if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
  789 +// //添加起点坐标
  790 +// if (followMyLocation != null) {
  791 +// points.add(new LatLng(followMyLocation.latitude, followMyLocation.longitude));
  792 +// }
  793 +// for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
  794 +// for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
  795 +// points.add(drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
  796 +// }
  797 +// }
  798 +// }
  799 +// //添加终点坐标
  800 +// if (endLatLng != null) {
693 801 // points.add(endLatLng);
694   - }
695   -
696   - ArrayList<Integer> traffics = new ArrayList<Integer>();
697   - for (int i = 0; i < points.size(); i++) {
698   - if (i % 2 == 0) {
699   - traffics.add(i);
700   - }
701   - }
702   -
703   -
704   - if (points.size() > 0) {
705   -// if (baiduMap != null) {
706   -// baiduMap.clear();
707   -// if (endLatLng != null) {
708   -// markPoi(endLatLng.latitude, endLatLng.longitude);
709   -// }
  802 +// }
  803 +// if (points.size() > 0) {
  804 +// if (baiduMap != null) {
  805 +// baiduMap.clear();
  806 +// if (endLatLng != null) {
  807 +// markPoi(endLatLng.latitude, endLatLng.longitude);
710 808 // }
711   -
712   - //设置折线的属性
  809 +// }
  810 +//
  811 +// //设置折线的属性
713 812 // OverlayOptions mOverlayOptions = new PolylineOptions()
714 813 // .width(10)
715 814 // .color(0xAAFF0000)
716 815 // .points(points);
717   - //设置折线的属性
718   - OverlayOptions mOverlayOptions = new PolylineOptions()
719   - .width(10)
720   - .dottedLine(true)
721   - .points(points)
722   - .customTextureList(getCustomTextureList())
723   - .textureIndex(traffics);//设置纹理列表
724   - //在地图上绘制起点
725   - if (index == 0) {
726   - //显示当前位置图标
727   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_start), 30, 30);
728   - startMark = new MarkerOptions()
729   - .position(StartPoint)
730   - .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
731   -// startMark.anchor(0.5f, 0.55f);
732   - baiduMap.addOverlay(startMark);
733   - } else if (index == listSize - 1) {
734   - //显示当前位置图标
735   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_end), 30, 30);
736   - endMark = new MarkerOptions()
737   - .position(points.get(points.size() - 1))
738   - .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap))
739   - .perspective(true)
740   -// endMark.anchor(0.5f, 0.5f)
741   - .perspective(true);
742   - baiduMap.addOverlay(endMark);
743   - }
744   - //mPloyline 折线对象
745   - Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
746   - MapStatus.Builder builder = new MapStatus.Builder();
747   - builder.zoom(currentZoom);
748   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
749   -
750   - }
751   - }
752   - }
753   -
754   - @Override
755   - public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) {
756   -
757   - }
758   -
759   - @Override
760   - public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) {
761   -
762   - }
763   -
764   - @Override
765   - public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
766   - if (fragment.getActivity() == null) {
767   - return;
768   - }
769   -
770   - if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
771   - Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
772   - }
773   - if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
774   - // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
775   - return;
776   - }
777   - List<LatLng> points = new ArrayList<LatLng>();
778   - if (drivingRouteResult.getRouteLines() != null) {
779   - if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
780   - //添加起点坐标
781   - if (followMyLocation != null) {
782   - points.add(new LatLng(followMyLocation.latitude, followMyLocation.longitude));
783   - }
784   - for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
785   - for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
786   - points.add(drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
787   - }
788   - }
789   - }
790   - //添加终点坐标
791   - if (endLatLng != null) {
792   - points.add(endLatLng);
793   - }
794   - if (points.size() > 0) {
795   - if (baiduMap != null) {
796   - baiduMap.clear();
797   - if (endLatLng != null) {
798   - markPoi(endLatLng.latitude, endLatLng.longitude);
799   - }
800   - }
801   -
802   - //设置折线的属性
803   - OverlayOptions mOverlayOptions = new PolylineOptions()
804   - .width(10)
805   - .color(0xAAFF0000)
806   - .points(points);
807   - //在地图上绘制折线
808   - //mPloyline 折线对象
809   - Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
810   - MapStatus.Builder builder = new MapStatus.Builder();
811   - builder.zoom(currentZoom);
812   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
813   -
814   - }
815   - }
816   - }
817   -
818   - @Override
819   - public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) {
820   -
821   - }
822   -
823   - @Override
824   - public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) {
825   -
826   - }
827   - });
828   - //开始检索
  816 +// //在地图上绘制折线
  817 +// //mPloyline 折线对象
  818 +// Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
  819 +// MapStatus.Builder builder = new MapStatus.Builder();
  820 +// builder.zoom(currentZoom);
  821 +// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  822 +//
  823 +// }
  824 +// }
  825 +// }
  826 +//
  827 +// @Override
  828 +// public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) {
  829 +//
  830 +// }
  831 +//
  832 +// @Override
  833 +// public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) {
  834 +//
  835 +// }
  836 +// });
  837 + //开始检索
829 838 // routePlanSearch.drivingSearch((new DrivingRoutePlanOption())
830 839 // .from(stNode).to(enNode).policy(DrivingRoutePlanOption.DrivingPolicy.ECAR_DIS_FIRST)
831 840 // .trafficPolicy(DrivingRoutePlanOption.DrivingTrafficPolicy.ROUTE_PATH_AND_TRAFFIC));
832 841  
833   - //开始步行检索
834   - routePlanSearch.walkingSearch((new WalkingRoutePlanOption())
835   - .from(stNode)
836   - .to(enNode));
837   - }
  842 + //开始步行检索
  843 +// routePlanSearch.walkingSearch((new WalkingRoutePlanOption())
  844 +// .from(stNode)
  845 +// .to(enNode));
  846 +// }
838 847 // showProgressDialog();
839 848  
840 849 /**
... ... @@ -989,12 +998,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
989 998 }
990 999 if (isFirstLoc) {
991 1000 isFirstLoc = false;
992   - if (location.getRadius() > 20) {
  1001 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
993 1002 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
994 1003 }
995 1004 } else {
996 1005 //过滤定位精度
997   - if (location.getRadius() > 20) {
  1006 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
998 1007 return;
999 1008 }
1000 1009 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
... ... @@ -9,6 +9,7 @@ import android.hardware.SensorEventListener;
9 9 import android.hardware.SensorManager;
10 10 import android.os.Handler;
11 11 import android.os.SystemClock;
  12 +import android.text.TextUtils;
12 13 import android.util.Log;
13 14 import android.view.MotionEvent;
14 15 import android.view.View;
... ... @@ -35,8 +36,12 @@ import com.baidu.mapapi.model.LatLng;
35 36 import com.baidu.mapapi.model.LatLngBounds;
36 37 import com.baidu.mapapi.utils.DistanceUtil;
37 38 import com.baidu.trace.model.SortType;
  39 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  40 +import com.cnlive.moudle.pedometer.model.Constant;
38 41 import com.cnlive.moudle.pedometer.model.RunningMapBean;
  42 +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
39 43 import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
  44 +import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
40 45 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
41 46 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
42 47 import com.cnlive.moudle.pedometer.utils.GsonUtil;
... ... @@ -75,6 +80,9 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
75 80 private boolean isFirstLoadMap = true;
76 81 private Overlay currentLine;
77 82 private List<LatLng> currentPoints;
  83 + private LatLng endLatLng;//终点坐标
  84 + private UserStepEntity userStepEntity;
  85 + private TipDialog tipDialog;
78 86  
79 87 public RunningMapFragmentView(RunningMapFragment fragment) {
80 88 this.fragment = fragment;
... ... @@ -85,6 +93,10 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
85 93 }
86 94  
87 95 public void initView() {
  96 + if (getContext() == null) {
  97 + return;
  98 + }
  99 + userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
88 100 currentPoints = new ArrayList<>();
89 101 initMap();
90 102 //返回键
... ... @@ -237,7 +249,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
237 249 @Override
238 250 public void onReceiveLocation(BDLocation location) {
239 251 // map view 销毁后不在处理新接收的位置
240   - if (location == null || mMapView == null) {
  252 + if (location == null || mMapView == null || getContext() == null) {
241 253 return;
242 254 }
243 255  
... ... @@ -293,17 +305,60 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
293 305  
294 306 if (isFirstLoc) {
295 307 isFirstLoc = false;
296   - if (location.getRadius() > 20) {
  308 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
297 309 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
298 310 }
299 311  
300 312  
301 313 } else {
302 314 //过滤定位精度
303   - if (location.getRadius() > 20) {
  315 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
304 316 return;
305 317 }
306 318 }
  319 +
  320 + //进行数据比较(先看看数据库是否有数据)
  321 + if (null == endLatLng) {
  322 + if (null == userStepEntity) {
  323 + userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
  324 + }
  325 + if (null != userStepEntity) {
  326 + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  327 + endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class);
  328 + }
  329 + }
  330 + }
  331 + //开始比较
  332 + if (null != endLatLng) {
  333 + LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
  334 + if (null != current) {
  335 + //开始比较数据
  336 + double distance = DistanceUtil.getDistance(current, endLatLng);
  337 + if (distance < Constant.LOCA_END_POINT_ACCURACY) {
  338 + //设置数据
  339 + if (userStepEntity != null) {
  340 + userStepEntity.setIsArriveEndPoint(true);
  341 + //更新数据
  342 + StepUtil.updateStepData(getContext(), userStepEntity);
  343 + }
  344 + //进行提示
  345 + if (null == tipDialog) {
  346 + tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  347 + @Override
  348 + public void onClick(TipDialog dialog) {
  349 + dialog.dismiss();
  350 + }
  351 + });
  352 + tipDialog.setCancelable(false);
  353 + tipDialog.setCanceledOnTouchOutside(false);
  354 + }
  355 + if (!tipDialog.isShowing()) {
  356 + tipDialog.show();
  357 + }
  358 + }
  359 + }
  360 + }
  361 +
307 362 mCurrentAccracy = location.getRadius();
308 363 mylocation = new MyLocationData.Builder()
309 364 .accuracy(location.getRadius())
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
... ... @@ -20,4 +20,8 @@ public class Constant {
20 20 public static final int REGISTRATION_SUCCESS = 11;//用户报名成功
21 21 public static final double PASS_RATE = 0.7;//通过率70%
22 22 public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围
  23 + public static final int LOCA_ACCURACY = 20;//定位过滤精度
  24 + public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度
  25 + public static final int LOCA_START_POINT_ACCURACY = 20;//起点位置比较精度
  26 +
23 27 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/net/bean/RunRaceDetailInfo.java
1 1 package com.cnlive.moudle.pedometer.net.bean;
2 2  
  3 +import com.baidu.mapapi.model.LatLng;
  4 +
3 5 import java.io.Serializable;
4 6 import java.util.List;
5 7  
... ... @@ -84,6 +86,15 @@ public class RunRaceDetailInfo implements Serializable {
84 86 private String userMileage;
85 87 private List<String> faceUrl;
86 88 private List<String> finishFaceUrl;
  89 + private LatLng endLatLng;//终点坐标,后加的,不是后台返回,这是从百度历史轨迹查出来的
  90 +
  91 + public LatLng getEndLatLng() {
  92 + return endLatLng;
  93 + }
  94 +
  95 + public void setEndLatLng(LatLng endLatLng) {
  96 + this.endLatLng = endLatLng;
  97 + }
87 98  
88 99 public String getAddress() {
89 100 return address;
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -369,7 +369,10 @@ public class StepService extends Service implements SensorEventListener {
369 369 return;
370 370 }
371 371 UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
372   - if (userStepEntity == null) {
  372 + if (null == userStepEntity) {
  373 + return;
  374 + }
  375 + if (userStepEntity.getFenceId() == 0) {
373 376 return;
374 377 }
375 378 if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) {
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/FailedEntityDao.java
... ... @@ -45,6 +45,7 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
45 45 public final static Property StreetId = new Property(18, String.class, "streetId", false, "STREET_ID");
46 46 public final static Property StreetTitle = new Property(19, String.class, "streetTitle", false, "STREET_TITLE");
47 47 public final static Property CreatTimeStamp = new Property(20, long.class, "creatTimeStamp", false, "CREAT_TIME_STAMP");
  48 + public final static Property IsArriveEndPoint = new Property(21, boolean.class, "isArriveEndPoint", false, "IS_ARRIVE_END_POINT");
48 49 }
49 50  
50 51  
... ... @@ -80,7 +81,8 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
80 81 "\"IMPORT_POINT\" TEXT," + // 17: importPoint
81 82 "\"STREET_ID\" TEXT," + // 18: streetId
82 83 "\"STREET_TITLE\" TEXT," + // 19: streetTitle
83   - "\"CREAT_TIME_STAMP\" INTEGER NOT NULL );"); // 20: creatTimeStamp
  84 + "\"CREAT_TIME_STAMP\" INTEGER NOT NULL ," + // 20: creatTimeStamp
  85 + "\"IS_ARRIVE_END_POINT\" INTEGER NOT NULL );"); // 21: isArriveEndPoint
84 86 }
85 87  
86 88 /** Drops the underlying database table. */
... ... @@ -165,6 +167,7 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
165 167 stmt.bindString(20, streetTitle);
166 168 }
167 169 stmt.bindLong(21, entity.getCreatTimeStamp());
  170 + stmt.bindLong(22, entity.getIsArriveEndPoint() ? 1L: 0L);
168 171 }
169 172  
170 173 @Override
... ... @@ -243,6 +246,7 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
243 246 stmt.bindString(20, streetTitle);
244 247 }
245 248 stmt.bindLong(21, entity.getCreatTimeStamp());
  249 + stmt.bindLong(22, entity.getIsArriveEndPoint() ? 1L: 0L);
246 250 }
247 251  
248 252 @Override
... ... @@ -273,7 +277,8 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
273 277 cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // importPoint
274 278 cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // streetId
275 279 cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // streetTitle
276   - cursor.getLong(offset + 20) // creatTimeStamp
  280 + cursor.getLong(offset + 20), // creatTimeStamp
  281 + cursor.getShort(offset + 21) != 0 // isArriveEndPoint
277 282 );
278 283 return entity;
279 284 }
... ... @@ -301,6 +306,7 @@ public class FailedEntityDao extends AbstractDao&lt;FailedEntity, String&gt; {
301 306 entity.setStreetId(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
302 307 entity.setStreetTitle(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
303 308 entity.setCreatTimeStamp(cursor.getLong(offset + 20));
  309 + entity.setIsArriveEndPoint(cursor.getShort(offset + 21) != 0);
304 310 }
305 311  
306 312 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
... ... @@ -45,6 +45,8 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
45 45 public final static Property FenceId = new Property(18, long.class, "fenceId", false, "FENCE_ID");
46 46 public final static Property ImportPoint = new Property(19, String.class, "importPoint", false, "IMPORT_POINT");
47 47 public final static Property StreetTitle = new Property(20, String.class, "streetTitle", false, "STREET_TITLE");
  48 + public final static Property EndLatLng = new Property(21, String.class, "endLatLng", false, "END_LAT_LNG");
  49 + public final static Property IsArriveEndPoint = new Property(22, boolean.class, "isArriveEndPoint", false, "IS_ARRIVE_END_POINT");
48 50 }
49 51  
50 52  
... ... @@ -80,7 +82,9 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
80 82 "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 17: continueTime
81 83 "\"FENCE_ID\" INTEGER NOT NULL ," + // 18: fenceId
82 84 "\"IMPORT_POINT\" TEXT," + // 19: importPoint
83   - "\"STREET_TITLE\" TEXT);"); // 20: streetTitle
  85 + "\"STREET_TITLE\" TEXT," + // 20: streetTitle
  86 + "\"END_LAT_LNG\" TEXT," + // 21: endLatLng
  87 + "\"IS_ARRIVE_END_POINT\" INTEGER NOT NULL );"); // 22: isArriveEndPoint
84 88 }
85 89  
86 90 /** Drops the underlying database table. */
... ... @@ -153,6 +157,12 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
153 157 if (streetTitle != null) {
154 158 stmt.bindString(21, streetTitle);
155 159 }
  160 +
  161 + String endLatLng = entity.getEndLatLng();
  162 + if (endLatLng != null) {
  163 + stmt.bindString(22, endLatLng);
  164 + }
  165 + stmt.bindLong(23, entity.getIsArriveEndPoint() ? 1L: 0L);
156 166 }
157 167  
158 168 @Override
... ... @@ -219,6 +229,12 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
219 229 if (streetTitle != null) {
220 230 stmt.bindString(21, streetTitle);
221 231 }
  232 +
  233 + String endLatLng = entity.getEndLatLng();
  234 + if (endLatLng != null) {
  235 + stmt.bindString(22, endLatLng);
  236 + }
  237 + stmt.bindLong(23, entity.getIsArriveEndPoint() ? 1L: 0L);
222 238 }
223 239  
224 240 @Override
... ... @@ -249,7 +265,9 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
249 265 cursor.getLong(offset + 17), // continueTime
250 266 cursor.getLong(offset + 18), // fenceId
251 267 cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // importPoint
252   - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // streetTitle
  268 + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // streetTitle
  269 + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // endLatLng
  270 + cursor.getShort(offset + 22) != 0 // isArriveEndPoint
253 271 );
254 272 return entity;
255 273 }
... ... @@ -277,6 +295,8 @@ public class UserStepEntityDao extends AbstractDao&lt;UserStepEntity, String&gt; {
277 295 entity.setFenceId(cursor.getLong(offset + 18));
278 296 entity.setImportPoint(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
279 297 entity.setStreetTitle(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
  298 + entity.setEndLatLng(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
  299 + entity.setIsArriveEndPoint(cursor.getShort(offset + 22) != 0);
280 300 }
281 301  
282 302 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/FailedEntity.java
... ... @@ -36,13 +36,13 @@ public class FailedEntity implements Serializable {
36 36 private String streetId;//赛事id
37 37 private String streetTitle;//赛道标题
38 38 private long creatTimeStamp;//数据创建的时间
  39 + private boolean isArriveEndPoint;//是否到达终点
39 40  
40   - @Generated(hash = 458367844)
41   - public FailedEntity(String uuid, String uid, boolean isPause, long userPauseTime, long usrContinueTime,
42   - String isFinish, String time, String speed, String step, String distance, String startPoint,
43   - String endPoint, long streetTraceStartTime, long streetTraceEndTime, String entityName,
44   - long userStartTime, long userEndTime, String importPoint, String streetId, String streetTitle,
45   - long creatTimeStamp) {
  41 + @Generated(hash = 1057412546)
  42 + public FailedEntity(String uuid, String uid, boolean isPause, long userPauseTime, long usrContinueTime, String isFinish,
  43 + String time, String speed, String step, String distance, String startPoint, String endPoint,
  44 + long streetTraceStartTime, long streetTraceEndTime, String entityName, long userStartTime, long userEndTime,
  45 + String importPoint, String streetId, String streetTitle, long creatTimeStamp, boolean isArriveEndPoint) {
46 46 this.uuid = uuid;
47 47 this.uid = uid;
48 48 this.isPause = isPause;
... ... @@ -64,6 +64,7 @@ public class FailedEntity implements Serializable {
64 64 this.streetId = streetId;
65 65 this.streetTitle = streetTitle;
66 66 this.creatTimeStamp = creatTimeStamp;
  67 + this.isArriveEndPoint = isArriveEndPoint;
67 68 }
68 69  
69 70 @Generated(hash = 1639581354)
... ... @@ -238,6 +239,13 @@ public class FailedEntity implements Serializable {
238 239 this.distance = distance;
239 240 }
240 241  
  242 + public boolean getIsArriveEndPoint() {
  243 + return this.isArriveEndPoint;
  244 + }
  245 +
  246 + public void setIsArriveEndPoint(boolean isArriveEndPoint) {
  247 + this.isArriveEndPoint = isArriveEndPoint;
  248 + }
241 249  
242 250  
243 251 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
1 1 package com.cnlive.moudle.pedometer.sql.entity;
2 2  
  3 +import com.baidu.mapapi.model.LatLng;
  4 +
3 5 import org.greenrobot.greendao.annotation.Entity;
4 6 import org.greenrobot.greendao.annotation.Generated;
5 7 import org.greenrobot.greendao.annotation.Id;
... ... @@ -28,11 +30,12 @@ public class UserStepEntity {
28 30 private long fenceId;//围栏id
29 31 private String importPoint;//关键点
30 32 private String streetTitle;//赛事标题
31   -
32   - @Generated(hash = 281426159)
  33 + private String endLatLng;//终点坐标
  34 + private boolean isArriveEndPoint;//是否到达终点
  35 + @Generated(hash = 434792384)
33 36 public UserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, String startPoint, String endPoint,
34 37 long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime,
35   - String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle) {
  38 + String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint) {
36 39 this.userId = userId;
37 40 this.date = date;
38 41 this.stepCount = stepCount;
... ... @@ -54,6 +57,8 @@ public class UserStepEntity {
54 57 this.fenceId = fenceId;
55 58 this.importPoint = importPoint;
56 59 this.streetTitle = streetTitle;
  60 + this.endLatLng = endLatLng;
  61 + this.isArriveEndPoint = isArriveEndPoint;
57 62 }
58 63  
59 64 @Generated(hash = 273857141)
... ... @@ -229,5 +234,21 @@ public class UserStepEntity {
229 234 this.streetTitle = streetTitle;
230 235 }
231 236  
  237 + public boolean getIsArriveEndPoint() {
  238 + return this.isArriveEndPoint;
  239 + }
  240 +
  241 + public void setIsArriveEndPoint(boolean isArriveEndPoint) {
  242 + this.isArriveEndPoint = isArriveEndPoint;
  243 + }
  244 +
  245 + public String getEndLatLng() {
  246 + return this.endLatLng;
  247 + }
  248 +
  249 + public void setEndLatLng(String endLatLng) {
  250 + this.endLatLng = endLatLng;
  251 + }
  252 +
232 253  
233 254 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
... ... @@ -2,6 +2,7 @@ package com.cnlive.moudle.pedometer.ui.fragment;
2 2  
3 3 import android.os.Bundle;
4 4 import android.os.Handler;
  5 +import android.os.Vibrator;
5 6 import android.support.annotation.Nullable;
6 7 import android.text.TextUtils;
7 8 import android.util.Log;
... ... @@ -18,6 +19,8 @@ import com.cnlive.moudle.pedometer.model.Constant;
18 19 import com.cnlive.moudle.pedometer.model.MessageEvent;
19 20 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
20 21 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
  22 +import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
  23 +import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil;
21 24 import com.cnlive.moudle.pedometer.utils.GsonUtil;
22 25 import com.cnlive.moudle.pedometer.utils.StepUtil;
23 26 import com.example.moudle_pedometer.R;
... ... @@ -34,6 +37,9 @@ import java.util.List;
34 37 public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFragmentPresenter, FragmentRunMainBinding> {
35 38 private final String TAG = "RunMainFragment";
36 39 private RunRaceDetailInfo runRaceDetailInfo;
  40 + //创建震动服务对象
  41 + private Vibrator mVibrator;
  42 + private TipDialog tipDialog;
37 43  
38 44 public static RunMainFragment newInstance(RunRaceDetailInfo runRaceDetailInfo) {
39 45 Bundle bundle = new Bundle();
... ... @@ -50,6 +56,7 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
50 56 StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0);
51 57 EventBus.getDefault().register(this);
52 58 if (getArguments() != null) {
  59 + initTipDialog();
53 60 runRaceDetailInfo = (RunRaceDetailInfo) getArguments().getSerializable("runRaceDetailInfo");
54 61 UserStepEntity userStepEntity = StepUtil.getUserStepData(getActivity(), CommonInfo.getUserId(getActivity()));
55 62 if (userStepEntity != null) {
... ... @@ -129,6 +136,19 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
129 136 return R.layout.fragment_run_main;
130 137 }
131 138  
  139 + private void initTipDialog() {
  140 + if (tipDialog == null) {
  141 + tipDialog = new TipDialog(getActivity(), "您已偏离预定轨迹!", "我知道了", R.color.green_round, new TipDialog.DialogInterface() {
  142 + @Override
  143 + public void onClick(TipDialog dialog) {
  144 + dialog.dismiss();
  145 + }
  146 + });
  147 + tipDialog.setCancelable(false);
  148 + tipDialog.setCanceledOnTouchOutside(false);
  149 + }
  150 + }
  151 +
132 152 @Subscribe(threadMode = ThreadMode.MAIN)
133 153 public void Event(MessageEvent messageEvent) {
134 154 //更新步数
... ... @@ -143,6 +163,32 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
143 163 getMvpView().resetSpeed();
144 164 }
145 165 }
  166 + //超出范围
  167 + else if (messageEvent.getMessageType() == Constant.EXIT_RANGE) {
  168 + ChineseToSpeechUtil.speech(getActivity().getApplicationContext(), getString(R.string.exit_range_tip));
  169 + if (mVibrator != null) {
  170 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  171 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  172 + mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1);
  173 + }
  174 + if (tipDialog != null) {
  175 + tipDialog.setTipMsg("您已偏离路径轨迹\n请您计时回归路径!");
  176 + tipDialog.show();
  177 + }
  178 + }
  179 + //进入范围
  180 + else if (messageEvent.getMessageType() == Constant.ENTER_RANGE) {
  181 + ChineseToSpeechUtil.speech(getActivity().getApplicationContext(), getString(R.string.enter_range_tip));
  182 + if (mVibrator != null) {
  183 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  184 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  185 + mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1);
  186 + }
  187 + if (tipDialog != null) {
  188 + tipDialog.setTipMsg("您已回归轨迹\n继续参与运动吧");
  189 + tipDialog.show();
  190 + }
  191 + }
146 192 }
147 193  
148 194 /**
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
... ... @@ -178,7 +178,6 @@ public class RunRaceDetailFragment extends QMUIFragment&lt;RunRaceDetailFragmentVie
178 178 //启动鹰眼成功
179 179 if (messageEvent.getMessageType() == Constant.START_TRACE_GATHER_SUCCESS) {
180 180 if (getMvpView() != null) {
181   - Log.e(TAG, "跳转: " + getMvpView().importStreetPoints.size());
182 181 QMUITipDialogUtil.dismessDialog();
183 182 PedometerMainActivity.startActivity(getActivity(), getMvpView().runRaceDetailInfo);
184 183 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
... ... @@ -199,6 +199,7 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
199 199 mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1);
200 200 }
201 201 if (tipDialog != null) {
  202 + tipDialog.setTipMsg("您已偏离路径轨迹\n请您计时回归路径!");
202 203 tipDialog.show();
203 204 }
204 205 }
... ... @@ -211,6 +212,7 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
211 212 mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1);
212 213 }
213 214 if (tipDialog != null) {
  215 + tipDialog.setTipMsg("您已回归轨迹\n继续参与运动吧");
214 216 tipDialog.show();
215 217 }
216 218 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/TipDialog.java
... ... @@ -54,12 +54,14 @@ public class TipDialog extends Dialog {
54 54 @Override
55 55 protected void onCreate(Bundle savedInstanceState) {
56 56 super.onCreate(savedInstanceState);
57   -
58   -
59 57 //显示视图
60 58 this.setContentView(view);
61 59 }
62 60  
  61 + public void setTipMsg(String tipMsg) {
  62 + tv_dialog_tip.setText(tipMsg);
  63 + }
  64 +
63 65 private void initView(View rootView) {
64 66 this.tv_dialog_tip = (TextView) rootView.findViewById(R.id.tv_dialog_tip);
65 67 this.btn_ok = (Button) rootView.findViewById(R.id.btn_ok);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -32,6 +32,7 @@ public class StepUtil {
32 32 return UUID.randomUUID().toString().replace("-", "");
33 33 }
34 34  
  35 +
35 36 /**
36 37 * 删除临时保存数据
37 38 *
... ...
moudle_pedometer/src/main/res/values/strings.xml
... ... @@ -31,7 +31,6 @@
31 31 <!--赛事详情-->
32 32 <string name="run_race_btn_sign_up">立即报名</string>
33 33 <string name="run_race_btn_start_now">现在开始</string>
34   - <string name="run_race_far_tip">您距离起点较远\n请到达起点附近再开始!</string>
35 34 <!--layout_street-->
36 35 <string name="layout_street_active_point">活动地点</string>
37 36 <string name="layout_street_start_point">(起)</string>
... ... @@ -81,14 +80,16 @@
81 80 <string name="again_up">重新上传</string>
82 81 <string name="myrecord">我的记录</string>
83 82 <string name="up_fail">上传失败</string>
84   - <string name="enter_range_tip">您已回归轨迹 继续参与运动吧</string>
85   - <string name="exit_range_tip">您已偏离路径轨迹 请您计时回归路径!</string>
86   - <string name="more_than_pause_count_tip">您已超过最大暂停次数,无法继续比赛!</string>
  83 + <string name="enter_range_tip">您已回归轨迹继续参与运动吧</string>
  84 + <string name="exit_range_tip">您已偏离路径轨迹请您计时回归路径</string>
  85 + <string name="more_than_pause_count_tip">您已超过最大暂停次数,无法继续比赛</string>
87 86 <string name="run_pause_tip">固定赛事只可暂停一次\n是否确定使用?</string>
88 87 <string name="add_path">添加轨迹</string>
89 88 <string name="addpath">绑定轨迹</string>
90 89 <string name="delect">删除</string>
91 90 <string name="no_fail_line_text_tip">没有上传失败的路线哦</string>
  91 + <string name="run_race_far_tip">您距离起点较远\n请到达起点附近再开始</string>
  92 + <string name="run_race_arrive_end_tip">您已到达终点附近\n可以结束运动了</string>
92 93  
93 94  
94 95 </resources>
... ...