From a3560fd8768ef4c2f546048b9e6be91484a635c3 Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Mon, 25 May 2020 10:59:48 +0800 Subject: [PATCH] opt --- .../map/impl/amap/AMapNaviViewWrapper.java | 8 +- .../common/map/MapCenterPointStrategy.java | 98 ++++++++++++------- .../com/mogo/module/common/map/Scene.java | 10 ++ .../com/mogo/module/service/MogoServices.java | 21 ++-- .../com/mogo/module/service/ServiceConst.java | 2 +- .../service/intent/MockIntentHandler.java | 9 ++ .../service/marker/MapMarkerManager.java | 1 - .../service/impl/adas/MogoADASController.java | 13 +-- 8 files changed, 102 insertions(+), 60 deletions(-) diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index 341fc8b0c4..a5f9f1be4a 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -157,7 +157,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, options.setNaviArrowVisible( false ); // 通过路线是否自动置灰,仅支持驾车导航 options.setAfterRouteAutoGray( true ); - options.setZoom( 16 ); + options.setZoom( ( ( int ) mDefaultZoomLevel ) ); options.setPointToCenter( 0.5D, 0.5D ); // 2D模式 options.setTilt( 0 ); @@ -295,7 +295,9 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onPolylineClick( Polyline polyline ) { - NaviClient.getInstance( getContext() ).handleClickedPolyline( polyline ); + if ( !NaviClient.getInstance( getContext() ).isNaviing() ) { + NaviClient.getInstance( getContext() ).handleClickedPolyline( polyline ); + } } @Override @@ -439,7 +441,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, case CarUp_3D: case NorthUP_2D: setUIMode( ui, options ); - break; + return; case Type_Light: options.setNaviNight( false ); break; diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java index 03d6f72ae3..c560808406 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java @@ -24,50 +24,76 @@ public class MapCenterPointStrategy { static { // 普通场景,使用高德内部值 - Map< Integer, MapCenterPoint > common = new HashMap<>(); - common.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.666666666D ) ); - common.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.666666666D ) ); - sStrategies.put( Scene.COMMON, common ); + { + Map< Integer, MapCenterPoint > common = new HashMap<>(); + common.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.666666666D ) ); + common.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.666666666D ) ); + sStrategies.put( Scene.COMMON, common ); + } - // 选点场景,定位中心点 - Map< Integer, MapCenterPoint > choosePoint = new HashMap<>(); - choosePoint.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.5D ) ); - choosePoint.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.5D ) ); - sStrategies.put( Scene.CHOOSE_POINT, choosePoint ); + { + // 选点场景,定位中心点 + Map< Integer, MapCenterPoint > choosePoint = new HashMap<>(); + choosePoint.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.5D ) ); + choosePoint.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.5D ) ); + sStrategies.put( Scene.CHOOSE_POINT, choosePoint ); + } + { + // 导航场景,定位视图右下角偏下 + Map< Integer, MapCenterPoint > navi = new HashMap<>(); + navi.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.734375D, 0.573333333333D ) ); + navi.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.575D ) ); + sStrategies.put( Scene.NAVI, navi ); + } - // 导航场景,定位视图右下角偏下 - Map< Integer, MapCenterPoint > navi = new HashMap<>(); - navi.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.7734375D, 0.65D ) ); - navi.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.775521D, 0.661165D ) ); - sStrategies.put( Scene.NAVI, navi ); + { + // 导航场景 vs 道路事件展示场景,定位视图右下角偏下 + Map< Integer, MapCenterPoint > naviWithRoadEvent = new HashMap<>(); + naviWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.734375D, 0.68333333333D ) ); + naviWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.683333333333D ) ); + sStrategies.put( Scene.NAVI_WITH_ROAD_EVENT, naviWithRoadEvent ); + } + { + // 巡航场景,定位视图右下角偏下 + Map< Integer, MapCenterPoint > aimless = new HashMap<>(); + aimless.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.734375D, 0.5D ) ); + aimless.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.5D ) ); + sStrategies.put( Scene.AIMLESS, aimless ); + } - // 巡航场景,定位视图右下角偏下 - Map< Integer, MapCenterPoint > aimless = new HashMap<>(); - aimless.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.677734375D, 0.54D ) ); - aimless.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.558737D ) ); - sStrategies.put( Scene.AIMLESS, aimless ); + { + // 巡航场景 vs 道路事件展示场景,定位视图右下角偏下 + Map< Integer, MapCenterPoint > aimlessWithRoadEvent = new HashMap<>(); + aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.734375D, 0.585 ) ); + aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.599074074D ) ); + sStrategies.put( Scene.AIMLESS_WITH_ROAD_EVENT, aimlessWithRoadEvent ); + } + { + // 规划路线,定位视图右边 + Map< Integer, MapCenterPoint > calculatePath = new HashMap<>(); + calculatePath.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) ); + calculatePath.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.703125D, 0.6083333D ) ); + sStrategies.put( Scene.CALCULATE_PATH, calculatePath ); + } - // 规划路线,定位视图右边 - Map< Integer, MapCenterPoint > calculatePath = new HashMap<>(); - calculatePath.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) ); - calculatePath.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.703125D, 0.6083333D ) ); - sStrategies.put( Scene.CALCULATE_PATH, calculatePath ); + { + // 分类搜索,定位视图右边 + Map< Integer, MapCenterPoint > categorySearch = new HashMap<>(); + categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) ); + categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.596759D ) ); + sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch ); + } - // 分类搜索,定位视图右边 - Map< Integer, MapCenterPoint > categorySearch = new HashMap<>(); - categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) ); - categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.596759D ) ); - sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch ); - - - // V2X,场景视图右边 - Map< Integer, MapCenterPoint > categoryV2XEvent = new HashMap<>(); - categoryV2XEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.677734375D, 0.7D ) ); - categoryV2XEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.65D ) ); - sStrategies.put( Scene.CATEGORY_V2X_EVENT, categoryV2XEvent ); + { + // V2X,场景视图右边 + Map< Integer, MapCenterPoint > categoryV2XEvent = new HashMap<>(); + categoryV2XEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.677734375D, 0.7D ) ); + categoryV2XEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.65D ) ); + sStrategies.put( Scene.CATEGORY_V2X_EVENT, categoryV2XEvent ); + } } public static void addScene( int scene, Map< Integer, MapCenterPoint > config ) { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/Scene.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/Scene.java index c37810ae50..c65f727241 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/Scene.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/Scene.java @@ -23,11 +23,21 @@ public interface Scene { */ int NAVI = 2; + /** + * 导航 vs 道路事件 + */ + int NAVI_WITH_ROAD_EVENT = 21; + /** * 巡航 */ int AIMLESS = 3; + /** + * 巡航 vs 道路事件 + */ + int AIMLESS_WITH_ROAD_EVENT = 31; + /** * 路线规划 */ diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index ed01a0a9e2..bb7370c404 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -173,7 +173,7 @@ public class MogoServices implements IMogoMapListener, switch ( msg.what ) { case ServiceConst.MSG_TYPE_REFRESH_DECREASE: if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) { - stopAutoRefreshStrategy(); + invokeAutoRefreshStrategy(); return; } mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL; @@ -263,17 +263,12 @@ public class MogoServices implements IMogoMapListener, invokeAutoRefreshStrategy(); } } - - private void invokeAutoRefreshStrategy() { - if ( mStatusManager.isSearchUIShow() ) { - return; - } - mRefreshRemainingTime = mAutoRefreshStrategy.getInterval(); - mHandler.removeMessages( ServiceConst.MSG_TYPE_REFRESH_DECREASE ); - mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, ServiceConst.DECREASE_INTERVAL ); - } }; + private void invokeAutoRefreshStrategy() { + restartAutoRefreshAtTime( mAutoRefreshStrategy.getInterval() ); + } + private Handler mThreadHandler; public void init( Context context ) { @@ -616,7 +611,7 @@ public class MogoServices implements IMogoMapListener, return; } Logger.d( TAG, mAutoRefreshCallback == callback ? "触发自动刷新" : "触发手动刷新" ); - int amount = mLastZoomLevel >= 10 ? 5 : 10; + int amount = 10; Message msg = Message.obtain(); msg.what = ServiceConst.MSG_REQUEST_DATA; @@ -697,7 +692,7 @@ public class MogoServices implements IMogoMapListener, } } - public void restartAutoRefreshAtTime( int time ) { + public void restartAutoRefreshAtTime( long time ) { if ( time < 0 ) { Logger.w( TAG, "ignore refresh request case time < 0" ); return; @@ -716,7 +711,7 @@ public class MogoServices implements IMogoMapListener, Logger.d( TAG, "move to center and refresh data." ); mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false ); mUiController.recoverLockMode();// 锁车代替移到中心点 - notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback ); + restartAutoRefreshAtTime( 0 ); } @Override diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java index 41282ef6bc..70012c00b6 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/ServiceConst.java @@ -83,7 +83,7 @@ public class ServiceConst { public static final int DEFAULT_AUTO_REFRESH_DATA_RADIUS = 2_000; /** - * 20 s + * 30 s */ public static final int DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT = 30 * 1_000; diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java index ff9a355949..4367517ce4 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java @@ -134,6 +134,15 @@ public class MockIntentHandler implements IntentHandler { case 11: MarkerServiceHandler.getADASController().setSettingStatus( intent.getBooleanExtra( "status", false ) ); break; + case 12: { + boolean status2 = intent.getBooleanExtra( "status", false ); + if ( status2 ) { + MarkerServiceHandler.getADASController().showADAS(); + } else { + MarkerServiceHandler.getADASController().closeADAS(); + } + } + break; } } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java index 9f5a90088b..4e85df77c6 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java @@ -247,7 +247,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, */ private void drawAllMarker( MarkerCardResult markerCardResult ) { List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay(); - drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL ); } diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java index 019e4c91c1..ec82685aea 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java @@ -70,16 +70,17 @@ public class MogoADASController implements IMogoADASController { init( AbsMogoApplication.getApp() ); } + if ( mStatusManager.isSearchUIShow() ) { + return; + } + if ( !mStatusManager.isMainPageOnResume() ) { + return; + } + int delay = CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ? 0 : 500; UiThreadHandler.postDelayed( () -> { try { - if ( mStatusManager.isSearchUIShow() ) { - return; - } - if ( !mStatusManager.isMainPageOnResume() ) { - return; - } AutopilotServiceManage.getInstance().showAdas(); } catch ( Exception e ) { Intent intent = new Intent( ACTION );