Commit e70e88433b05b2f3de04990a0780df999cea061e

Authored by 杨帅
1 parent 47b15bb5

1 路径工具,打点页面逻辑

moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
@@ -32,17 +32,20 @@ import com.baidu.mapapi.map.Overlay; @@ -32,17 +32,20 @@ import com.baidu.mapapi.map.Overlay;
32 import com.baidu.mapapi.map.UiSettings; 32 import com.baidu.mapapi.map.UiSettings;
33 import com.baidu.mapapi.model.LatLng; 33 import com.baidu.mapapi.model.LatLng;
34 import com.baidu.mapapi.utils.DistanceUtil; 34 import com.baidu.mapapi.utils.DistanceUtil;
  35 +import com.baidu.trace.model.SortType;
  36 +import com.cnlive.moudle.collectionTrace.model.CollectPoint;
  37 +import com.cnlive.moudle.collectionTrace.service.CollStepService;
35 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; 38 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
36 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; 39 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
37 import com.cnlive.moudle.pedometer.model.Constant; 40 import com.cnlive.moudle.pedometer.model.Constant;
38 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; 41 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
39 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; 42 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
  43 +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
40 import com.cnlive.moudle.pedometer.utils.BitmapUtil; 44 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
41 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; 45 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
42 import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; 46 import com.cnlive.moudle.collectionTrace.utils.CollStepUtil;
43 import com.cnlive.moudle.pedometer.utils.GsonUtil; 47 import com.cnlive.moudle.pedometer.utils.GsonUtil;
44 import com.cnlive.moudle.pedometer.utils.MyMapUtil; 48 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
45 -import com.cnlive.moudle.pedometer.utils.StepUtil;  
46 import com.cnlive.moudle.pedometer.utils.TimeUtil; 49 import com.cnlive.moudle.pedometer.utils.TimeUtil;
47 import com.example.moudle_pedometer.R; 50 import com.example.moudle_pedometer.R;
48 import com.hannesdorfmann.mosby3.mvp.MvpView; 51 import com.hannesdorfmann.mosby3.mvp.MvpView;
@@ -60,26 +63,27 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -60,26 +63,27 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
60 private BitmapDescriptor mCurrentMarker;//定位图标 63 private BitmapDescriptor mCurrentMarker;//定位图标
61 private static int accuracyCircleFillColor; 64 private static int accuracyCircleFillColor;
62 private static int accuracyCircleStrokeColor; 65 private static int accuracyCircleStrokeColor;
63 - private static MyLocationData mylocation; 66 + private MyLocationData followMyLocation;
64 boolean isFirstLoc = true; // 是否首次定位 67 boolean isFirstLoc = true; // 是否首次定位
65 private MarkerOptions currentMark; 68 private MarkerOptions currentMark;
66 - private LatLng myCurLatLng;  
67 private Double lastX = 0.0; 69 private Double lastX = 0.0;
68 private int mCurrentDirection = 0; 70 private int mCurrentDirection = 0;
69 - private double mCurrentLat = 0.0;  
70 - private double mCurrentLon = 0.0;  
71 private float mCurrentAccracy; 71 private float mCurrentAccracy;
72 // 定位相关 72 // 定位相关
73 private LocationClient mLocClient; 73 private LocationClient mLocClient;
74 public MyLocationListenner myListener = new MyLocationListenner(); 74 public MyLocationListenner myListener = new MyLocationListenner();
75 - private final int DEFULT_ZOOM = 17; 75 + private int DEFULT_ZOOM = 17;
76 private boolean isFirstLoadMap = true; 76 private boolean isFirstLoadMap = true;
77 private Overlay currentLine; 77 private Overlay currentLine;
78 - private List<LatLng> currentPoints; 78 + private List<LatLng> currentWalkPoints;//用户当前行走的线的集合
79 private CollUserStepEntity userStepEntity; 79 private CollUserStepEntity userStepEntity;
80 private String uid; 80 private String uid;
81 private RunRaceDetailInfo runRaceDetailInfo; 81 private RunRaceDetailInfo runRaceDetailInfo;
82 - private List<Overlay> overlays; 82 + private List<Overlay> allMapOverlays;
  83 + private SelectDialog selectDialog;
  84 + private boolean isShowFollowAddress = false;//是否显示跟随地址
  85 + private String currentAddress;
  86 + private LatLng currentImportLatLng;
83 87
84 public CollRunningMapFragmentView(CollRunningMapFragment fragment) { 88 public CollRunningMapFragmentView(CollRunningMapFragment fragment) {
85 this.fragment = fragment; 89 this.fragment = fragment;
@@ -90,7 +94,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -90,7 +94,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
90 } 94 }
91 95
92 public void initView(RunRaceDetailInfo runRaceDetailInfo) { 96 public void initView(RunRaceDetailInfo runRaceDetailInfo) {
93 - currentPoints = new ArrayList<>(); 97 + initSelectDialog();
94 this.runRaceDetailInfo = runRaceDetailInfo; 98 this.runRaceDetailInfo = runRaceDetailInfo;
95 uid = CollCommonInfo.getUserId(getContext()); 99 uid = CollCommonInfo.getUserId(getContext());
96 userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid); 100 userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
@@ -102,7 +106,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -102,7 +106,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
102 CollStepUtil.setCollStreetTitle(getContext(), CollCommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle()); 106 CollStepUtil.setCollStreetTitle(getContext(), CollCommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle());
103 } 107 }
104 //设置开始时间和赛事id 108 //设置开始时间和赛事id
105 - if (TextUtils.isEmpty(userStepEntity.getStreetId())) { 109 + if (0 == userStepEntity.getStartTimeStamp()) {
106 CollStepUtil.setCollStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CollCommonInfo.getStreetId(getContext())); 110 CollStepUtil.setCollStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CollCommonInfo.getStreetId(getContext()));
107 } 111 }
108 //设置步数 112 //设置步数
@@ -111,26 +115,87 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -111,26 +115,87 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
111 fragment.binding.tvCurrentDiatance.setText(CollStepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + ""); 115 fragment.binding.tvCurrentDiatance.setText(CollStepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + "");
112 } 116 }
113 //设置是否需要设置起点信息 117 //设置是否需要设置起点信息
114 - if (TextUtils.isEmpty(userStepEntity.getCollStartLatLng())||TextUtils.isEmpty(userStepEntity.getCollStartLatLngName())) { 118 + if (TextUtils.isEmpty(userStepEntity.getCollStartPointData())) {
115 //开始设置 119 //开始设置
116 if (!TextUtils.isEmpty(runRaceDetailInfo.getCollStartLatLng()) && !TextUtils.isEmpty(runRaceDetailInfo.getCollStartLntLngName())) { 120 if (!TextUtils.isEmpty(runRaceDetailInfo.getCollStartLatLng()) && !TextUtils.isEmpty(runRaceDetailInfo.getCollStartLntLngName())) {
117 - CollStepUtil.setCollStartPointData(getContext(), uid, runRaceDetailInfo.getCollStartLntLngName(), runRaceDetailInfo.getCollStartLatLng()); 121 + CollectPoint collectPoint = new CollectPoint();
  122 + LatLng latLng = GsonUtil.GsonToBean(runRaceDetailInfo.getCollStartLatLng(), LatLng.class);
  123 + if (null != latLng) {
  124 + collectPoint.setLatitude(latLng.latitude);
  125 + collectPoint.setLongitude(latLng.longitude);
  126 + collectPoint.setPointName(runRaceDetailInfo.getCollStartLntLngName());
  127 + CollStepUtil.setCollStartPointData(getContext(), uid, collectPoint);
  128 + }
118 } 129 }
119 } 130 }
120 initChrom(); 131 initChrom();
121 //初始化起点 132 //初始化起点
122 - overlays = new ArrayList<>(); 133 + allMapOverlays = new ArrayList<>();
123 //打起点(重新获取数据) 134 //打起点(重新获取数据)
124 userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid); 135 userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
125 - if (!TextUtils.isEmpty(userStepEntity.getCollStartLatLng())) {  
126 - LatLng startLatLng = GsonUtil.GsonToBean(userStepEntity.getCollStartLatLng(), LatLng.class);  
127 - if (null != startLatLng) {  
128 - List<Overlay> resultOverlays = MyMapUtil.setStartMarker(getContext(), baiduMap, startLatLng, R.drawable.icon_start);  
129 - if (null != resultOverlays) {  
130 - this.overlays.addAll(resultOverlays); 136 + //查询历史轨迹(用于用户返回后再次进入,无法显示轨迹问题)
  137 + if (0 != userStepEntity.getStartTimeStamp()) {
  138 + //获取当前时间戳
  139 + long currentTimeStamp = TimeUtil.getNowTimeStamp();
  140 + //获取用户开始时间
  141 + long userStartTime = userStepEntity.getStartTimeStamp();
  142 + double result = currentTimeStamp - userStartTime;
  143 + //超过一分钟才进行查询
  144 + if (result > 1 * 60) {
  145 + if (null != CollStepService.mClient) {
  146 + MyMapUtil.queryHistoryTrace(getContext(), CollStepService.mClient, CollStepService.entityName, userStartTime, currentTimeStamp, new MyMapUtil.CallBack() {
  147 + @Override
  148 + public void success(List<LatLng> resultPoints) {
  149 + if (null != resultPoints && resultPoints.size() > 1) {
  150 + //绘制历史轨迹
  151 + MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, 0);
  152 + //将最后一个点添加到用户走的线中
  153 + currentWalkPoints = new ArrayList<>();
  154 + currentWalkPoints.add(resultPoints.get(resultPoints.size() - 1));
  155 + }
  156 + }
  157 + });
  158 + }
  159 + } else {
  160 + //绘制起点
  161 + if (!TextUtils.isEmpty(userStepEntity.getCollStartPointData())) {
  162 + CollectPoint collectPoint = GsonUtil.GsonToBean(userStepEntity.getCollStartPointData(), CollectPoint.class);
  163 + if (null != collectPoint) {
  164 + LatLng startLatLng = new LatLng(collectPoint.getLatitude(), collectPoint.getLongitude());
  165 + //把起点添加到用户走的实时轨迹中
  166 + currentWalkPoints = new ArrayList<>();
  167 + currentWalkPoints.add(startLatLng);
  168 + List<Overlay> resultOverlays = MyMapUtil.setStartMarker(getContext(), baiduMap, startLatLng, R.drawable.icon_start);
  169 + if (null != resultOverlays) {
  170 + this.allMapOverlays.addAll(resultOverlays);
  171 + }
  172 + }
  173 + }
  174 + //
  175 + }
  176 + //
  177 + }
  178 +
  179 +
  180 + //更新可打点数量
  181 + int remainPointNum = updataCanTakePointCount();
  182 + if (remainPointNum != 0) {
  183 + //展示点位信息
  184 + List<CollectPoint> collectPoints = CollStepUtil.getCollImportPointList(getContext(), CollCommonInfo.getUserId(getContext()));
  185 + if (null != collectPoints) {
  186 + for (CollectPoint point : collectPoints) {
  187 + LatLng markLatLng = new LatLng(point.getLatitude(), point.getLongitude());
  188 + if (null != markLatLng) {
  189 + //将点位显示到地图上
  190 + Overlay overlay = MyMapUtil.setMapMarker(getContext(), baiduMap, markLatLng, R.drawable.icon_map_import);
  191 + if (null != overlay) {
  192 + allMapOverlays.add(overlay);
  193 + }
  194 + }
131 } 195 }
132 } 196 }
133 } 197 }
  198 + //
134 } 199 }
135 //返回键 200 //返回键
136 fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() { 201 fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() {
@@ -172,7 +237,83 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -172,7 +237,83 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
172 isFirstLoc = true; 237 isFirstLoc = true;
173 } 238 }
174 }); 239 });
  240 + //开始打点
  241 + fragment.binding.flTakeImportPoint.setOnClickListener(new View.OnClickListener() {
  242 + @Override
  243 + public void onClick(View view) {
  244 + //更新可打点数量
  245 + int remainNum = updataCanTakePointCount();
  246 + if (remainNum != 0) {
  247 + //获取当前地点
  248 + if (!TextUtils.isEmpty(currentAddress)) {
  249 + if (null != followMyLocation) {
  250 + currentImportLatLng = new LatLng(followMyLocation.latitude, followMyLocation.longitude);
  251 + }
  252 + selectDialog.setTipMessage("确定在" + "\"" + currentAddress + "\"" + "打点?");
  253 + selectDialog.show();
  254 + } else {
  255 + isShowFollowAddress = true;
  256 + Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show();
  257 + }
  258 + } else {
  259 + Toast.makeText(getContext(), "打点数量超过最大限制,无法打点!", Toast.LENGTH_SHORT).show();
  260 + }
  261 + }
  262 + });
  263 +
  264 + }
175 265
  266 + /**
  267 + * 更新可打点位数量
  268 + *
  269 + * @return
  270 + */
  271 + private int updataCanTakePointCount() {
  272 + //获取用户可打点的数量
  273 + int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext()));
  274 + if (canTakePointCount < 98) {
  275 + canTakePointCount = 98 - canTakePointCount;
  276 + } else {
  277 + canTakePointCount = 0;
  278 + }
  279 + fragment.binding.tvCanTakePointSize.setText("可打点数量:" + canTakePointCount + "个");
  280 + return canTakePointCount;
  281 + }
  282 +
  283 + private void initSelectDialog() {
  284 + if (selectDialog == null) {
  285 + selectDialog = new SelectDialog(getContext(), "标题", "否", new SelectDialog.DialogInterface() {
  286 + @Override
  287 + public void onClick(SelectDialog dialog) {
  288 + dialog.dismiss();
  289 + isShowFollowAddress = false;
  290 + }
  291 + }, "是", new SelectDialog.DialogInterface() {
  292 + @Override
  293 + public void onClick(SelectDialog dialog) {
  294 + dialog.dismiss();
  295 + isShowFollowAddress = false;
  296 + if (null == currentImportLatLng || TextUtils.isEmpty(currentAddress)) {
  297 + return;
  298 + }
  299 + //将点位保存在数据库中
  300 + CollectPoint collectPoint = new CollectPoint();
  301 + collectPoint.setLatitude(currentImportLatLng.latitude);
  302 + collectPoint.setLongitude(currentImportLatLng.longitude);
  303 + collectPoint.setPointName(currentAddress);
  304 + CollStepUtil.setCollImportPoints(getContext(), CollCommonInfo.getUserId(getContext()), collectPoint);
  305 + //将点位显示到地图上
  306 + Overlay overlay = MyMapUtil.setMapMarker(getContext(), baiduMap, currentImportLatLng, R.drawable.icon_map_import);
  307 + if (null != overlay) {
  308 + allMapOverlays.add(overlay);
  309 + }
  310 + //更新可打点数量
  311 + updataCanTakePointCount();
  312 + }
  313 + });
  314 + selectDialog.setCancelable(false);
  315 + selectDialog.setCanceledOnTouchOutside(false);
  316 + }
176 } 317 }
177 318
178 private void initChrom() { 319 private void initChrom() {
@@ -272,9 +413,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -272,9 +413,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
272 //LocationMode. Device_Sensors:仅使用设备; 413 //LocationMode. Device_Sensors:仅使用设备;
273 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); 414 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
274 //可选,设置是否需要地址信息,默认不需要 415 //可选,设置是否需要地址信息,默认不需要
275 - option.setIsNeedAddress(false); 416 + option.setIsNeedAddress(true);
276 //可选,设置是否需要地址描述 417 //可选,设置是否需要地址描述
277 - option.setIsNeedLocationDescribe(false); 418 + option.setIsNeedLocationDescribe(true);
278 //可选,设置是否需要设备方向结果 419 //可选,设置是否需要设备方向结果
279 option.setNeedDeviceDirect(false); 420 option.setNeedDeviceDirect(false);
280 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 421 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
@@ -320,9 +461,80 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -320,9 +461,80 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
320 @Override 461 @Override
321 public void onReceiveLocation(BDLocation location) { 462 public void onReceiveLocation(BDLocation location) {
322 // map view 销毁后不在处理新接收的位置 463 // map view 销毁后不在处理新接收的位置
323 - if (location == null || mMapView == null) { 464 + if (location == null || mMapView == null || getContext() == null) {
324 return; 465 return;
325 } 466 }
  467 + Log.e(TAG, "onReceiveLocation: 定位地点" + location.getAddress().address);
  468 +
  469 + mCurrentAccracy = location.getRadius();
  470 + followMyLocation = new MyLocationData.Builder()
  471 + .accuracy(location.getRadius())
  472 + // 此处设置开发者获取到的方向信息,顺时针0-360
  473 + .direction(mCurrentDirection).latitude(location.getLatitude())
  474 + .longitude(location.getLongitude()).build();
  475 +// if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) {
  476 +// return;
  477 +// }
  478 + MapStatus.Builder builder = new MapStatus.Builder();
  479 + //第一次定位
  480 + if (isFirstLoc) {
  481 + isFirstLoc = false;
  482 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
  483 + Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
  484 + }
  485 + baiduMap.setMyLocationData(followMyLocation);
  486 + builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM);
  487 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  488 + } else {
  489 + //不是第一次定位状态
  490 + Log.e(TAG, "onReceiveLocation: 当前精度" + location.getRadius());
  491 + //过滤定位精度
  492 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
  493 + return;
  494 + }
  495 + if (null != currentWalkPoints && currentWalkPoints.size() > 0) {
  496 + //进行判断
  497 + LatLng lastLatLng = currentWalkPoints.get(currentWalkPoints.size() - 1);
  498 + LatLng curLatLng = new LatLng(location.getLatitude(),
  499 + location.getLongitude());
  500 + if (DistanceUtil.getDistance(lastLatLng, curLatLng) > 0.5) {
  501 + currentWalkPoints.add(curLatLng);
  502 + }
  503 + } else {
  504 + currentWalkPoints.add(new LatLng(location.getLatitude(),
  505 + location.getLongitude()));
  506 + }
  507 +
  508 + //判断当前集合列表是否可以划线(至少两个点)
  509 + if (currentWalkPoints != null && currentWalkPoints.size() > 1) {
  510 + //判断当前是否已经在地图上画点
  511 + if (currentLine != null) {
  512 + currentLine.remove();
  513 + }
  514 + currentLine = MyMapUtil.drawMapLine(getContext(), baiduMap, currentWalkPoints, R.color.green_round);
  515 + }
  516 + }
  517 + Log.e(TAG, "onReceiveLocation: 运行");
  518 + currentAddress = location.getLocationDescribe();
  519 + if (TextUtils.isEmpty(currentAddress)) {
  520 + if (null != location.getAddress()) {
  521 + currentAddress = location.getAddress().address;
  522 + }
  523 + }
  524 +
  525 + if (isShowFollowAddress && !TextUtils.isEmpty(currentAddress)) {
  526 + //设置当前打点经纬度
  527 + currentImportLatLng = new LatLng(location.getLatitude(), location.getLongitude());
  528 + if (isShowFollowAddress && selectDialog != null && !selectDialog.isShowing()) {
  529 + if (!TextUtils.isEmpty(currentAddress)) {
  530 + selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?");
  531 + if (!selectDialog.isShowing()) {
  532 + selectDialog.show();
  533 + }
  534 + isShowFollowAddress = false;
  535 + }
  536 + }
  537 + }
326 538
327 //正在搜索GPS信号 539 //正在搜索GPS信号
328 if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) { 540 if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) {
@@ -373,66 +585,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -373,66 +585,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
373 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); 585 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
374 } 586 }
375 } 587 }
  588 + }
376 589
377 - if (isFirstLoc) {  
378 - isFirstLoc = false;  
379 - if (location.getRadius() > Constant.LOCA_ACCURACY) {  
380 - Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();  
381 - }  
382 -  
383 -  
384 - } else {  
385 - //过滤定位精度  
386 - if (location.getRadius() > Constant.LOCA_ACCURACY) {  
387 - return;  
388 - }  
389 - }  
390 - mCurrentAccracy = location.getRadius();  
391 - mylocation = new MyLocationData.Builder()  
392 - .accuracy(location.getRadius())  
393 - // 此处设置开发者获取到的方向信息,顺时针0-360  
394 - .direction(mCurrentDirection).latitude(location.getLatitude())  
395 - .longitude(location.getLongitude()).build();  
396 - if (mylocation == null || mylocation.latitude == 0 || mylocation.longitude == 0) {  
397 - return;  
398 - }  
399 - MapStatus.Builder builder = new MapStatus.Builder();  
400 - //不是第一次定位状态  
401 - if (!isFirstLoc) {  
402 - baiduMap.setMyLocationData(mylocation);  
403 - builder.target(new LatLng(mylocation.latitude, mylocation.longitude)).zoom(DEFULT_ZOOM);  
404 - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));  
405 - if (currentPoints.size() > 0) {  
406 - //进行判断  
407 - LatLng lastLatLng = currentPoints.get(currentPoints.size() - 1);  
408 - LatLng curLatLng = new LatLng(location.getLatitude(),  
409 - location.getLongitude());  
410 - if (DistanceUtil.getDistance(lastLatLng, curLatLng) > 0.5) {  
411 - currentPoints.add(curLatLng);  
412 - }  
413 - } else {  
414 - currentPoints.add(new LatLng(location.getLatitude(),  
415 - location.getLongitude()));  
416 - }  
417 -  
418 - //判断当前集合列表是否可以划线(至少两个点)  
419 - if (currentPoints != null && currentPoints.size() > 1) {  
420 - //判断当前是否已经在地图上画点  
421 - if (currentLine != null) {  
422 - currentLine.remove();  
423 - }  
424 - //开始划线  
425 - if (getContext() == null) {  
426 - return;  
427 - }  
428 - currentLine = MyMapUtil.drawMapLine(getContext(), baiduMap, currentPoints, R.color.red);  
429 - }  
430 590
431 - }  
432 - myCurLatLng = new LatLng(location.getLatitude(),  
433 - location.getLongitude());  
434 - baiduMap.setMyLocationData(mylocation);  
435 - }  
436 } 591 }
437 592
438 593
@@ -483,13 +638,13 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -483,13 +638,13 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
483 double x = sensorEvent.values[SensorManager.DATA_X]; 638 double x = sensorEvent.values[SensorManager.DATA_X];
484 if (Math.abs(x - lastX) > 1.0) { 639 if (Math.abs(x - lastX) > 1.0) {
485 mCurrentDirection = (int) x; 640 mCurrentDirection = (int) x;
486 - if (mylocation != null) {  
487 - mylocation = new MyLocationData.Builder() 641 + if (followMyLocation != null) {
  642 + followMyLocation = new MyLocationData.Builder()
488 .accuracy(mCurrentAccracy) 643 .accuracy(mCurrentAccracy)
489 // 此处设置开发者获取到的方向信息,顺时针0-360 644 // 此处设置开发者获取到的方向信息,顺时针0-360
490 - .direction(mCurrentDirection).latitude(mylocation.latitude)  
491 - .longitude(mylocation.longitude).build();  
492 - baiduMap.setMyLocationData(mylocation); 645 + .direction(mCurrentDirection).latitude(followMyLocation.latitude)
  646 + .longitude(followMyLocation.longitude).build();
  647 + baiduMap.setMyLocationData(followMyLocation);
493 } 648 }
494 } 649 }
495 lastX = x; 650 lastX = x;
@@ -506,12 +661,12 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -506,12 +661,12 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
506 * @param lastPoint 661 * @param lastPoint
507 */ 662 */
508 public void setHistoryLastPoint(LatLng lastPoint) { 663 public void setHistoryLastPoint(LatLng lastPoint) {
509 - if (currentPoints != null) {  
510 - currentPoints.clear();  
511 - currentPoints.add(lastPoint); 664 + if (currentWalkPoints != null) {
  665 + currentWalkPoints.clear();
  666 + currentWalkPoints.add(lastPoint);
512 } else { 667 } else {
513 - currentPoints = new ArrayList<>();  
514 - currentPoints.add(lastPoint); 668 + currentWalkPoints = new ArrayList<>();
  669 + currentWalkPoints.add(lastPoint);
515 } 670 }
516 } 671 }
517 672
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
@@ -108,12 +108,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -108,12 +108,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
108 fragment.binding.btnIdentify.setOnClickListener(new View.OnClickListener() { 108 fragment.binding.btnIdentify.setOnClickListener(new View.OnClickListener() {
109 @Override 109 @Override
110 public void onClick(View view) { 110 public void onClick(View view) {
111 - isShowFollowAddress = true;  
112 //获取当前地点 111 //获取当前地点
113 if (!TextUtils.isEmpty(currentAddress)) { 112 if (!TextUtils.isEmpty(currentAddress)) {
114 selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?"); 113 selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?");
115 selectDialog.show(); 114 selectDialog.show();
116 } else { 115 } else {
  116 + isShowFollowAddress = true;
117 Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show(); 117 Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show();
118 } 118 }
119 } 119 }
@@ -305,13 +305,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -305,13 +305,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
305 .longitude(location.getLongitude()).build(); 305 .longitude(location.getLongitude()).build();
306 // currentAddress = location.getAddrStr(); 306 // currentAddress = location.getAddrStr();
307 currentAddress = location.getLocationDescribe(); 307 currentAddress = location.getLocationDescribe();
308 - if (selectDialog != null && selectDialog.isShowing()) {  
309 - selectDialog.setTipMessage(currentAddress);  
310 - }  
311 if (isShowFollowAddress && selectDialog != null && !selectDialog.isShowing()) { 308 if (isShowFollowAddress && selectDialog != null && !selectDialog.isShowing()) {
312 if (!TextUtils.isEmpty(currentAddress)) { 309 if (!TextUtils.isEmpty(currentAddress)) {
313 selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?"); 310 selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?");
314 - selectDialog.show(); 311 + if (!selectDialog.isShowing()) {
  312 + selectDialog.show();
  313 + }
315 } 314 }
316 } 315 }
317 if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) { 316 if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) {
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/model/CollectPoint.java
@@ -3,24 +3,24 @@ package com.cnlive.moudle.collectionTrace.model; @@ -3,24 +3,24 @@ package com.cnlive.moudle.collectionTrace.model;
3 import com.baidu.mapapi.model.LatLng; 3 import com.baidu.mapapi.model.LatLng;
4 4
5 public class CollectPoint { 5 public class CollectPoint {
6 - private double lat;  
7 - private double lng; 6 + private double latitude;
  7 + private double longitude;
8 private String pointName; 8 private String pointName;
9 9
10 - public double getLat() {  
11 - return lat; 10 + public double getLatitude() {
  11 + return latitude;
12 } 12 }
13 13
14 - public void setLat(double lat) {  
15 - this.lat = lat; 14 + public void setLatitude(double latitude) {
  15 + this.latitude = latitude;
16 } 16 }
17 17
18 - public double getLng() {  
19 - return lng; 18 + public double getLongitude() {
  19 + return longitude;
20 } 20 }
21 21
22 - public void setLng(double lng) {  
23 - this.lng = lng; 22 + public void setLongitude(double longitude) {
  23 + this.longitude = longitude;
24 } 24 }
25 25
26 public String getPointName() { 26 public String getPointName() {
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/utils/CollStepUtil.java
@@ -33,6 +33,61 @@ public class CollStepUtil { @@ -33,6 +33,61 @@ public class CollStepUtil {
33 } 33 }
34 34
35 /** 35 /**
  36 + * 获取打点详细
  37 + *
  38 + * @param context
  39 + * @param uid
  40 + */
  41 + public static List<CollectPoint> getCollImportPointList(Context context, String uid) {
  42 + //先获取有没有
  43 + if (getCollUserStepData(context, uid) != null) {
  44 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  45 + if (null != entity) {
  46 + //判断有没有打过点
  47 + if (!TextUtils.isEmpty(entity.getImportPoint())) {
  48 + //已经打过点,先把打的点取出来
  49 + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class);
  50 + if (null != lngs) {
  51 + return lngs;
  52 + } else {
  53 + return null;
  54 + }
  55 + }
  56 + }
  57 + }
  58 + return null;
  59 + }
  60 +
  61 +
  62 + /**
  63 + * 获取打点数量重要点
  64 + *
  65 + * @param context
  66 + * @param uid
  67 + */
  68 + public static int getCollImportPointSize(Context context, String uid) {
  69 + //先获取有没有
  70 + if (getCollUserStepData(context, uid) != null) {
  71 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  72 + if (null != entity) {
  73 + //判断有没有打过点
  74 + if (!TextUtils.isEmpty(entity.getImportPoint())) {
  75 + //已经打过点,先把打的点取出来
  76 + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class);
  77 + if (null != lngs) {
  78 + return lngs.size();
  79 + } else {
  80 + return 98;
  81 + }
  82 + } else {
  83 + return 0;
  84 + }
  85 + }
  86 + }
  87 + return 98;
  88 + }
  89 +
  90 + /**
36 * 初始化数据库 91 * 初始化数据库
37 * 92 *
38 * @param context 93 * @param context
@@ -53,16 +108,13 @@ public class CollStepUtil { @@ -53,16 +108,13 @@ public class CollStepUtil {
53 * 108 *
54 * @param context 109 * @param context
55 * @param uid 110 * @param uid
56 - * @param startPointName  
57 - * @param startPointLatLng  
58 */ 111 */
59 - public static void setCollStartPointData(Context context, String uid, String startPointName, String startPointLatLng) { 112 + public static void setCollStartPointData(Context context, String uid, CollectPoint collectPoint) {
60 //先获取有没有 113 //先获取有没有
61 if (getCollUserStepData(context, uid) != null) { 114 if (getCollUserStepData(context, uid) != null) {
62 CollUserStepEntity entity = getCollUserStepData(context, uid); 115 CollUserStepEntity entity = getCollUserStepData(context, uid);
63 if (null != entity) { 116 if (null != entity) {
64 - entity.setCollStartLatLngName(startPointName);  
65 - entity.setCollStartLatLng(startPointLatLng); 117 + entity.setCollStartPointData(GsonUtil.GsonString(collectPoint));
66 //更新数据 118 //更新数据
67 updateCollStepData(context, entity); 119 updateCollStepData(context, entity);
68 } 120 }
@@ -74,9 +126,9 @@ public class CollStepUtil { @@ -74,9 +126,9 @@ public class CollStepUtil {
74 * 126 *
75 * @param context 127 * @param context
76 * @param uid 128 * @param uid
77 - * @param latLng 129 + * @param collectPoint
78 */ 130 */
79 - public static void setImportPoints(Context context, String uid, LatLng latLng) { 131 + public static void setCollImportPoints(Context context, String uid, CollectPoint collectPoint) {
80 //先获取有没有 132 //先获取有没有
81 if (getCollUserStepData(context, uid) != null) { 133 if (getCollUserStepData(context, uid) != null) {
82 CollUserStepEntity entity = getCollUserStepData(context, uid); 134 CollUserStepEntity entity = getCollUserStepData(context, uid);
@@ -84,11 +136,11 @@ public class CollStepUtil { @@ -84,11 +136,11 @@ public class CollStepUtil {
84 //判断有没有打过点 136 //判断有没有打过点
85 if (!TextUtils.isEmpty(entity.getImportPoint())) { 137 if (!TextUtils.isEmpty(entity.getImportPoint())) {
86 //已经打过点,先把打的点取出来 138 //已经打过点,先把打的点取出来
87 - List<LatLng> lngs = GsonUtil.jsonToList(entity.getImportPoint(), LatLng.class); 139 + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class);
88 if (null != lngs) { 140 if (null != lngs) {
89 //加入新打的点 141 //加入新打的点
90 - if (!lngs.contains(latLng)) {  
91 - lngs.add(latLng); 142 + if (!lngs.contains(collectPoint)) {
  143 + lngs.add(collectPoint);
92 //重新设置打的点 144 //重新设置打的点
93 entity.setImportPoint(GsonUtil.GsonString(lngs)); 145 entity.setImportPoint(GsonUtil.GsonString(lngs));
94 //更新数据 146 //更新数据
@@ -100,8 +152,8 @@ public class CollStepUtil { @@ -100,8 +152,8 @@ public class CollStepUtil {
100 //没有打过点 152 //没有打过点
101 else { 153 else {
102 //则设置一个 154 //则设置一个
103 - List<LatLng> lngs = new ArrayList<>();  
104 - lngs.add(latLng); 155 + List<CollectPoint> lngs = new ArrayList<>();
  156 + lngs.add(collectPoint);
105 //重新设置打的点 157 //重新设置打的点
106 entity.setImportPoint(GsonUtil.GsonString(lngs)); 158 entity.setImportPoint(GsonUtil.GsonString(lngs));
107 //更新数据 159 //更新数据
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
1 package com.cnlive.moudle.pedometer.model; 1 package com.cnlive.moudle.pedometer.model;
2 2
3 public class Constant { 3 public class Constant {
4 -// public static final long SERVICE_ID = 213511;//公司账号 4 + // public static final long SERVICE_ID = 213511;//公司账号
5 public static final long SERVICE_ID = 213553; 5 public static final long SERVICE_ID = 213553;
6 6
7 public static final int TAG = 1; 7 public static final int TAG = 1;
@@ -15,6 +15,9 @@ public class Constant { @@ -15,6 +15,9 @@ public class Constant {
15 public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器 15 public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器
16 public static final int EXIT_RANGE = 5;//超出范围 16 public static final int EXIT_RANGE = 5;//超出范围
17 public static final int ENTER_RANGE = 6;//进入范围 17 public static final int ENTER_RANGE = 6;//进入范围
  18 +
  19 +
  20 + /*****************************************运营工具****************************************************/
18 public static final int COLL_SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度 21 public static final int COLL_SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度
19 public static final int COLL_SERVICE_STEP_COUNT_UPDATE = 0;//步数更新 22 public static final int COLL_SERVICE_STEP_COUNT_UPDATE = 0;//步数更新
20 public static final int COLL_START_TRACE_GATHER_SUCCESS = 7;//启动轨迹服务成功(运营) 23 public static final int COLL_START_TRACE_GATHER_SUCCESS = 7;//启动轨迹服务成功(运营)
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/CollUserStepEntityDao.java
@@ -45,8 +45,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -45,8 +45,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
45 public final static Property StreetTitle = new Property(18, String.class, "streetTitle", false, "STREET_TITLE"); 45 public final static Property StreetTitle = new Property(18, String.class, "streetTitle", false, "STREET_TITLE");
46 public final static Property EndLatLng = new Property(19, String.class, "endLatLng", false, "END_LAT_LNG"); 46 public final static Property EndLatLng = new Property(19, String.class, "endLatLng", false, "END_LAT_LNG");
47 public final static Property IsArriveEndPoint = new Property(20, boolean.class, "isArriveEndPoint", false, "IS_ARRIVE_END_POINT"); 47 public final static Property IsArriveEndPoint = new Property(20, boolean.class, "isArriveEndPoint", false, "IS_ARRIVE_END_POINT");
48 - public final static Property CollStartLatLngName = new Property(21, String.class, "collStartLatLngName", false, "COLL_START_LAT_LNG_NAME");  
49 - public final static Property CollStartLatLng = new Property(22, String.class, "collStartLatLng", false, "COLL_START_LAT_LNG"); 48 + public final static Property CollStartPointData = new Property(21, String.class, "collStartPointData", false, "COLL_START_POINT_DATA");
50 } 49 }
51 50
52 51
@@ -83,8 +82,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -83,8 +82,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
83 "\"STREET_TITLE\" TEXT," + // 18: streetTitle 82 "\"STREET_TITLE\" TEXT," + // 18: streetTitle
84 "\"END_LAT_LNG\" TEXT," + // 19: endLatLng 83 "\"END_LAT_LNG\" TEXT," + // 19: endLatLng
85 "\"IS_ARRIVE_END_POINT\" INTEGER NOT NULL ," + // 20: isArriveEndPoint 84 "\"IS_ARRIVE_END_POINT\" INTEGER NOT NULL ," + // 20: isArriveEndPoint
86 - "\"COLL_START_LAT_LNG_NAME\" TEXT," + // 21: collStartLatLngName  
87 - "\"COLL_START_LAT_LNG\" TEXT);"); // 22: collStartLatLng 85 + "\"COLL_START_POINT_DATA\" TEXT);"); // 21: collStartPointData
88 } 86 }
89 87
90 /** Drops the underlying database table. */ 88 /** Drops the underlying database table. */
@@ -154,14 +152,9 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -154,14 +152,9 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
154 } 152 }
155 stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L); 153 stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L);
156 154
157 - String collStartLatLngName = entity.getCollStartLatLngName();  
158 - if (collStartLatLngName != null) {  
159 - stmt.bindString(22, collStartLatLngName);  
160 - }  
161 -  
162 - String collStartLatLng = entity.getCollStartLatLng();  
163 - if (collStartLatLng != null) {  
164 - stmt.bindString(23, collStartLatLng); 155 + String collStartPointData = entity.getCollStartPointData();
  156 + if (collStartPointData != null) {
  157 + stmt.bindString(22, collStartPointData);
165 } 158 }
166 } 159 }
167 160
@@ -226,14 +219,9 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -226,14 +219,9 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
226 } 219 }
227 stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L); 220 stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L);
228 221
229 - String collStartLatLngName = entity.getCollStartLatLngName();  
230 - if (collStartLatLngName != null) {  
231 - stmt.bindString(22, collStartLatLngName);  
232 - }  
233 -  
234 - String collStartLatLng = entity.getCollStartLatLng();  
235 - if (collStartLatLng != null) {  
236 - stmt.bindString(23, collStartLatLng); 222 + String collStartPointData = entity.getCollStartPointData();
  223 + if (collStartPointData != null) {
  224 + stmt.bindString(22, collStartPointData);
237 } 225 }
238 } 226 }
239 227
@@ -266,8 +254,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -266,8 +254,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
266 cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // streetTitle 254 cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // streetTitle
267 cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // endLatLng 255 cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // endLatLng
268 cursor.getShort(offset + 20) != 0, // isArriveEndPoint 256 cursor.getShort(offset + 20) != 0, // isArriveEndPoint
269 - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // collStartLatLngName  
270 - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22) // collStartLatLng 257 + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21) // collStartPointData
271 ); 258 );
272 return entity; 259 return entity;
273 } 260 }
@@ -295,8 +282,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin @@ -295,8 +282,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
295 entity.setStreetTitle(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); 282 entity.setStreetTitle(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
296 entity.setEndLatLng(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); 283 entity.setEndLatLng(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
297 entity.setIsArriveEndPoint(cursor.getShort(offset + 20) != 0); 284 entity.setIsArriveEndPoint(cursor.getShort(offset + 20) != 0);
298 - entity.setCollStartLatLngName(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));  
299 - entity.setCollStartLatLng(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); 285 + entity.setCollStartPointData(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
300 } 286 }
301 287
302 @Override 288 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/CollUserStepEntity.java
@@ -28,15 +28,14 @@ public class CollUserStepEntity { @@ -28,15 +28,14 @@ public class CollUserStepEntity {
28 private String streetTitle;//赛事标题 28 private String streetTitle;//赛事标题
29 private String endLatLng;//终点坐标 29 private String endLatLng;//终点坐标
30 private boolean isArriveEndPoint;//是否到达终点 30 private boolean isArriveEndPoint;//是否到达终点
31 - private String collStartLatLngName;//运营打点名称  
32 - private String collStartLatLng;//运营打点名称 31 + private String collStartPointData;//运营打点名称和经纬度
33 32
34 - @Generated(hash = 1127995406) 33 + @Generated(hash = 1720877205)
35 public CollUserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, 34 public CollUserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount,
36 String serverTraceData, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, 35 String serverTraceData, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount,
37 long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime, 36 long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime,
38 String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle, 37 String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle,
39 - String endLatLng, boolean isArriveEndPoint, String collStartLatLngName, String collStartLatLng) { 38 + String endLatLng, boolean isArriveEndPoint, String collStartPointData) {
40 this.userId = userId; 39 this.userId = userId;
41 this.date = date; 40 this.date = date;
42 this.stepCount = stepCount; 41 this.stepCount = stepCount;
@@ -58,8 +57,7 @@ public class CollUserStepEntity { @@ -58,8 +57,7 @@ public class CollUserStepEntity {
58 this.streetTitle = streetTitle; 57 this.streetTitle = streetTitle;
59 this.endLatLng = endLatLng; 58 this.endLatLng = endLatLng;
60 this.isArriveEndPoint = isArriveEndPoint; 59 this.isArriveEndPoint = isArriveEndPoint;
61 - this.collStartLatLngName = collStartLatLngName;  
62 - this.collStartLatLng = collStartLatLng; 60 + this.collStartPointData = collStartPointData;
63 } 61 }
64 62
65 @Generated(hash = 681143087) 63 @Generated(hash = 681143087)
@@ -235,20 +233,13 @@ public class CollUserStepEntity { @@ -235,20 +233,13 @@ public class CollUserStepEntity {
235 this.isArriveEndPoint = isArriveEndPoint; 233 this.isArriveEndPoint = isArriveEndPoint;
236 } 234 }
237 235
238 - public String getCollStartLatLngName() {  
239 - return this.collStartLatLngName;  
240 - }  
241 -  
242 - public void setCollStartLatLngName(String collStartLatLngName) {  
243 - this.collStartLatLngName = collStartLatLngName;  
244 - }  
245 236
246 - public String getCollStartLatLng() {  
247 - return this.collStartLatLng; 237 + public String getCollStartPointData() {
  238 + return this.collStartPointData;
248 } 239 }
249 240
250 - public void setCollStartLatLng(String collStartLatLng) {  
251 - this.collStartLatLng = collStartLatLng; 241 + public void setCollStartPointData(String collStartPointData) {
  242 + this.collStartPointData = collStartPointData;
252 } 243 }
253 244
254 245
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
@@ -52,6 +52,48 @@ public class MyMapUtil { @@ -52,6 +52,48 @@ public class MyMapUtil {
52 private static int pageIndex = 1; 52 private static int pageIndex = 1;
53 private static List<LatLng> trackPoints; 53 private static List<LatLng> trackPoints;
54 54
  55 +
  56 + /**
  57 + * 在地图上进行打点
  58 + *
  59 + * @param context
  60 + * @param baiduMap
  61 + * @param startLatLng
  62 + * @param startIconRes
  63 + * @return
  64 + */
  65 + public static Overlay setMapMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) {
  66 + if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) {
  67 + return null;
  68 + }
  69 + try {
  70 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 17, 30);
  71 + OverlayOptions startOptions = null;
  72 + if (pointBitmap != null) {
  73 + startOptions = new MarkerOptions().position(startLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  74 + }
  75 +
  76 + if (startOptions != null) {
  77 + return baiduMap.addOverlay(startOptions);
  78 +
  79 + } else {
  80 + return null;
  81 + }
  82 + } catch (
  83 + Exception e) {
  84 + return null;
  85 + }
  86 + }
  87 +
  88 + /**
  89 + * 打上运营选择的开始点
  90 + *
  91 + * @param context
  92 + * @param baiduMap
  93 + * @param startLatLng
  94 + * @param startIconRes
  95 + * @return
  96 + */
55 public static List<Overlay> setStartMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) { 97 public static List<Overlay> setStartMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) {
56 if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) { 98 if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) {
57 return null; 99 return null;
moudle_pedometer/src/main/res/drawable-hdpi/icon_map_import.png 0 → 100644

1.4 KB

moudle_pedometer/src/main/res/drawable-xhdpi/icon_map_import.png 0 → 100644

1.21 KB

moudle_pedometer/src/main/res/drawable-xxhdpi/icon_map_import.png 0 → 100644

3.51 KB

moudle_pedometer/src/main/res/layout/fragment_collect_running_map.xml
@@ -50,9 +50,9 @@ @@ -50,9 +50,9 @@
50 android:layout_width="80dp" 50 android:layout_width="80dp"
51 android:layout_height="35dp" 51 android:layout_height="35dp"
52 android:layout_gravity="right" 52 android:layout_gravity="right"
53 - android:scaleType="fitXY"  
54 android:background="@drawable/gps_white_shadow" 53 android:background="@drawable/gps_white_shadow"
55 - android:gravity="center"> 54 + android:gravity="center"
  55 + android:scaleType="fitXY">
56 56
57 <TextView 57 <TextView
58 android:layout_width="wrap_content" 58 android:layout_width="wrap_content"
@@ -121,6 +121,7 @@ @@ -121,6 +121,7 @@
121 android:layout_height="wrap_content" 121 android:layout_height="wrap_content"
122 android:layout_gravity="center" 122 android:layout_gravity="center"
123 android:layout_marginBottom="5dp" 123 android:layout_marginBottom="5dp"
  124 + android:focusable="false"
124 android:text="打点" 125 android:text="打点"
125 android:textColor="@color/text_black" 126 android:textColor="@color/text_black"
126 android:textSize="15sp" /> 127 android:textSize="15sp" />
@@ -148,90 +149,108 @@ @@ -148,90 +149,108 @@
148 149
149 <LinearLayout 150 <LinearLayout
150 android:layout_width="match_parent" 151 android:layout_width="match_parent"
151 - android:layout_height="130dp" 152 + android:layout_height="140dp"
152 android:layout_gravity="bottom" 153 android:layout_gravity="bottom"
153 android:layout_marginBottom="10dp" 154 android:layout_marginBottom="10dp"
154 android:background="@drawable/white_shadow_bg" 155 android:background="@drawable/white_shadow_bg"
  156 + android:orientation="vertical"
155 android:scaleX="1.02"> 157 android:scaleX="1.02">
156 158
  159 + <TextView
  160 + android:id="@+id/tv_can_take_point_size"
  161 + android:layout_width="wrap_content"
  162 + android:layout_height="wrap_content"
  163 + android:layout_marginLeft="30dp"
  164 + android:layout_marginTop="10dp"
  165 + android:text="可打点数量"
  166 + android:textColor="@color/text_black"
  167 + android:textSize="12sp"
  168 + android:textStyle="bold" />
  169 +
157 <LinearLayout 170 <LinearLayout
158 - android:layout_width="0dp"  
159 - android:layout_height="match_parent"  
160 - android:layout_weight="1.2"  
161 - android:gravity="center"  
162 - android:orientation="vertical"  
163 - android:paddingLeft="5dp"  
164 - android:paddingRight="5dp"> 171 + android:layout_width="match_parent"
  172 + android:layout_height="match_parent">
165 173
166 - <TextView  
167 - android:id="@+id/tv_current_speed"  
168 - android:layout_width="wrap_content"  
169 - android:layout_height="wrap_content"  
170 - android:text="--"  
171 - android:textColor="@color/black"  
172 - android:textSize="20sp"  
173 - android:textStyle="bold" /> 174 + <LinearLayout
  175 + android:layout_width="0dp"
  176 + android:layout_height="match_parent"
  177 + android:layout_weight="1.2"
  178 + android:gravity="center"
  179 + android:orientation="vertical"
  180 + android:paddingLeft="5dp"
  181 + android:paddingRight="5dp">
174 182
175 - <TextView  
176 - android:layout_width="wrap_content"  
177 - android:layout_height="wrap_content"  
178 - android:layout_marginTop="10dp"  
179 - android:text="配速"  
180 - android:textColor="@color/black"  
181 - android:textSize="15sp" />  
182 - </LinearLayout> 183 + <TextView
  184 + android:id="@+id/tv_current_speed"
  185 + android:layout_width="wrap_content"
  186 + android:layout_height="wrap_content"
  187 + android:text="--"
  188 + android:textColor="@color/black"
  189 + android:textSize="20sp"
  190 + android:textStyle="bold" />
183 191
184 - <LinearLayout  
185 - android:layout_width="0dp"  
186 - android:layout_height="match_parent"  
187 - android:layout_weight="1.2"  
188 - android:gravity="center"  
189 - android:orientation="vertical"> 192 + <TextView
  193 + android:layout_width="wrap_content"
  194 + android:layout_height="wrap_content"
  195 + android:layout_marginTop="10dp"
  196 + android:text="配速"
  197 + android:textColor="@color/black"
  198 + android:textSize="15sp" />
  199 + </LinearLayout>
190 200
191 - <Chronometer  
192 - android:id="@+id/chronometer"  
193 - android:layout_width="wrap_content"  
194 - android:layout_height="wrap_content"  
195 - android:format="00:00:00"  
196 - android:textColor="@color/black"  
197 - android:textSize="20sp"  
198 - android:textStyle="bold" /> 201 + <LinearLayout
  202 + android:layout_width="0dp"
  203 + android:layout_height="match_parent"
  204 + android:layout_weight="1.2"
  205 + android:gravity="center"
  206 + android:orientation="vertical">
199 207
200 - <TextView  
201 - android:layout_width="wrap_content"  
202 - android:layout_height="wrap_content"  
203 - android:layout_marginTop="10dp"  
204 - android:text="用时"  
205 - android:textColor="@color/black"  
206 - android:textSize="15sp" />  
207 - </LinearLayout> 208 + <Chronometer
  209 + android:id="@+id/chronometer"
  210 + android:layout_width="wrap_content"
  211 + android:layout_height="wrap_content"
  212 + android:format="00:00:00"
  213 + android:textColor="@color/black"
  214 + android:textSize="20sp"
  215 + android:textStyle="bold" />
208 216
  217 + <TextView
  218 + android:layout_width="wrap_content"
  219 + android:layout_height="wrap_content"
  220 + android:layout_marginTop="10dp"
  221 + android:text="用时"
  222 + android:textColor="@color/black"
  223 + android:textSize="15sp" />
  224 + </LinearLayout>
209 225
210 - <LinearLayout  
211 - android:layout_width="0dp"  
212 - android:layout_height="match_parent"  
213 - android:layout_weight="1"  
214 - android:gravity="center"  
215 - android:orientation="vertical"  
216 - android:paddingLeft="5dp"  
217 - android:paddingRight="5dp">  
218 226
219 - <TextView  
220 - android:id="@+id/tv_current_diatance"  
221 - android:layout_width="wrap_content"  
222 - android:layout_height="wrap_content"  
223 - android:text="--"  
224 - android:textColor="@color/black"  
225 - android:textSize="20sp"  
226 - android:textStyle="bold" /> 227 + <LinearLayout
  228 + android:layout_width="0dp"
  229 + android:layout_height="match_parent"
  230 + android:layout_marginRight="10dp"
  231 + android:layout_weight="1"
  232 + android:gravity="center"
  233 + android:orientation="vertical"
  234 + android:paddingLeft="5dp"
  235 + android:paddingRight="5dp">
227 236
228 - <TextView  
229 - android:layout_width="wrap_content"  
230 - android:layout_height="wrap_content"  
231 - android:layout_marginTop="10dp"  
232 - android:text="距离(km)"  
233 - android:textColor="@color/black"  
234 - android:textSize="15sp" /> 237 + <TextView
  238 + android:id="@+id/tv_current_diatance"
  239 + android:layout_width="wrap_content"
  240 + android:layout_height="wrap_content"
  241 + android:text="--"
  242 + android:textColor="@color/black"
  243 + android:textSize="20sp"
  244 + android:textStyle="bold" />
  245 +
  246 + <TextView
  247 + android:layout_width="wrap_content"
  248 + android:layout_height="wrap_content"
  249 + android:layout_marginTop="10dp"
  250 + android:text="距离(km)"
  251 + android:textColor="@color/black"
  252 + android:textSize="15sp" />
  253 + </LinearLayout>
235 </LinearLayout> 254 </LinearLayout>
236 255
237 </LinearLayout> 256 </LinearLayout>