Commit a90484e214e90a0896fd6ab65c7fa910de0565be
1 parent
259138b6
1 修复BUG
Showing
2 changed files
with
51 additions
and
17 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
| @@ -76,6 +76,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { | @@ -76,6 +76,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { | ||
| 76 | private SelectDialog selectDialog; | 76 | private SelectDialog selectDialog; |
| 77 | private boolean isShowFollowAddress = false;//是否显示跟随地址 | 77 | private boolean isShowFollowAddress = false;//是否显示跟随地址 |
| 78 | public RunRaceDetailInfo runRaceDetailInfo; | 78 | public RunRaceDetailInfo runRaceDetailInfo; |
| 79 | + private boolean isFollowUserShow = true;//是否跟随用户视角 | ||
| 79 | 80 | ||
| 80 | public StartTraceFragmentView(StartTraceFragment fragment) { | 81 | public StartTraceFragmentView(StartTraceFragment fragment) { |
| 81 | this.fragment = fragment; | 82 | this.fragment = fragment; |
| @@ -442,10 +443,13 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { | @@ -442,10 +443,13 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { | ||
| 442 | // 此处设置开发者获取到的方向信息,顺时针0-360 | 443 | // 此处设置开发者获取到的方向信息,顺时针0-360 |
| 443 | .direction(location.getDirection()).latitude(location.getLatitude()) | 444 | .direction(location.getDirection()).latitude(location.getLatitude()) |
| 444 | .longitude(location.getLongitude()).build(); | 445 | .longitude(location.getLongitude()).build(); |
| 445 | - baiduMap.setMyLocationData(followMyLocation); | ||
| 446 | - MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 447 | - builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM); | ||
| 448 | - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | 446 | + if (isFollowUserShow) { |
| 447 | + baiduMap.setMyLocationData(followMyLocation); | ||
| 448 | + MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 449 | + builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM); | ||
| 450 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 451 | + isFollowUserShow=false; | ||
| 452 | + } | ||
| 449 | } | 453 | } |
| 450 | // if (location.hasAddr()) { | 454 | // if (location.hasAddr()) { |
| 451 | // if (!TextUtils.isEmpty(location.getAddress().address)) { | 455 | // if (!TextUtils.isEmpty(location.getAddress().address)) { |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
| @@ -69,6 +69,9 @@ public class MyMapUtil { | @@ -69,6 +69,9 @@ public class MyMapUtil { | ||
| 69 | * @param geoCodeResult | 69 | * @param geoCodeResult |
| 70 | */ | 70 | */ |
| 71 | public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) { | 71 | public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) { |
| 72 | + if (null == latLng) { | ||
| 73 | + return; | ||
| 74 | + } | ||
| 72 | if (null == mSearch) { | 75 | if (null == mSearch) { |
| 73 | mSearch = GeoCoder.newInstance(); | 76 | mSearch = GeoCoder.newInstance(); |
| 74 | } | 77 | } |
| @@ -87,15 +90,15 @@ public class MyMapUtil { | @@ -87,15 +90,15 @@ public class MyMapUtil { | ||
| 87 | queryGeoCount = 0; | 90 | queryGeoCount = 0; |
| 88 | if (null != geoCodeResult) { | 91 | if (null != geoCodeResult) { |
| 89 | List<PoiInfo> pois = reverseGeoCodeResult.getPoiList(); | 92 | List<PoiInfo> pois = reverseGeoCodeResult.getPoiList(); |
| 90 | - if (null != pois&&pois.size()>0) { | ||
| 91 | - if (!TextUtils.isEmpty(pois.get(0).name)){ | 93 | + if (null != pois && pois.size() > 0) { |
| 94 | + if (!TextUtils.isEmpty(pois.get(0).name)) { | ||
| 92 | geoCodeResult.success(pois.get(0).name); | 95 | geoCodeResult.success(pois.get(0).name); |
| 93 | - }else { | 96 | + } else { |
| 94 | geoCodeResult.success(null); | 97 | geoCodeResult.success(null); |
| 95 | } | 98 | } |
| 96 | } else { | 99 | } else { |
| 97 | //如果街道号或者街道为空 | 100 | //如果街道号或者街道为空 |
| 98 | - if ((null==reverseGeoCodeResult.getAddressDetail().street||TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null==reverseGeoCodeResult.getAddressDetail().streetNumber||TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) { | 101 | + if ((null == reverseGeoCodeResult.getAddressDetail().street || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null == reverseGeoCodeResult.getAddressDetail().streetNumber || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) { |
| 99 | if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) { | 102 | if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) { |
| 100 | geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription()); | 103 | geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription()); |
| 101 | } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) { | 104 | } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) { |
| @@ -147,7 +150,7 @@ public class MyMapUtil { | @@ -147,7 +150,7 @@ public class MyMapUtil { | ||
| 147 | * @return | 150 | * @return |
| 148 | */ | 151 | */ |
| 149 | public static Overlay setMapMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) { | 152 | public static Overlay setMapMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) { |
| 150 | - if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) { | 153 | + if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap || null == startLatLng) { |
| 151 | return null; | 154 | return null; |
| 152 | } | 155 | } |
| 153 | try { | 156 | try { |
| @@ -182,7 +185,7 @@ public class MyMapUtil { | @@ -182,7 +185,7 @@ public class MyMapUtil { | ||
| 182 | * @return | 185 | * @return |
| 183 | */ | 186 | */ |
| 184 | public static List<Overlay> setStartMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) { | 187 | public static List<Overlay> setStartMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) { |
| 185 | - if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) { | 188 | + if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap || null == startLatLng) { |
| 186 | return null; | 189 | return null; |
| 187 | } | 190 | } |
| 188 | List<Overlay> resultOverlays = new ArrayList<>(); | 191 | List<Overlay> resultOverlays = new ArrayList<>(); |
| @@ -234,6 +237,9 @@ public class MyMapUtil { | @@ -234,6 +237,9 @@ public class MyMapUtil { | ||
| 234 | * @param zoomBy | 237 | * @param zoomBy |
| 235 | */ | 238 | */ |
| 236 | public static float setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) { | 239 | public static float setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) { |
| 240 | + if (null == baiduMap || null == trackPoints) { | ||
| 241 | + return 0; | ||
| 242 | + } | ||
| 237 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); | 243 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); |
| 238 | for (LatLng latLng : trackPoints) { | 244 | for (LatLng latLng : trackPoints) { |
| 239 | builder.include(latLng); | 245 | builder.include(latLng); |
| @@ -261,6 +267,9 @@ public class MyMapUtil { | @@ -261,6 +267,9 @@ public class MyMapUtil { | ||
| 261 | * @param zoomBy | 267 | * @param zoomBy |
| 262 | */ | 268 | */ |
| 263 | public static void setCollMapAutoZoom(BaiduMap baiduMap, List<CollectPoint> trackPoints, float zoomBy) { | 269 | public static void setCollMapAutoZoom(BaiduMap baiduMap, List<CollectPoint> trackPoints, float zoomBy) { |
| 270 | + if (null == baiduMap || null == trackPoints) { | ||
| 271 | + return; | ||
| 272 | + } | ||
| 264 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); | 273 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); |
| 265 | List<LatLng> latLngs = new ArrayList<>(); | 274 | List<LatLng> latLngs = new ArrayList<>(); |
| 266 | for (int i = 0; i < trackPoints.size(); i++) { | 275 | for (int i = 0; i < trackPoints.size(); i++) { |
| @@ -292,6 +301,9 @@ public class MyMapUtil { | @@ -292,6 +301,9 @@ public class MyMapUtil { | ||
| 292 | * @return | 301 | * @return |
| 293 | */ | 302 | */ |
| 294 | public static boolean checkIsFinishTrace(List<LatLng> importPoints, List<LatLng> trackPoints, double passRate) { | 303 | public static boolean checkIsFinishTrace(List<LatLng> importPoints, List<LatLng> trackPoints, double passRate) { |
| 304 | + if (null == importPoints || null == trackPoints) { | ||
| 305 | + return false; | ||
| 306 | + } | ||
| 295 | HashMap<Integer, Boolean> importHash = new HashMap<>(); | 307 | HashMap<Integer, Boolean> importHash = new HashMap<>(); |
| 296 | for (int i = 0; i < importPoints.size(); i++) { | 308 | for (int i = 0; i < importPoints.size(); i++) { |
| 297 | importHash.put(i, false); | 309 | importHash.put(i, false); |
| @@ -341,6 +353,16 @@ public class MyMapUtil { | @@ -341,6 +353,16 @@ public class MyMapUtil { | ||
| 341 | private static int queryNum = 0;//查询次数 | 353 | private static int queryNum = 0;//查询次数 |
| 342 | 354 | ||
| 343 | public static void queryHistoryTrace(Context context, LBSTraceClient mClient, String entityName, long startTime, long endTime, CallBack callBack) { | 355 | public static void queryHistoryTrace(Context context, LBSTraceClient mClient, String entityName, long startTime, long endTime, CallBack callBack) { |
| 356 | + if (null == context || null == mClient) { | ||
| 357 | + return; | ||
| 358 | + } | ||
| 359 | + if (0 == startTime || 0 == endTime) { | ||
| 360 | + if (callBack != null) { | ||
| 361 | + callBack.success(null); | ||
| 362 | + } else { | ||
| 363 | + return; | ||
| 364 | + } | ||
| 365 | + } | ||
| 344 | HistoryTrackRequest historyTrackRequest = new HistoryTrackRequest(Constant.TAG, Constant.SERVICE_ID, entityName); | 366 | HistoryTrackRequest historyTrackRequest = new HistoryTrackRequest(Constant.TAG, Constant.SERVICE_ID, entityName); |
| 345 | //设置查询设备名称 | 367 | //设置查询设备名称 |
| 346 | historyTrackRequest.setEntityName(entityName); | 368 | historyTrackRequest.setEntityName(entityName); |
| @@ -491,15 +513,20 @@ public class MyMapUtil { | @@ -491,15 +513,20 @@ public class MyMapUtil { | ||
| 491 | */ | 513 | */ |
| 492 | public static List<Overlay> drawHistoryTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) { | 514 | public static List<Overlay> drawHistoryTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) { |
| 493 | // 绘制新覆盖物前,清空之前的覆盖物 | 515 | // 绘制新覆盖物前,清空之前的覆盖物 |
| 494 | - if (points == null || points.size() == 0 || lineColor == 0) { | 516 | + if (points == null || points.size() == 0 || lineColor == 0 || null == context) { |
| 495 | return null; | 517 | return null; |
| 496 | } | 518 | } |
| 497 | List<Overlay> overlayList = new ArrayList<>(); | 519 | List<Overlay> overlayList = new ArrayList<>(); |
| 498 | //只有一个点 | 520 | //只有一个点 |
| 499 | if (points.size() == 1) { | 521 | if (points.size() == 1) { |
| 500 | if (startIconRes != 0) { | 522 | if (startIconRes != 0) { |
| 501 | - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30); | ||
| 502 | - OverlayOptions startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | 523 | + |
| 524 | + Bitmap pointBitmap = null; | ||
| 525 | + pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30); | ||
| 526 | + OverlayOptions startOptions = null; | ||
| 527 | + if (null != pointBitmap) { | ||
| 528 | + startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | ||
| 529 | + } | ||
| 503 | if (null != startOptions) { | 530 | if (null != startOptions) { |
| 504 | overlayList.add(baiduMap.addOverlay(startOptions)); | 531 | overlayList.add(baiduMap.addOverlay(startOptions)); |
| 505 | } | 532 | } |
| @@ -548,15 +575,15 @@ public class MyMapUtil { | @@ -548,15 +575,15 @@ public class MyMapUtil { | ||
| 548 | polylineOptions = new PolylineOptions().width(10) | 575 | polylineOptions = new PolylineOptions().width(10) |
| 549 | .color(context.getResources().getColor(lineColor)).points(points); | 576 | .color(context.getResources().getColor(lineColor)).points(points); |
| 550 | } | 577 | } |
| 578 | + if (null != polylineOptions) { | ||
| 579 | + overlayList.add(baiduMap.addOverlay(polylineOptions)); | ||
| 580 | + } | ||
| 551 | if (startOptions != null) { | 581 | if (startOptions != null) { |
| 552 | overlayList.add(baiduMap.addOverlay(startOptions)); | 582 | overlayList.add(baiduMap.addOverlay(startOptions)); |
| 553 | } | 583 | } |
| 554 | if (endOptions != null) { | 584 | if (endOptions != null) { |
| 555 | overlayList.add(baiduMap.addOverlay(endOptions)); | 585 | overlayList.add(baiduMap.addOverlay(endOptions)); |
| 556 | } | 586 | } |
| 557 | - if (null != polylineOptions) { | ||
| 558 | - overlayList.add(baiduMap.addOverlay(polylineOptions)); | ||
| 559 | - } | ||
| 560 | if (null != overlayList) { | 587 | if (null != overlayList) { |
| 561 | return overlayList; | 588 | return overlayList; |
| 562 | } else if (overlayList.size() == 0) { | 589 | } else if (overlayList.size() == 0) { |
| @@ -571,7 +598,7 @@ public class MyMapUtil { | @@ -571,7 +598,7 @@ public class MyMapUtil { | ||
| 571 | */ | 598 | */ |
| 572 | public static Overlay drawRealTimeTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes) { | 599 | public static Overlay drawRealTimeTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes) { |
| 573 | // 绘制新覆盖物前,清空之前的覆盖物 | 600 | // 绘制新覆盖物前,清空之前的覆盖物 |
| 574 | - if (points == null || points.size() == 0 || lineColor == 0) { | 601 | + if (points == null || points.size() == 0 || lineColor == 0 || null == context) { |
| 575 | return null; | 602 | return null; |
| 576 | } | 603 | } |
| 577 | //只有一个点 | 604 | //只有一个点 |
| @@ -618,6 +645,9 @@ public class MyMapUtil { | @@ -618,6 +645,9 @@ public class MyMapUtil { | ||
| 618 | * 绘制服务器传过来的轨迹 | 645 | * 绘制服务器传过来的轨迹 |
| 619 | */ | 646 | */ |
| 620 | public static List<Overlay> drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) { | 647 | public static List<Overlay> drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) { |
| 648 | + if (null == context || null == baiduMap || null == points) { | ||
| 649 | + return null; | ||
| 650 | + } | ||
| 621 | try { | 651 | try { |
| 622 | // 绘制新覆盖物前,清空之前的覆盖物 | 652 | // 绘制新覆盖物前,清空之前的覆盖物 |
| 623 | if (points == null || points.size() == 0) { | 653 | if (points == null || points.size() == 0) { |