diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index c3af9a70e9..a5cbdc4518 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -67,6 +67,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca private boolean mIsCarLocked = false; private int mLockZoom = 16; + private long startTime; private float mDefaultZoomLevel = 16.0f; private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder() @@ -76,6 +77,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca private CarCursorOption mCarCursorOption = DEFAULT_OPTION; public AMapViewWrapper(MapAutoView mMapView) { + startTime = System.currentTimeMillis(); Logger.i(TAG, "autoop--AMapViewWrapper: init"); this.mMapView = mMapView; initListeners(); @@ -292,23 +294,23 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca if (ui == null) { return; } - if ( checkAMapView() ) { - switch ( ui ) { + if (checkAMapView()) { + switch (ui) { case CarUp_2D: case CarUp_3D: case NorthUP_2D: //setUIMode( ui, options ); return; case Type_Light: - mMapView.getMapAutoViewHelper().setAutoSwitchStyle( false ); + mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false); mMapView.getMapAutoViewHelper().setMapStyle(MapHelper.INSTANCE.getMMapParams().MAP_STYLE_DAY); break; case Type_Night: - mMapView.getMapAutoViewHelper().setAutoSwitchStyle( false ); + mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false); mMapView.getMapAutoViewHelper().setMapStyle(MapHelper.INSTANCE.getMMapParams().MAP_STYLE_NIGHT); break; case Type_AUTO_LIGHT_Night: - mMapView.getMapAutoViewHelper().setAutoSwitchStyle( true ); + mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true); break; } @@ -322,7 +324,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca private void setUIMode(EnumMapUI ui) { this.mCurrentUIMode = ui; - if( mMapView.getMapAutoViewHelper() != null){ + if (mMapView.getMapAutoViewHelper() != null) { switch (ui) { case CarUp_2D: mMapView.getMapAutoViewHelper().setMapViewPerspective(MapParams.MAP_PERSPECTIVE_2D); @@ -380,16 +382,16 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca @Override public void showMyLocation(View view) { - if ( NaviClient.getInstance( getContext() ).isNaviing() ) { + if (NaviClient.getInstance(getContext()).isNaviing()) { return; } - if ( DebugConfig.isDebug() ) { - Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + if (DebugConfig.isDebug()) { + Logger.d(TAG, Log.getStackTraceString(new Throwable())); } - if ( checkAMapView() ) { + if (checkAMapView()) { MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle(); // style.myLocationIcon( BitmapDescriptorFactory.fromView( view ) ); - mMapView.getMapAutoViewHelper().setMyLocationStyle( style ); + mMapView.getMapAutoViewHelper().setMyLocationStyle(style); } } @@ -441,7 +443,6 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca } - @Override public float getScalePerPixel() { return getMap().getScalePerPixel(); @@ -454,15 +455,15 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca @Override public MogoLatLng getCameraNorthEastPosition() { - return ObjectUtils.fromAMap( MapTools.INSTANCE.getVisibleRegion().getRightTopPoint()); + return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getRightTopPoint()); } @Override public MogoLatLng getCameraSouthWestPosition() { try { - return ObjectUtils.fromAMap( MapTools.INSTANCE.getVisibleRegion().getLeftBottomPoint()); - } catch ( Exception e ) { + return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getLeftBottomPoint()); + } catch (Exception e) { } return null; @@ -545,7 +546,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca public void setRenderFps(int fps) { if (checkAMapView()) { if (mMapView.getMapAutoViewHelper() != null) { - mMapView.getMapAutoViewHelper().setRenderFps( fps ); + mMapView.getMapAutoViewHelper().setRenderFps(fps); Logger.d(TAG, "设置刷新帧率 fps = %s", fps); } } @@ -556,17 +557,17 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca if (!checkAMapView()) { return; } - Logger.i(TAG, "showBounds:%s -%s-%s- %b ", tag,carPosition.toString(),bound.toShortString(),lockCarPosition); + Logger.i(TAG, "showBounds:%s -%s-%s- %b ", tag, carPosition.toString(), bound.toShortString(), lockCarPosition); try { - if ( DebugConfig.isDebug() ) { - Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); + if (DebugConfig.isDebug()) { + Logger.d(TAG, Log.getStackTraceString(new Throwable())); } - LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds( carPosition, lonLats, lockCarPosition ); - if ( !lockCarPosition ) { + LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds(carPosition, lonLats, lockCarPosition); + if (!lockCarPosition) { loseLockMode(); } mMapView.getMapAutoViewHelper().setCenter(ObjectUtils.fromMogo(carPosition)); - mMapView.getMapAutoViewHelper().moveCamera( CameraUpdateFactory.INSTANCE.newLatLngBounds( latLngBounds, bound.left, bound.right, bound.top, bound.bottom ) ); + mMapView.getMapAutoViewHelper().moveCamera(CameraUpdateFactory.INSTANCE.newLatLngBounds(latLngBounds, bound.left, bound.right, bound.top, bound.bottom)); } catch (Exception e) { Logger.e(TAG, e, "%s error.", tag); } @@ -640,7 +641,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca public MapCameraPosition getMapCameraPosition() { if (checkAMapView()) { CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition(); - return ObjectUtils.fromAMap( cameraPosition ); + return ObjectUtils.fromAMap(cameraPosition); } return null; } @@ -679,12 +680,12 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca isLoaded = true; MogoMapListenerHandler.getInstance().onMapLoaded(); CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition(); - if ( cameraPosition != null ) { - Trace.beginSection( "timer.onCameraChangeFinish" ); - MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap( cameraPosition.getTarget() ), + if (cameraPosition != null) { + Trace.beginSection("timer.onCameraChangeFinish"); + MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()), cameraPosition.getZoom(), cameraPosition.getTilt(), - cameraPosition.getBearing() ); + cameraPosition.getBearing()); Trace.endSection(); } } @@ -699,7 +700,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca @Override public void onMarkClick(@NotNull Marker markerInfo) { - mMarkerClickHandler.handleMarkerClicked( markerInfo ); + mMarkerClickHandler.handleMarkerClicked(markerInfo); } @Override @@ -709,23 +710,23 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca @Override public void onMapStatusChanged(int type, int value) { - Log.i(TAG, "mapop--onMapStatusChanged-: "+type+","+value); + Log.i(TAG, "mapop--onMapStatusChanged-: " + type + "," + value); } @Override public void onCameraChange(int type, int value) { - Log.i(TAG, "mapop--onCameraChange-: "+type+","+value); + Log.i(TAG, "mapop--onCameraChange-: " + type + "," + value); } @Override public void onCameraChangeFinish(@Nullable CameraPosition cameraPosition) { - Log.i(TAG, "mapop--onCameraChangeFinish-: "+cameraPosition); - if ( cameraPosition != null ) { - Trace.beginSection( "timer.onCameraChangeFinish" ); - MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap( cameraPosition.getTarget() ), + Log.i(TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + (System.currentTimeMillis() - startTime)); + if (cameraPosition != null) { + Trace.beginSection("timer.onCameraChangeFinish"); + MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()), cameraPosition.getZoom(), cameraPosition.getTilt(), - cameraPosition.getBearing() ); + cameraPosition.getBearing()); Trace.endSection(); } }