diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index 048c2eafa4..b5b577a813 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -57,12 +57,22 @@ public class AbsMogoApplication extends Application { public void onCreate() { super.onCreate(); sApp = this; + initARouter(); if ( shouldInit() ) { init(); } } - protected boolean shouldInit(){ + private void initARouter() { + ARouter.init( sApp ); + // 初始化 arouter + if ( DebugConfig.isDebug() ) { + ARouter.openDebug(); + ARouter.openLog(); + } + } + + protected boolean shouldInit() { return true; } @@ -72,31 +82,25 @@ public class AbsMogoApplication extends Application { } private void syncInit() { - // 初始化 arouter - if ( DebugConfig.isDebug() ) { - ARouter.openDebug(); - ARouter.openLog(); - } - ARouter.init( sApp ); TipToast.init( this, ( ( context, message, tipDrawable ) -> { if ( TextUtils.isEmpty( message ) ) { return null; } View contentView; - if(tipDrawable==null) { - contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast, null); - TextView txt = contentView.findViewById(R.id.module_commons_toast_msg); - txt.setText(message); - }else{ + if ( tipDrawable == null ) { + contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null ); + TextView txt = contentView.findViewById( R.id.module_commons_toast_msg ); + txt.setText( message ); + } else { // 有图片,使用带图片的布局,当前只实现了左侧图片 - contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast_with_left_drawable, null); - TextView txt = contentView.findViewById(R.id.module_commons_toast_msg); - ImageView img = contentView.findViewById(R.id.module_commons_toast_left_drawable); - img.setImageDrawable(tipDrawable.getDrawable()); + contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast_with_left_drawable, null ); + TextView txt = contentView.findViewById( R.id.module_commons_toast_msg ); + ImageView img = contentView.findViewById( R.id.module_commons_toast_left_drawable ); + img.setImageDrawable( tipDrawable.getDrawable() ); ViewGroup.LayoutParams params = img.getLayoutParams(); params.width = tipDrawable.getWidth(); params.height = tipDrawable.getHeight(); - txt.setText(message); + txt.setText( message ); } return contentView; } ) ); @@ -133,7 +137,7 @@ public class AbsMogoApplication extends Application { } ); } - protected void asyncInitImpl(){ + protected void asyncInitImpl() { } diff --git a/libraries/map-custom/build.gradle b/libraries/map-custom/build.gradle index 9ee986a20f..fe1c8dca4c 100644 --- a/libraries/map-custom/build.gradle +++ b/libraries/map-custom/build.gradle @@ -55,7 +55,7 @@ dependencies { implementation project(':foudations:mogo-commons') } - implementation 'com.zhidaoauto.machine:map:1.0.0-online-25' + implementation 'com.zhidaoauto.machine:map:1.0.0-online-26' } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() 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 06418ba36e..6b8e2fcb07 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 @@ -97,6 +97,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca // options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() ); // 设置自车的图片对象 options.setMyLocationStyle( options.getMyLocationStyle().myLocationIcon( DEFAULT_OPTION.getCarCursorRes() ) ); + options.setAnchorScale(1.2f, 2 ); // 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。 // options.hiddenDirection(); // 黑夜模式 diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java index dd7ce735df..db8daa61d7 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java @@ -24,7 +24,7 @@ public class CustomMapView implements IMogoMapViewCreator { @Override public IMogoMapView create( Context context ) { if ( mapView == null ) { - MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( false ) + MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( true ) .setCoordinateType( MapParams.COORDINATETYPE_GCJ02 ) .setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D ) .setZoom( 16 ) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java index bd8dc29f45..7bea24b088 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java @@ -2,6 +2,7 @@ package com.mogo.module.common.drawer; import android.content.Context; import android.graphics.BitmapFactory; +import android.text.TextUtils; import com.mogo.commons.AbsMogoApplication; import com.mogo.map.MogoLatLng; @@ -72,6 +73,9 @@ class AdasRecognizedResultDrawer { } IMogoMarker marker = null; String uniqueKey = recognizedListResult.uuid; + if ( TextUtils.isEmpty( uniqueKey ) ) { + continue; + } if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) { marker = mAdasRecognizedMarkersCaches.get( uniqueKey ); } @@ -81,17 +85,19 @@ class AdasRecognizedResultDrawer { } List< MogoLatLng > points = new ArrayList<>(); + MogoLatLng endLatLon = null; if ( recognizedListResult.latLonList != null - || recognizedListResult.latLonList.size() > 1 ) { + && recognizedListResult.latLonList.size() > 1 ) { for ( int j = 0; j < recognizedListResult.latLonList.size(); j++ ) { ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( j ); if ( latLon == null ) { continue; } - points.add( new MogoLatLng( latLon.lat, latLon.lon ) ); + points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) ); } - } else { + } else if ( recognizedListResult.latLonList != null + && recognizedListResult.latLonList.size() == 1 ) { // 原来的点和新的点做一个数组进行平滑移动 MogoLatLng latLng = marker.getPosition(); ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 ); @@ -99,7 +105,10 @@ class AdasRecognizedResultDrawer { continue; } points.add( latLng ); - points.add( new MogoLatLng( latLng.lat, latLon.lon ) ); + points.add( endLatLon = new MogoLatLng( latLng.lat, latLon.lon ) ); + } + if ( endLatLon != null ) { + marker.setPosition( endLatLon.lat, endLatLon.lon ); } if ( points.size() >= 1 ) { marker.startSmooth( points, 1 ); @@ -153,6 +162,7 @@ class AdasRecognizedResultDrawer { } MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_ADAS ) + .gps( true ) .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) ) .position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) ); return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options ); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java index 1ab52d1cb6..d3099dfb34 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java @@ -77,10 +77,12 @@ class MarkerDrawer { } IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).addMarker( markerShowEntity.getMarkerType(), options ); - marker.setOwner( markerShowEntity.getMarkerType() ); - markerView.setMarker( marker ); - marker.setOnMarkerClickListener( listener ); - markerShowEntity.setMarker( marker ); + if ( marker != null ) { + marker.setOwner( markerShowEntity.getMarkerType() ); + markerView.setMarker( marker ); + marker.setOnMarkerClickListener( listener ); + markerShowEntity.setMarker( marker ); + } return marker; } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java index 974b9674a0..fe43987eca 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java @@ -2,6 +2,10 @@ package com.mogo.module.common.drawer; import android.content.Context; import android.graphics.BitmapFactory; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; import com.mogo.commons.AbsMogoApplication; import com.mogo.map.MogoLatLng; @@ -15,6 +19,7 @@ import com.mogo.module.common.constants.DataTypes; import com.mogo.module.common.entity.CloudLocationInfo; import com.mogo.module.common.entity.CloudRoadData; import com.mogo.module.common.entity.MogoSnapshotSetData; +import com.mogo.utils.logger.Logger; import java.util.ArrayList; import java.util.HashMap; @@ -31,6 +36,8 @@ public */ class SnapshotSetDataDrawer { + private static final String TAG = "SnapshotSetDataDrawer"; + private static volatile SnapshotSetDataDrawer sInstance; private Context mContext; @@ -84,16 +91,23 @@ class SnapshotSetDataDrawer { } IMogoMarker marker = null; String uniqueKey = cloudRoadData.getUniqueKey(); + if ( TextUtils.isEmpty( uniqueKey ) ) { + continue; + } if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) { marker = mCloudSnapshotMarkersCaches.get( uniqueKey ); } if ( marker == null || marker.isDestroyed() ) { marker = drawSnapshotDataMarker( cloudRoadData ); + if ( marker == null ) { + continue; + } mCloudSnapshotMarkersCaches.put( uniqueKey, marker ); } + MogoLatLng endLatLon = null; List< MogoLatLng > points = new ArrayList<>(); if ( cloudRoadData.getCoordinates() != null - || cloudRoadData.getCoordinates().size() > 1 ) { + && cloudRoadData.getCoordinates().size() > 1 ) { for ( int j = 0; j < cloudRoadData.getCoordinates().size(); j++ ) { CloudLocationInfo poi = cloudRoadData.getCoordinates().get( j ); if ( poi == null ) { @@ -101,12 +115,14 @@ class SnapshotSetDataDrawer { } double lat = poi.getLat(); double lng = poi.getLon(); - points.add( new MogoLatLng( lat, lng ) ); + points.add( endLatLon = new MogoLatLng( lat, lng ) ); } - } else { points.add( marker.getPosition() ); - points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) ); + points.add( endLatLon = new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) ); + } + if ( endLatLon != null ) { + marker.setPosition( endLatLon.lat, endLatLon.lon ); } if ( points.size() >= 1 ) { marker.startSmooth( points, 1 ); @@ -132,6 +148,9 @@ class SnapshotSetDataDrawer { continue; } String uniqueKey = cloudRoadData.getUniqueKey(); + if ( TextUtils.isEmpty( uniqueKey ) ) { + continue; + } if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) { existMarker.put( uniqueKey, mCloudSnapshotMarkersCaches.get( uniqueKey ) ); } @@ -159,10 +178,19 @@ class SnapshotSetDataDrawer { if ( data.getType() == AdasRecognizedType.classIdBackground ) { } + Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() ); MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_CLOUD_DATA ) - .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) ) + .icon( inflateView( data ) ) + .gps( true ) .position( new MogoLatLng( data.getLat(), data.getLon() ) ); return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options ); } + + private View inflateView( CloudRoadData data ) { + View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null ); + TextView tv = rootView.findViewById( R.id.tvSn ); + tv.setText( data.getUniqueKey() ); + return rootView; + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java new file mode 100644 index 0000000000..eda212b483 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java @@ -0,0 +1,13 @@ +package com.mogo.module.common.drawer.marker; + +public +/** + * @author congtaowang + * @since 2020/10/29 + *
+ * 描述
+ */
+class MarkerResourceManager {
+
+
+}
diff --git a/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml b/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml
new file mode 100644
index 0000000000..c065851373
--- /dev/null
+++ b/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml
@@ -0,0 +1,17 @@
+
+