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 | 76 | private SelectDialog selectDialog; |
| 77 | 77 | private boolean isShowFollowAddress = false;//是否显示跟随地址 |
| 78 | 78 | public RunRaceDetailInfo runRaceDetailInfo; |
| 79 | + private boolean isFollowUserShow = true;//是否跟随用户视角 | |
| 79 | 80 | |
| 80 | 81 | public StartTraceFragmentView(StartTraceFragment fragment) { |
| 81 | 82 | this.fragment = fragment; |
| ... | ... | @@ -442,10 +443,13 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 442 | 443 | // 此处设置开发者获取到的方向信息,顺时针0-360 |
| 443 | 444 | .direction(location.getDirection()).latitude(location.getLatitude()) |
| 444 | 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 | 454 | // if (location.hasAddr()) { |
| 451 | 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 | 69 | * @param geoCodeResult |
| 70 | 70 | */ |
| 71 | 71 | public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) { |
| 72 | + if (null == latLng) { | |
| 73 | + return; | |
| 74 | + } | |
| 72 | 75 | if (null == mSearch) { |
| 73 | 76 | mSearch = GeoCoder.newInstance(); |
| 74 | 77 | } |
| ... | ... | @@ -87,15 +90,15 @@ public class MyMapUtil { |
| 87 | 90 | queryGeoCount = 0; |
| 88 | 91 | if (null != geoCodeResult) { |
| 89 | 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 | 95 | geoCodeResult.success(pois.get(0).name); |
| 93 | - }else { | |
| 96 | + } else { | |
| 94 | 97 | geoCodeResult.success(null); |
| 95 | 98 | } |
| 96 | 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 | 102 | if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) { |
| 100 | 103 | geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription()); |
| 101 | 104 | } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) { |
| ... | ... | @@ -147,7 +150,7 @@ public class MyMapUtil { |
| 147 | 150 | * @return |
| 148 | 151 | */ |
| 149 | 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 | 154 | return null; |
| 152 | 155 | } |
| 153 | 156 | try { |
| ... | ... | @@ -182,7 +185,7 @@ public class MyMapUtil { |
| 182 | 185 | * @return |
| 183 | 186 | */ |
| 184 | 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 | 189 | return null; |
| 187 | 190 | } |
| 188 | 191 | List<Overlay> resultOverlays = new ArrayList<>(); |
| ... | ... | @@ -234,6 +237,9 @@ public class MyMapUtil { |
| 234 | 237 | * @param zoomBy |
| 235 | 238 | */ |
| 236 | 239 | public static float setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) { |
| 240 | + if (null == baiduMap || null == trackPoints) { | |
| 241 | + return 0; | |
| 242 | + } | |
| 237 | 243 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); |
| 238 | 244 | for (LatLng latLng : trackPoints) { |
| 239 | 245 | builder.include(latLng); |
| ... | ... | @@ -261,6 +267,9 @@ public class MyMapUtil { |
| 261 | 267 | * @param zoomBy |
| 262 | 268 | */ |
| 263 | 269 | public static void setCollMapAutoZoom(BaiduMap baiduMap, List<CollectPoint> trackPoints, float zoomBy) { |
| 270 | + if (null == baiduMap || null == trackPoints) { | |
| 271 | + return; | |
| 272 | + } | |
| 264 | 273 | LatLngBounds.Builder builder = new LatLngBounds.Builder(); |
| 265 | 274 | List<LatLng> latLngs = new ArrayList<>(); |
| 266 | 275 | for (int i = 0; i < trackPoints.size(); i++) { |
| ... | ... | @@ -292,6 +301,9 @@ public class MyMapUtil { |
| 292 | 301 | * @return |
| 293 | 302 | */ |
| 294 | 303 | public static boolean checkIsFinishTrace(List<LatLng> importPoints, List<LatLng> trackPoints, double passRate) { |
| 304 | + if (null == importPoints || null == trackPoints) { | |
| 305 | + return false; | |
| 306 | + } | |
| 295 | 307 | HashMap<Integer, Boolean> importHash = new HashMap<>(); |
| 296 | 308 | for (int i = 0; i < importPoints.size(); i++) { |
| 297 | 309 | importHash.put(i, false); |
| ... | ... | @@ -341,6 +353,16 @@ public class MyMapUtil { |
| 341 | 353 | private static int queryNum = 0;//查询次数 |
| 342 | 354 | |
| 343 | 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 | 366 | HistoryTrackRequest historyTrackRequest = new HistoryTrackRequest(Constant.TAG, Constant.SERVICE_ID, entityName); |
| 345 | 367 | //设置查询设备名称 |
| 346 | 368 | historyTrackRequest.setEntityName(entityName); |
| ... | ... | @@ -491,15 +513,20 @@ public class MyMapUtil { |
| 491 | 513 | */ |
| 492 | 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 | 517 | return null; |
| 496 | 518 | } |
| 497 | 519 | List<Overlay> overlayList = new ArrayList<>(); |
| 498 | 520 | //只有一个点 |
| 499 | 521 | if (points.size() == 1) { |
| 500 | 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 | 530 | if (null != startOptions) { |
| 504 | 531 | overlayList.add(baiduMap.addOverlay(startOptions)); |
| 505 | 532 | } |
| ... | ... | @@ -548,15 +575,15 @@ public class MyMapUtil { |
| 548 | 575 | polylineOptions = new PolylineOptions().width(10) |
| 549 | 576 | .color(context.getResources().getColor(lineColor)).points(points); |
| 550 | 577 | } |
| 578 | + if (null != polylineOptions) { | |
| 579 | + overlayList.add(baiduMap.addOverlay(polylineOptions)); | |
| 580 | + } | |
| 551 | 581 | if (startOptions != null) { |
| 552 | 582 | overlayList.add(baiduMap.addOverlay(startOptions)); |
| 553 | 583 | } |
| 554 | 584 | if (endOptions != null) { |
| 555 | 585 | overlayList.add(baiduMap.addOverlay(endOptions)); |
| 556 | 586 | } |
| 557 | - if (null != polylineOptions) { | |
| 558 | - overlayList.add(baiduMap.addOverlay(polylineOptions)); | |
| 559 | - } | |
| 560 | 587 | if (null != overlayList) { |
| 561 | 588 | return overlayList; |
| 562 | 589 | } else if (overlayList.size() == 0) { |
| ... | ... | @@ -571,7 +598,7 @@ public class MyMapUtil { |
| 571 | 598 | */ |
| 572 | 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 | 602 | return null; |
| 576 | 603 | } |
| 577 | 604 | //只有一个点 |
| ... | ... | @@ -618,6 +645,9 @@ public class MyMapUtil { |
| 618 | 645 | * 绘制服务器传过来的轨迹 |
| 619 | 646 | */ |
| 620 | 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 | 651 | try { |
| 622 | 652 | // 绘制新覆盖物前,清空之前的覆盖物 |
| 623 | 653 | if (points == null || points.size() == 0) { | ... | ... |