diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 208c303fbb..3313577672 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -1,5 +1,6 @@ package com.mogo.launcher; +import android.app.ActivityManager; import android.content.Context; import android.content.Intent; import android.text.TextUtils; @@ -37,6 +38,8 @@ import com.zhidao.boot.persistent.lib.PersistentManager; import com.zhidao.mogo.module.left.panel.LeftPanelConst; import com.zhidao.mogo.tanlu.api.TanluApiConst; +import java.util.List; + import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_FRAGMENT; import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_MODULE_NAME; @@ -110,9 +113,23 @@ public class MogoApplication extends AbsMogoApplication { @Override protected boolean shouldInit() { - return !LeakCanary.isInAnalyzerProcess( this ); + return isMainProcess(); } + private boolean isMainProcess() { + ActivityManager am = ( ( ActivityManager ) getSystemService( Context.ACTIVITY_SERVICE ) ); + List< ActivityManager.RunningAppProcessInfo > processInfos = am.getRunningAppProcesses(); + String mainProcessName = getPackageName(); + int myPid = android.os.Process.myPid(); + for ( ActivityManager.RunningAppProcessInfo info : processInfos ) { + if ( info.pid == myPid && mainProcessName.equals( info.processName ) ) { + return true; + } + } + return false; + } + + private void initDebugConfig() { if ( !shouldInit() ) { return; diff --git a/libraries/map-custom/build.gradle b/libraries/map-custom/build.gradle index b542142f9d..6e93301417 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-21' + implementation 'com.zhidaoauto.machine:map:1.0.0-online-23' } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() 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 08d3bc5ba6..917f883c74 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 @@ -102,7 +102,7 @@ class AdasRecognizedResultDrawer { points.add( new MogoLatLng( latLng.lat, latLon.lon ) ); } if ( points.size() >= 1 ) { - marker.startSmooth( points, 1000 ); + marker.startSmooth( points, 1 ); } } } @@ -153,7 +153,7 @@ class AdasRecognizedResultDrawer { } MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_ADAS ) - .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) ) + .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( ModuleNames.CARD_TYPE_ROAD_CONDITION, 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 new file mode 100644 index 0000000000..1ab52d1cb6 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java @@ -0,0 +1,261 @@ +package com.mogo.module.common.drawer; + +import android.text.TextUtils; + +import com.mogo.commons.AbsMogoApplication; +import com.mogo.map.MogoLatLng; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.drawer.marker.IMarkerView; +import com.mogo.module.common.drawer.marker.MapMarkerAdapter; +import com.mogo.module.common.drawer.marker.OnlineCarMarkerView; +import com.mogo.module.common.entity.MarkerExploreWay; +import com.mogo.module.common.entity.MarkerNoveltyInfo; +import com.mogo.module.common.entity.MarkerOnlineCar; +import com.mogo.module.common.entity.MarkerShareMusic; +import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.utils.logger.Logger; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public +/** + * @author congtaowang + * @since 2020/10/28 + *

+ * 描述 + */ +class MarkerDrawer { + + public static final int MARKER_Z_INDEX_HIGH = 100; + public static final int MARKER_Z_INDEX_LOW = 2; + + private static volatile MarkerDrawer sInstance; + + private MarkerDrawer() { + } + + public static MarkerDrawer getInstance() { + if ( sInstance == null ) { + synchronized ( MarkerDrawer.class ) { + if ( sInstance == null ) { + sInstance = new MarkerDrawer(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) { + if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) { + return null; + } + MogoMarkerOptions options = new MogoMarkerOptions().owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() ); + IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options ); + if ( markerView instanceof OnlineCarMarkerView ) { + try { + options.icon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) ); + } catch ( Exception e ) { + options.icon( markerView.getBitmap( 0 ) ); + } + options.anchor( 0.5f, 0.5f ); + } else { + options.icon( markerView.getView() ); + } + + 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 ); + return marker; + } + + /** + * S = (A ∩ B) ∪ B + * (A ∩ B)作为旧列表需要保留的部分 + * + * @param newList + * @return + */ + public Map< String, IMogoMarker > purgeMarkerData( List newList, String markerType ) { + + final long start = System.currentTimeMillis(); + Map< String, IMogoMarker > existMap = new HashMap<>(); + List< IMogoMarker > allCarsList = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).getMarkers( markerType ); + if ( allCarsList == null || allCarsList.isEmpty() ) { + return existMap; + } + if ( newList == null || newList.isEmpty() ) { + return existMap; + } + + Map< String, IMogoMarker > allMap = new HashMap<>(); + for ( IMogoMarker marker : allCarsList ) { + String sn = getPrimaryKeyFromMarker( marker ); + allMap.put( sn, marker ); + } + for ( Object entity : newList ) { + String sn = getPrimaryKeyFromEntity( entity ); + if ( allMap.containsKey( sn ) ) { + if ( !isNewVehicleType( entity, allMap.get( sn ) ) ) { + existMap.put( sn, allMap.get( sn ) ); + } + } + } + for ( String sn : allMap.keySet() ) { + if ( !existMap.containsKey( sn ) ) { + IMogoMarker dirtyMarker = allMap.get( sn ); + allCarsList.remove( dirtyMarker ); + dirtyMarker.destroy(); + } + } + allMap.clear(); + Logger.i( "timer", "purge data cost " + ( System.currentTimeMillis() - start ) + "ms" ); + return existMap; + } + + + /** + * @param maxAmount 展示的最大数量 + * @param list + * @return + */ + public int getAppropriateSize( int maxAmount, List list ) { + if ( list == null ) { + return 0; + } + return Math.min( maxAmount, list.size() ); + } + + + private boolean isNewVehicleType( Object object, IMogoMarker marker ) { + if ( object instanceof MarkerOnlineCar + && marker != null + && marker.getObject() instanceof MarkerShowEntity + && ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerOnlineCar ) { + try { + return ( ( MarkerOnlineCar ) object ).getCarInfo().getVehicleType() + != ( ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ).getCarInfo().getVehicleType(); + } catch ( Exception e ) { + + } + } + return false; + } + + public String getPrimaryKeyFromEntity( Object entity ) { + if ( entity instanceof MarkerExploreWay ) { + String id = ( ( MarkerExploreWay ) entity ).getInfoId(); + if ( !TextUtils.isEmpty( id ) ) { + return id; + } + } + return getCarSnFromEntity( entity ); + } + + private String getPrimaryKeyFromMarker( IMogoMarker marker ) { + if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) { + return null; + } + if ( !( marker.getObject() instanceof MarkerShowEntity ) ) { + return null; + } + return getPrimaryKeyFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ); + } + + private String getCarSnFromEntity( Object entity ) { + try { + if ( entity instanceof MarkerOnlineCar ) { + return ( ( MarkerOnlineCar ) entity ).getUserInfo().getSn(); + } else if ( entity instanceof MarkerShareMusic ) { + return ( ( MarkerShareMusic ) entity ).getUserInfo().getSn(); + } else if ( entity instanceof MarkerNoveltyInfo ) { + return ( ( MarkerNoveltyInfo ) entity ).getSn(); + } else if ( entity instanceof MarkerExploreWay ) { + return ( ( MarkerExploreWay ) entity ).getUserInfo().getSn(); + } + } catch ( Exception e ) { + + } + return ""; + } + + public String getCarSnFromMarker( IMogoMarker marker ) { + if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) { + return null; + } + if ( !( marker.getObject() instanceof MarkerShowEntity ) ) { + return null; + } + return getCarSnFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ); + } + + /** + * 距离半径计算方式 + * + * @param point1 点一坐标 + * @param point2 点二坐标 + * @return 两坐标的距离 单位:米(M) + */ + public static float calculateLineDistance( MogoLatLng point1, MogoLatLng point2 ) { + if ( point1 != null && point2 != null ) { + return calculateLineDistance( point1.lon, point1.lat, point2.lon, point2.lat ); + } else { + return 0.0F; + } + } + + /** + * @param lon1 + * @param lat1 + * @param lon2 + * @param lat2 + * @return 两坐标的距离 单位:米(M) + */ + public static float calculateLineDistance( double lon1, double lat1, double lon2, double lat2 ) { + try { + double var2 = lon1; + double var4 = lat1; + double var6 = lon2; + double var8 = lat2; + var2 *= 0.01745329251994329D; + var4 *= 0.01745329251994329D; + var6 *= 0.01745329251994329D; + var8 *= 0.01745329251994329D; + double var10 = Math.sin( var2 ); + double var12 = Math.sin( var4 ); + double var14 = Math.cos( var2 ); + double var16 = Math.cos( var4 ); + double var18 = Math.sin( var6 ); + double var20 = Math.sin( var8 ); + double var22 = Math.cos( var6 ); + double var24 = Math.cos( var8 ); + double[] var28 = new double[3]; + double[] var29 = new double[3]; + var28[0] = var16 * var14; + var28[1] = var16 * var10; + var28[2] = var12; + var29[0] = var24 * var22; + var29[1] = var24 * var18; + var29[2] = var20; + return ( float ) ( Math.asin( Math.sqrt( ( var28[0] - var29[0] ) * ( var28[0] - var29[0] ) + ( var28[1] - var29[1] ) * ( var28[1] - var29[1] ) + ( var28[2] - var29[2] ) * ( var28[2] - var29[2] ) ) / 2.0D ) * 1.27420015798544E7D ); + } catch ( Throwable var26 ) { + var26.printStackTrace(); + return 0.0F; + } + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java new file mode 100644 index 0000000000..5829eee710 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java @@ -0,0 +1,193 @@ +package com.mogo.module.common.drawer; + +import android.graphics.Rect; + +import com.mogo.commons.AbsMogoApplication; +import com.mogo.map.MogoLatLng; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; +import com.mogo.module.common.ModuleNames; +import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.entity.MarkerCarPois; +import com.mogo.module.common.entity.MarkerLocation; +import com.mogo.module.common.entity.MarkerOnlineCar; +import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public +/** + * @author congtaowang + * @since 2020/10/28 + * + * 描述 + */ +class OnlineCarDrawer { + + private static final String TAG = "OnlineCarDrawer"; + + // 平滑移动事件间隔(单位:秒) + private static final int SMOOTH_DURATION = 15; + + private static volatile OnlineCarDrawer sInstance; + + private OnlineCarDrawer() { + } + + public static OnlineCarDrawer getInstance() { + if ( sInstance == null ) { + synchronized ( OnlineCarDrawer.class ) { + if ( sInstance == null ) { + sInstance = new OnlineCarDrawer(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + /** + * 绘制在线车辆marker + * + * @param onlineCarList + */ + public void drawOnlineCarMarkers( List< MarkerOnlineCar > onlineCarList, + int maxAmount, + boolean clearOld, + boolean showBounds, + Rect bound, + MogoLatLng centerPoint, + IMogoMarkerClickListener listener ) { + // 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗 + if ( onlineCarList == null || onlineCarList.isEmpty() ) { + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA ); + return; + } + + if ( clearOld ) { + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA ); + } + + int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, onlineCarList ); + + Map< String, IMogoMarker > existCarMap = MarkerDrawer.getInstance().purgeMarkerData( onlineCarList, ModuleNames.CARD_TYPE_USER_DATA ); + + List< MogoLatLng > carPoints = new ArrayList<>(); + for ( int i = 0; i < size; i++ ) { + MarkerOnlineCar markerOnlineCar = onlineCarList.get( i ); + MarkerLocation markerLocation = markerOnlineCar.getLocation(); + MarkerShowEntity markerShowEntity = new MarkerShowEntity(); + markerShowEntity.setBindObj( markerOnlineCar ); + markerShowEntity.setMarkerLocation( markerLocation ); + markerShowEntity.setMarkerType( markerOnlineCar.getType() ); + + if ( markerOnlineCar.getCarInfo() != null ) { + markerShowEntity.setTextContent( markerOnlineCar.getUserInfo().getUserName() ); + markerShowEntity.setIconUrl( markerOnlineCar.getUserInfo().getUserHead() ); + } + + if ( i <= 5 ) { + carPoints.add( new MogoLatLng( markerLocation.getLat(), markerLocation.getLon() ) ); + } + + String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar ); + IMogoMarker mogoMarker = existCarMap.get( sn ); + if ( mogoMarker == null || mogoMarker.isDestroyed() ) { + mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, listener ); + } + if ( mogoMarker != null ) { + mogoMarker.setVisible( true ); + } + startSmooth( mogoMarker, markerOnlineCar, markerLocation ); + } + + if ( showBounds && bound != null ) { + // 将前6个点显示在固定范围内 + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showBounds( TAG, centerPoint, carPoints, bound, false ); + } + } + + + // 平滑移动 + private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar, + MarkerLocation markerLocation ) { + if ( iMogoMarker == null ) { + return; + } + List< MarkerCarPois > poiList = markerOnlineCar.getPois(); + if ( filterErrorPoint( poiList ) ) { + return; + } + if ( poiList == null || poiList.size() < 2 ) { + return; + } + + List< MogoLatLng > points = new ArrayList<>(); + + double lastLat = 0.0d; + double lastLon = 0.0d; + + for ( int j = 0; j < poiList.size(); j++ ) { + MarkerCarPois poi = poiList.get( j ); + if ( poi == null || poi.getCoordinates() == null && poi.getCoordinates().size() != 2 ) { + continue; + } + try { + double lat = Double.valueOf( poi.getCoordinates().get( 1 ) + "" ); + double lng = Double.valueOf( poi.getCoordinates().get( 0 ) + "" ); + + float distance = MarkerDrawer.calculateLineDistance( lastLon, lastLat, lng, lat ); + lastLon = lng; + lastLat = lat; + if ( distance < 0.2f ) {// 距离过短,认为静止不动 + continue; + } + + points.add( new MogoLatLng( lat, lng ) ); + } catch ( Exception e ) { + } + } + if ( points.size() >= 1 ) { + iMogoMarker.startSmooth( points, SMOOTH_DURATION ); + } else { + Logger.d( TAG, "静止小车,但是有相同的连续坐标" ); + } + } + + /** + * 有可能出现终点到起点跳跃的情况,需要用"500M"约束起点和终点 + * + * @param poiList + */ + private boolean filterErrorPoint( List< MarkerCarPois > poiList ) { + if ( poiList == null || poiList.size() < 2 ) { + return false; + } + MarkerCarPois start = poiList.get( 0 ); + MarkerCarPois end = poiList.get( poiList.size() - 1 ); + + try { + double lat1 = Double.valueOf( start.getCoordinates().get( 1 ) + "" ); + double lng1 = Double.valueOf( start.getCoordinates().get( 0 ) + "" ); + double lat2 = Double.valueOf( end.getCoordinates().get( 1 ) + "" ); + double lng2 = Double.valueOf( end.getCoordinates().get( 0 ) + "" ); + if ( MarkerDrawer.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) { + Logger.d( TAG, "filter point" ); + return true; + } + } catch ( Exception e ) { + } + return false; + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/RoadConditionDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/RoadConditionDrawer.java new file mode 100644 index 0000000000..8fa79aaf08 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/RoadConditionDrawer.java @@ -0,0 +1,128 @@ +package com.mogo.module.common.drawer; + +import android.view.animation.LinearInterpolator; + +import com.mogo.commons.AbsMogoApplication; +import com.mogo.commons.debug.DebugConfig; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; +import com.mogo.map.marker.anim.OnMarkerAnimationListener; +import com.mogo.module.common.ModuleNames; +import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.entity.MarkerExploreWay; +import com.mogo.module.common.entity.MarkerLocation; +import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.utils.WorkThreadHandler; +import com.mogo.utils.logger.Logger; + +import java.util.List; +import java.util.Map; + +public +/** + * @author congtaowang + * @since 2020/10/28 + * + * 描述 + */ +class RoadConditionDrawer { + + private static final String TAG = "RoadConditionDrawer"; + + private static volatile RoadConditionDrawer sInstance; + + private RoadConditionDrawer() { + } + + public static RoadConditionDrawer getInstance() { + if ( sInstance == null ) { + synchronized ( RoadConditionDrawer.class ) { + if ( sInstance == null ) { + sInstance = new RoadConditionDrawer(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + /** + * 探路数据 + * + * @param exploreWayList + */ + public void drawRoadConditionMarker( List< MarkerExploreWay > exploreWayList, int maxAmount, IMogoMarkerClickListener listener ) { + // 将数据同步给探路,避免探路每次 perform 的时候去拉取,造成消耗 + if ( exploreWayList == null || exploreWayList.isEmpty() ) { + MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION ); + return; + } + int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, exploreWayList ); + Map< String, IMogoMarker > existCarMap = MarkerDrawer.getInstance().purgeMarkerData( exploreWayList, ModuleNames.CARD_TYPE_ROAD_CONDITION ); + Logger.i( TAG, "existCarMap: size = %d", existCarMap.size() ); + for ( int i = 0; i < size; i++ ) { + MarkerExploreWay markerExploreWay = exploreWayList.get( i ); + if ( !markerExploreWay.getCanLive() ) { + MarkerLocation markerLocation = markerExploreWay.getLocation(); + + MarkerShowEntity markerShowEntity = new MarkerShowEntity(); + markerShowEntity.setBindObj( markerExploreWay ); + markerShowEntity.setMarkerLocation( markerLocation ); + markerShowEntity.setMarkerType( markerExploreWay.getType() ); + markerShowEntity.setTextContent( markerExploreWay.getAddr() ); + + String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerExploreWay ); + IMogoMarker mogoMarker = existCarMap.get( sn ); + if ( mogoMarker == null || mogoMarker.isDestroyed() ) { + Logger.d( TAG, "draw road condition, sn = %s", sn ); + try { + if ( DebugConfig.isRoadEventAnimated() ) { + post2AddAndStartAnimation( markerShowEntity, i * 100L, listener ); + } else { + mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener ); + } + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } + } + } + + private void post2AddAndStartAnimation( MarkerShowEntity entity, long delay, IMogoMarkerClickListener listener ) { + if ( entity == null ) { + return; + } + WorkThreadHandler.getInstance().postDelayed( () -> { + if ( entity == null ) { + return; + } + IMogoMarker marker = MarkerDrawer.getInstance().drawMapMarkerImpl( entity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener ); + if ( marker == null ) { + return; + } + marker.startScaleAnimationWithAlpha( 0, 1.2f, 0, 1.2f, 0f, 1f, 300, new LinearInterpolator(), new OnMarkerAnimationListener() { + @Override + public void onAnimStart() { + Logger.d( TAG, " onAnimStart ---1----> " ); + } + + @Override + public void onAnimEnd() { + if ( marker == null || marker.isDestroyed() ) { + return; + } + marker.startScaleAnimation( 1.2f, 1, 1.2f, 1, 100, new LinearInterpolator(), null ); + } + } ); + }, delay ); + } +} 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 3b5ca12e41..c45a635e18 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 @@ -108,7 +108,7 @@ class SnapshotSetDataDrawer { points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) ); } if ( points.size() >= 1 ) { - marker.startSmooth( points, 1000 ); + marker.startSmooth( points, 1 ); } } } @@ -160,7 +160,7 @@ class SnapshotSetDataDrawer { } MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_CLOUD_DATA ) - .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) ) + .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) ) .position( new MogoLatLng( data.getLat(), data.getLon() ) ); return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( ModuleNames.CARD_TYPE_ROAD_CONDITION, options ); } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/IMarkerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/IMarkerView.java similarity index 77% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/IMarkerView.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/IMarkerView.java index 44388f2e8f..e4b0892d4e 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/IMarkerView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/IMarkerView.java @@ -1,4 +1,4 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.graphics.Bitmap; import android.view.View; @@ -15,7 +15,7 @@ public interface IMarkerView { View getView(); - default Bitmap getBitmap(int type){ + default Bitmap getBitmap( int type ){ return null; } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerAdapter.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java similarity index 81% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerAdapter.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java index a577317e48..94d682ca4a 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerAdapter.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java @@ -1,17 +1,11 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.text.TextUtils; -import android.view.View; -import com.mogo.commons.AbsMogoApplication; -import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; import com.mogo.module.common.ModuleNames; import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.service.R; /** * author : donghongyu diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerBaseView.java similarity index 88% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerBaseView.java index c790f05e65..ec5f0d8739 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerBaseView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerBaseView.java @@ -1,4 +1,4 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.content.Context; import android.graphics.Bitmap; @@ -7,19 +7,17 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.constraintlayout.widget.ConstraintLayout; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.R; import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.service.MarkerServiceHandler; -import com.mogo.module.service.R; import com.mogo.service.imageloader.IMogoImageLoaderListener; import com.mogo.service.imageloader.MogoImageView; import com.mogo.utils.UiThreadHandler; @@ -83,7 +81,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV private void runOnUiThread(final MarkerShowEntity markerShowEntity){ if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) { - MarkerServiceHandler.getImageloader().displayImage(markerShowEntity.getIconUrl(), + MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(markerShowEntity.getIconUrl(), ivUserHead, WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50), new IMogoImageLoaderListener() { @@ -108,7 +106,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV }); } else { - ivUserHead.setBackgroundResource(R.drawable.icon_default_user_head); + ivUserHead.setBackgroundResource( R.drawable.icon_default_user_head); } } @@ -116,7 +114,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV view.setDrawingCacheEnabled( true ); processChildView( view ); view.destroyDrawingCache(); - view.measure( View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ), View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ) ); + view.measure( MeasureSpec.makeMeasureSpec( 0, MeasureSpec.UNSPECIFIED ), MeasureSpec.makeMeasureSpec( 0, MeasureSpec.UNSPECIFIED ) ); view.layout( 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight() ); Bitmap bitmap = null; return ( bitmap = view.getDrawingCache() ) != null ? bitmap.copy( Bitmap.Config.ARGB_8888, false ) : null; diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerInfoView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java similarity index 95% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerInfoView.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java index 195bd75c83..5270818a0b 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerInfoView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java @@ -1,4 +1,4 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.content.Context; import android.text.TextUtils; @@ -12,12 +12,12 @@ import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.module.common.ModuleNames; +import com.mogo.module.common.R; import com.mogo.module.common.entity.MarkerExploreWay; import com.mogo.module.common.entity.MarkerPoiTypeEnum; import com.mogo.module.common.entity.MarkerShareMusic; import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.service.R; -import com.mogo.module.service.ServiceConst; /** * author : donghongyu @@ -70,8 +70,8 @@ public class MapMarkerInfoView extends MapMarkerBaseView { clMarkerContent.setBackgroundResource( R.drawable.bg_map_marker_yellow_info ); ivReverseTriangle.setImageResource( R.drawable.bg_shape_reverse_yellow ); switch ( markerShowEntity.getMarkerType() ) { - case ServiceConst.CARD_TYPE_CARS_CHATTING: - case ServiceConst.CARD_TYPE_USER_DATA: + case ModuleNames.CARD_TYPE_CARS_CHATTING: + case ModuleNames.CARD_TYPE_USER_DATA: ivUserHead.setVisibility( View.VISIBLE ); ivIcon.setVisibility( View.INVISIBLE ); loadImageWithMarker( markerShowEntity ); @@ -79,8 +79,8 @@ public class MapMarkerInfoView extends MapMarkerBaseView { //ivCar.setRotation(new Random().nextInt(360)); ivCar.setRotation( ( float ) markerShowEntity.getMarkerLocation().getAngle() ); break; - case ServiceConst.CARD_TYPE_ROAD_CONDITION: - case ServiceConst.CARD_TYPE_NOVELTY: + case ModuleNames.CARD_TYPE_ROAD_CONDITION: + case ModuleNames.CARD_TYPE_NOVELTY: ivUserHead.setVisibility( View.INVISIBLE ); ivIcon.setVisibility( View.VISIBLE ); @@ -143,7 +143,7 @@ public class MapMarkerInfoView extends MapMarkerBaseView { } } break; - case ServiceConst.CARD_TYPE_SHARE_MUSIC: + case ModuleNames.CARD_TYPE_SHARE_MUSIC: ivUserHead.setVisibility( View.INVISIBLE ); ivIcon.setVisibility( View.VISIBLE ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java similarity index 92% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java index 0912f537d6..d5a53835e0 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java @@ -1,4 +1,4 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.content.Context; import android.util.AttributeSet; @@ -7,12 +7,12 @@ import android.view.LayoutInflater; import androidx.annotation.Nullable; import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.module.common.ModuleNames; import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.R; import com.mogo.module.common.entity.MarkerExploreWay; import com.mogo.module.common.entity.MarkerPoiTypeEnum; import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.service.R; -import com.mogo.module.service.ServiceConst; /** * author : donghongyu @@ -52,10 +52,13 @@ public class MapMarkerView extends MapMarkerBaseView { try { Object bindObj = markerShowEntity.getBindObj(); if ( MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) { + ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr ); + } else { + ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow ); } switch ( markerShowEntity.getMarkerType() ) { - case ServiceConst.CARD_TYPE_ROAD_CONDITION: - case ServiceConst.CARD_TYPE_NOVELTY: + case ModuleNames.CARD_TYPE_ROAD_CONDITION: + case ModuleNames.CARD_TYPE_NOVELTY: if ( bindObj instanceof MarkerExploreWay && ( ( MarkerExploreWay ) bindObj ).getPoiType() != null ) { switch ( ( ( MarkerExploreWay ) bindObj ).getPoiType() ) { case MarkerPoiTypeEnum.GAS_STATION: diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/OnlineCarMarkerView.java similarity index 96% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java rename to modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/OnlineCarMarkerView.java index 33c9aea200..81459e5a74 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/OnlineCarMarkerView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/OnlineCarMarkerView.java @@ -1,4 +1,4 @@ -package com.mogo.module.service.marker; +package com.mogo.module.common.drawer.marker; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -6,8 +6,7 @@ import android.view.View; import com.mogo.commons.AbsMogoApplication; import com.mogo.map.marker.IMogoMarker; -import com.mogo.module.common.ModuleNames; -import com.mogo.module.service.R; +import com.mogo.module.common.R; import java.lang.ref.SoftReference; import java.util.HashMap; diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_4s.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_4s.png new file mode 100644 index 0000000000..11c5c6ea7b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_4s.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_book.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_book.png new file mode 100644 index 0000000000..f846dcefc3 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_book.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray.png new file mode 100644 index 0000000000..d4266a6bc5 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png new file mode 100644 index 0000000000..725a560b4f Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_gray_selected.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type2.png new file mode 100644 index 0000000000..10221fcb01 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_110.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_110.png new file mode 100644 index 0000000000..74f12e781d Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_110.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_119.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_119.png new file mode 100644 index 0000000000..db23ff7144 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_119.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_120.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_120.png new file mode 100644 index 0000000000..1c929ca8a0 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_120.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_bus.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_bus.png new file mode 100644 index 0000000000..afe1372cb9 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_bus.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_taxi.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_taxi.png new file mode 100644 index 0000000000..0b363c6d61 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_car_type_taxi.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living.png new file mode 100644 index 0000000000..d6f1dea192 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living_white.png new file mode 100644 index 0000000000..1b87f0ce86 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_living_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow.png new file mode 100644 index 0000000000..f05356795e Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png new file mode 100644 index 0000000000..eca4f04cef Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_misic.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_misic.png new file mode 100644 index 0000000000..b0dc73d75a Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_misic.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_news.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_news.png new file mode 100644 index 0000000000..26edaa7f7a Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_news.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl.png new file mode 100644 index 0000000000..fc3ff86372 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2.png new file mode 100755 index 0000000000..478232ac79 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2_white.png new file mode 100755 index 0000000000..700226f150 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_pondingl2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_refuel.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_refuel.png new file mode 100644 index 0000000000..bac7ee2e40 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_refuel.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off.png new file mode 100644 index 0000000000..8c6b30842b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2.png new file mode 100755 index 0000000000..2fb4ef553e Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2_white.png new file mode 100755 index 0000000000..9b424494ee Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_off2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up.png new file mode 100644 index 0000000000..29fd407dca Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2.png new file mode 100755 index 0000000000..e62fd5ec03 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2_white.png new file mode 100755 index 0000000000..0ac89f4dec Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_block_up2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check.png new file mode 100644 index 0000000000..7f8f80be69 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2.png new file mode 100755 index 0000000000..001974ba87 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2_white.png new file mode 100755 index 0000000000..5baea2a41b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_check2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work.png new file mode 100644 index 0000000000..0b0d4bbab5 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2.png new file mode 100755 index 0000000000..c11e911f15 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2_white.png new file mode 100755 index 0000000000..7875086c3e Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_road_work2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shear_news.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shear_news.png new file mode 100644 index 0000000000..f446cba155 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shear_news.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop.png new file mode 100644 index 0000000000..d8be56fd47 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop_discount.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop_discount.png new file mode 100644 index 0000000000..97e8a4967b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/icon_map_marker_shop_discount.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_left.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_left.png new file mode 100644 index 0000000000..702a793d5a Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_left.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_middle.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_middle.png new file mode 100644 index 0000000000..3bfa172f98 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_middle.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_reverse.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_reverse.png new file mode 100644 index 0000000000..e034294816 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_reverse.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_right.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_right.png new file mode 100644 index 0000000000..43a86c955d Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_right.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_call.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_call.png new file mode 100644 index 0000000000..9a9321b3a6 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_call.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident.png new file mode 100644 index 0000000000..8dd43b20a7 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident2.png new file mode 100644 index 0000000000..1e61298d35 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3.png new file mode 100755 index 0000000000..fe68bc7cba Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3_white.png new file mode 100755 index 0000000000..911bee2df4 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_accident3_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog.png new file mode 100644 index 0000000000..61296d59d2 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2.png new file mode 100755 index 0000000000..787101fbb1 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2_white.png new file mode 100755 index 0000000000..b6164bcfdd Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_dark_frog2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze.png new file mode 100644 index 0000000000..ea07251424 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2.png new file mode 100755 index 0000000000..d34779845e Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2_white.png new file mode 100755 index 0000000000..353cfefec6 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_freeze2_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park.png new file mode 100644 index 0000000000..5923d114f6 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park_white.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park_white.png new file mode 100644 index 0000000000..dbc420e8e6 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_illegal_park_white.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking.png new file mode 100644 index 0000000000..33cb8fd3ce Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking2.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking2.png new file mode 100644 index 0000000000..8026654bdf Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_parking2.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery.png new file mode 100644 index 0000000000..f11b4a4178 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery_light.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery_light.png new file mode 100644 index 0000000000..e78307acd8 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_rc_road_slippery_light.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png new file mode 100755 index 0000000000..aa6eb75043 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_service_ic_seek_helping.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable/bg_map_marker_yellow_info.xml b/modules/mogo-module-common/src/main/res/drawable/bg_map_marker_yellow_info.xml new file mode 100644 index 0000000000..b2be8e312e --- /dev/null +++ b/modules/mogo-module-common/src/main/res/drawable/bg_map_marker_yellow_info.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-common/src/main/res/drawable/bg_shape_reverse_yellow.xml b/modules/mogo-module-common/src/main/res/drawable/bg_shape_reverse_yellow.xml new file mode 100644 index 0000000000..6bc80c96dc --- /dev/null +++ b/modules/mogo-module-common/src/main/res/drawable/bg_shape_reverse_yellow.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout.xml b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout.xml new file mode 100644 index 0000000000..c8b06a6245 --- /dev/null +++ b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml new file mode 100644 index 0000000000..444e398c97 --- /dev/null +++ b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index 199c972202..e1b35231b4 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -10,6 +10,7 @@ import com.mogo.map.navi.IMogoNavi; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.carchattingprovider.ICarsChattingProvider; import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.drawer.MarkerDrawer; import com.mogo.module.common.entity.MarkerResponse; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.gps.simulator.IMogoGpsSimulatorManager; @@ -193,7 +194,7 @@ public class MarkerServiceHandler { */ @Deprecated public static IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity ) { - return getMapMarkerManager().drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH ); + return getMapMarkerManager().drawMapMarker( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH ); } /** 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 c42b5dc99d..e7bbacb98b 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 @@ -112,10 +112,6 @@ public class ServiceConst { */ public static final int MSG_LOCK_CAR = 0x202; - public static final int MARKER_Z_INDEX_HIGH = 100; - public static final int MARKER_Z_INDEX_LOW = 2; - - /** * 切换卡片内容-上一个 */ 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 bcffc5c194..4bfff517c3 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 @@ -3,7 +3,6 @@ package com.mogo.module.service.marker; import android.content.Context; import android.graphics.Rect; import android.text.TextUtils; -import android.view.animation.LinearInterpolator; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.debug.DebugConfig; @@ -11,27 +10,26 @@ import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.IMogoMarkerClickListener; import com.mogo.map.marker.IMogoMarkerManager; -import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.map.marker.anim.OnMarkerAnimationListener; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.module.common.ModuleNames; import com.mogo.module.common.api.CallChatApi; import com.mogo.module.common.drawer.AdasRecognizedResultDrawer; +import com.mogo.module.common.drawer.MarkerDrawer; +import com.mogo.module.common.drawer.OnlineCarDrawer; +import com.mogo.module.common.drawer.RoadConditionDrawer; import com.mogo.module.common.drawer.SnapshotSetDataDrawer; -import com.mogo.module.common.entity.MarkerCarPois; +import com.mogo.module.common.drawer.marker.IMarkerView; +import com.mogo.module.common.drawer.marker.MapMarkerAdapter; +import com.mogo.module.common.drawer.marker.OnlineCarMarkerView; import com.mogo.module.common.entity.MarkerCardResult; import com.mogo.module.common.entity.MarkerExploreWay; -import com.mogo.module.common.entity.MarkerLocation; -import com.mogo.module.common.entity.MarkerNoveltyInfo; import com.mogo.module.common.entity.MarkerOnlineCar; import com.mogo.module.common.entity.MarkerResponse; -import com.mogo.module.common.entity.MarkerShareMusic; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.common.entity.MogoSnapshotSetData; import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.R; import com.mogo.module.service.ServiceConst; -import com.mogo.module.service.Utils; import com.mogo.module.service.network.RefreshCallback; import com.mogo.module.service.network.RefreshModel; import com.mogo.module.service.utils.ViewUtils; @@ -44,7 +42,6 @@ import com.mogo.service.module.IMogoBizActionDoneListener; import com.mogo.utils.ResourcesHelper; import com.mogo.utils.ThreadPoolService; import com.mogo.utils.UiThreadHandler; -import com.mogo.utils.WorkThreadHandler; import com.mogo.utils.logger.Logger; import org.json.JSONArray; @@ -195,7 +192,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, Map< String, Object > properties = new HashMap<>(); if ( marker.getObject() instanceof MarkerShowEntity ) { - final String sn = getCarSnFromMarker( marker ); + final String sn = MarkerDrawer.getInstance().getCarSnFromMarker( marker ); if ( TextUtils.isEmpty( sn ) ) { return false; } @@ -375,260 +372,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener, */ private void drawAllMarker( MarkerCardResult markerCardResult ) { List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay(); - drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL ); + RoadConditionDrawer.getInstance().drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL, this ); } - /** - * 绘制在线车辆marker - * - * @param onlineCarList - */ - private void drawOnlineCarMarkers( List< MarkerOnlineCar > onlineCarList, - int maxAmount, - boolean clearOld, - boolean showBounds, - Rect bound, - MogoLatLng centerPoint ) { - // 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗 - if ( onlineCarList == null || onlineCarList.isEmpty() ) { - MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA ); - return; - } - - if ( clearOld ) { - MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA ); - } - - int size = getAppropriateSize( maxAmount, onlineCarList ); - - Map< String, IMogoMarker > existCarMap = purgeMarkerData( onlineCarList, ModuleNames.CARD_TYPE_USER_DATA ); - - List< MogoLatLng > carPoints = new ArrayList<>(); - for ( int i = 0; i < size; i++ ) { - MarkerOnlineCar markerOnlineCar = onlineCarList.get( i ); - MarkerLocation markerLocation = markerOnlineCar.getLocation(); - MarkerShowEntity markerShowEntity = new MarkerShowEntity(); - markerShowEntity.setBindObj( markerOnlineCar ); - markerShowEntity.setMarkerLocation( markerLocation ); - markerShowEntity.setMarkerType( markerOnlineCar.getType() ); - - if ( markerOnlineCar.getCarInfo() != null ) { - markerShowEntity.setTextContent( markerOnlineCar.getUserInfo().getUserName() ); - markerShowEntity.setIconUrl( markerOnlineCar.getUserInfo().getUserHead() ); - } - - if ( i <= 5 ) { - carPoints.add( new MogoLatLng( markerLocation.getLat(), markerLocation.getLon() ) ); - } - - String sn = getPrimaryKeyFromEntity( markerOnlineCar ); - IMogoMarker mogoMarker = existCarMap.get( sn ); - if ( mogoMarker == null || mogoMarker.isDestroyed() ) { - mogoMarker = drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_LOW ); - } - if ( mogoMarker != null ) { - mogoMarker.setVisible( true ); - } - startSmooth( mogoMarker, markerOnlineCar, markerLocation ); - } - - if ( showBounds && bound != null ) { - // 将前6个点显示在固定范围内 - MarkerServiceHandler.getMapUIController().showBounds( TAG, centerPoint, carPoints, bound, false ); - } - } - - /** - * 探路数据 - * - * @param exploreWayList - */ - private void drawRoadConditionMarker( List< MarkerExploreWay > exploreWayList, int maxAmount ) { - // 将数据同步给探路,避免探路每次 perform 的时候去拉取,造成消耗 - if ( exploreWayList == null || exploreWayList.isEmpty() ) { - MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION ); - return; - } - int size = getAppropriateSize( maxAmount, exploreWayList ); - Map< String, IMogoMarker > existCarMap = purgeMarkerData( exploreWayList, ModuleNames.CARD_TYPE_ROAD_CONDITION ); - Logger.i( TAG, "existCarMap: size = %d", existCarMap.size() ); - for ( int i = 0; i < size; i++ ) { - MarkerExploreWay markerExploreWay = exploreWayList.get( i ); - if ( !markerExploreWay.getCanLive() ) { - MarkerLocation markerLocation = markerExploreWay.getLocation(); - - MarkerShowEntity markerShowEntity = new MarkerShowEntity(); - markerShowEntity.setBindObj( markerExploreWay ); - markerShowEntity.setMarkerLocation( markerLocation ); - markerShowEntity.setMarkerType( markerExploreWay.getType() ); - markerShowEntity.setTextContent( markerExploreWay.getAddr() ); - - String sn = getPrimaryKeyFromEntity( markerExploreWay ); - IMogoMarker mogoMarker = existCarMap.get( sn ); - if ( mogoMarker == null || mogoMarker.isDestroyed() ) { - Logger.d( TAG, "draw road condition, sn = %s", sn ); - try { - if ( DebugConfig.isRoadEventAnimated() ) { - post2AddAndStartAnimation( markerShowEntity, i * 100L ); - } else { - mogoMarker = drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH ); - } - } catch ( Exception e ) { - e.printStackTrace(); - } - } - } - } - } - - private void post2AddAndStartAnimation( MarkerShowEntity entity, long delay ) { - if ( entity == null ) { - return; - } - WorkThreadHandler.getInstance().postDelayed( () -> { - if ( entity == null ) { - return; - } - IMogoMarker marker = drawMapMarker( entity, ServiceConst.MARKER_Z_INDEX_HIGH ); - if ( marker == null ) { - return; - } - marker.startScaleAnimationWithAlpha( 0, 1.2f, 0, 1.2f, 0f, 1f, 300, new LinearInterpolator(), new OnMarkerAnimationListener() { - @Override - public void onAnimStart() { - Logger.d( TAG, " onAnimStart ---1----> " ); - } - - @Override - public void onAnimEnd() { - if ( marker == null || marker.isDestroyed() ) { - return; - } - marker.startScaleAnimation( 1.2f, 1, 1.2f, 1, 100, new LinearInterpolator(), null ); - } - } ); - }, delay ); - } - - /** - * S = (A ∩ B) ∪ B - * (A ∩ B)作为旧列表需要保留的部分 - * - * @param newList - * @return - */ - private Map< String, IMogoMarker > purgeMarkerData( List newList, String markerType ) { - - final long start = System.currentTimeMillis(); - Map< String, IMogoMarker > existMap = new HashMap<>(); - List< IMogoMarker > allCarsList = MarkerServiceHandler.getMarkerManager().getMarkers( markerType ); - if ( allCarsList == null || allCarsList.isEmpty() ) { - return existMap; - } - if ( newList == null || newList.isEmpty() ) { - return existMap; - } - - Map< String, IMogoMarker > allMap = new HashMap<>(); - for ( IMogoMarker marker : allCarsList ) { - String sn = getPrimaryKeyFromMarker( marker ); - allMap.put( sn, marker ); - } - for ( Object entity : newList ) { - String sn = getPrimaryKeyFromEntity( entity ); - if ( allMap.containsKey( sn ) ) { - if ( !isNewVehicleType( entity, allMap.get( sn ) ) ) { - existMap.put( sn, allMap.get( sn ) ); - } - } - } - for ( String sn : allMap.keySet() ) { - if ( !existMap.containsKey( sn ) ) { - IMogoMarker dirtyMarker = allMap.get( sn ); - allCarsList.remove( dirtyMarker ); - dirtyMarker.destroy(); - } - } - allMap.clear(); - Logger.i( "timer", "purge data cost " + ( System.currentTimeMillis() - start ) + "ms" ); - return existMap; - } - - private boolean isNewVehicleType( Object object, IMogoMarker marker ) { - if ( object instanceof MarkerOnlineCar - && marker != null - && marker.getObject() instanceof MarkerShowEntity - && ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerOnlineCar ) { - try { - return ( ( MarkerOnlineCar ) object ).getCarInfo().getVehicleType() - != ( ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ).getCarInfo().getVehicleType(); - } catch ( Exception e ) { - - } - } - return false; - } - - private String getPrimaryKeyFromEntity( Object entity ) { - if ( entity instanceof MarkerExploreWay ) { - String id = ( ( MarkerExploreWay ) entity ).getInfoId(); - if ( !TextUtils.isEmpty( id ) ) { - return id; - } - } - return getCarSnFromEntity( entity ); - } - - private String getPrimaryKeyFromMarker( IMogoMarker marker ) { - if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) { - return null; - } - if ( !( marker.getObject() instanceof MarkerShowEntity ) ) { - return null; - } - return getPrimaryKeyFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ); - } - - private String getCarSnFromEntity( Object entity ) { - try { - if ( entity instanceof MarkerOnlineCar ) { - return ( ( MarkerOnlineCar ) entity ).getUserInfo().getSn(); - } else if ( entity instanceof MarkerShareMusic ) { - return ( ( MarkerShareMusic ) entity ).getUserInfo().getSn(); - } else if ( entity instanceof MarkerNoveltyInfo ) { - return ( ( MarkerNoveltyInfo ) entity ).getSn(); - } else if ( entity instanceof MarkerExploreWay ) { - return ( ( MarkerExploreWay ) entity ).getUserInfo().getSn(); - } - } catch ( Exception e ) { - - } - return ""; - } - - private String getCarSnFromMarker( IMogoMarker marker ) { - if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) { - return null; - } - if ( !( marker.getObject() instanceof MarkerShowEntity ) ) { - return null; - } - return getCarSnFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ); - } - - /** - * @param maxAmount 展示的最大数量 - * @param list - * @return - */ - private int getAppropriateSize( int maxAmount, List list ) { - if ( list == null ) { - return 0; - } - return Math.min( maxAmount, list.size() ); - } - - /** * 统计地图内数据获取 * @@ -714,37 +460,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, } } - /** - * 大而全数据计数埋点 - */ - private synchronized static JSONObject fillPoiTypeTrackBody( JSONArray arr, String poiType, int poiTypeNum ) { - JSONObject object = new JSONObject(); - try { - object.put( "poitype", poiType ); - object.put( "num", poiTypeNum ); - if ( arr != null ) { - arr.put( object ); - } - return object; - } catch ( JSONException e ) { - e.printStackTrace(); - } - return null; - } - - private synchronized static void fillPoiChildTypeTrackBody( JSONArray arr, String childType, int childTypeNum ) { - JSONObject object = new JSONObject(); - try { - object.put( "contenttype", childType ); - object.put( "num", childTypeNum ); - if ( arr != null ) { - arr.put( object ); - } - } catch ( JSONException e ) { - e.printStackTrace(); - } - } - /** * 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护 * @@ -753,39 +468,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener, */ public synchronized IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity, int zIndex ) { try { - return drawMapMarkerImpl( markerShowEntity, zIndex ); + return MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, zIndex, this ); } catch ( Exception e ) { Logger.e( TAG, e, "drawMapMarker" ); return null; } } - private IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex ) { - if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) { - return null; - } - MogoMarkerOptions options = new MogoMarkerOptions().owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() ); - IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, options ); - if ( markerView instanceof OnlineCarMarkerView ) { - try { - options.icon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) ); - } catch ( Exception e ) { - options.icon( markerView.getBitmap( 0 ) ); - } - options.anchor( 0.5f, 0.5f ); - } else { - options.icon( markerView.getView() ); - } - - IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker( markerShowEntity.getMarkerType(), options ); - marker.setOwner( markerShowEntity.getMarkerType() ); - markerView.setMarker( marker ); - marker.setOnMarkerClickListener( this ); - markerShowEntity.setMarker( marker ); - return marker; - } - - @Override public Class< MarkerResponse > target() { return MarkerResponse.class; @@ -919,7 +608,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, runOnTargetThread( () -> { Logger.d( TAG, "内部 - 请求完毕开始处理" ); trackData( size ); - drawOnlineCarMarkers( onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng ); + OnlineCarDrawer.getInstance().drawOnlineCarMarkers( onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this ); UiThreadHandler.postDelayed( runnable, SMOOTH_DURATION * 1000 ); } ); } @@ -958,77 +647,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA ); } - // 平滑移动 - private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar, - MarkerLocation markerLocation ) { - if ( iMogoMarker == null ) { - return; - } - List< MarkerCarPois > poiList = markerOnlineCar.getPois(); - if ( filterErrorPoint( poiList ) ) { - return; - } - if ( poiList == null || poiList.size() < 2 ) { - return; - } - List< MogoLatLng > points = new ArrayList<>(); - - double lastLat = 0.0d; - double lastLon = 0.0d; - - for ( int j = 0; j < poiList.size(); j++ ) { - MarkerCarPois poi = poiList.get( j ); - if ( poi == null || poi.getCoordinates() == null && poi.getCoordinates().size() != 2 ) { - continue; - } - try { - double lat = Double.valueOf( poi.getCoordinates().get( 1 ) + "" ); - double lng = Double.valueOf( poi.getCoordinates().get( 0 ) + "" ); - - float distance = Utils.calculateLineDistance( lastLon, lastLat, lng, lat ); - lastLon = lng; - lastLat = lat; - if ( distance < 0.2f ) {// 距离过短,认为静止不动 - continue; - } - - points.add( new MogoLatLng( lat, lng ) ); - } catch ( Exception e ) { - } - } - if ( points.size() >= 1 ) { - iMogoMarker.startSmooth( points, SMOOTH_DURATION ); - } else { - Logger.d( TAG, "静止小车,但是有相同的连续坐标" ); - } - } - - /** - * 有可能出现终点到起点跳跃的情况,需要用"500M"约束起点和终点 - * - * @param poiList - */ - private boolean filterErrorPoint( List< MarkerCarPois > poiList ) { - if ( poiList == null || poiList.size() < 2 ) { - return false; - } - MarkerCarPois start = poiList.get( 0 ); - MarkerCarPois end = poiList.get( poiList.size() - 1 ); - - try { - double lat1 = Double.valueOf( start.getCoordinates().get( 1 ) + "" ); - double lng1 = Double.valueOf( start.getCoordinates().get( 0 ) + "" ); - double lat2 = Double.valueOf( end.getCoordinates().get( 1 ) + "" ); - double lng2 = Double.valueOf( end.getCoordinates().get( 0 ) + "" ); - if ( Utils.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) { - Logger.d( TAG, "filter point" ); - return true; - } - } catch ( Exception e ) { - } - return false; - } private boolean ignoreDrawRequest() { return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MogoMarkerServiceImpl.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MogoMarkerServiceImpl.java index 6e820c88a2..47044f9b9f 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MogoMarkerServiceImpl.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MogoMarkerServiceImpl.java @@ -6,6 +6,7 @@ import androidx.annotation.Nullable; import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.map.marker.IMogoMarker; +import com.mogo.module.common.drawer.MarkerDrawer; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.ServiceConst; @@ -28,7 +29,7 @@ public class MogoMarkerServiceImpl implements IMogoMarkerService { @Override public IMogoMarker drawMarker( Object object ) { if ( object instanceof MarkerShowEntity ) { - return MarkerServiceHandler.getMapMarkerManager().drawMapMarker( ( ( MarkerShowEntity ) object ), ServiceConst.MARKER_Z_INDEX_HIGH ); + return MarkerServiceHandler.getMapMarkerManager().drawMapMarker( ( ( MarkerShowEntity ) object ), MarkerDrawer.MARKER_Z_INDEX_HIGH ); } Logger.w( TAG, "object must instance of [com.mogo.module.common.entity.MarkerShowEntity]" ); return null; diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java deleted file mode 100644 index 42048bc2eb..0000000000 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/UserDataMarkerInfoWindowAdapter.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.mogo.module.service.marker; - -import android.content.Context; -import android.os.Looper; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - -import com.mogo.commons.debug.DebugConfig; -import com.mogo.commons.network.SubscribeImpl; -import com.mogo.map.marker.IMogoInfoWindowAdapter; -import com.mogo.map.marker.IMogoMarker; -import com.mogo.module.common.entity.MarkerLocation; -import com.mogo.module.common.entity.MarkerOnlineCar; -import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.common.entity.MarkerUserInfo; -import com.mogo.module.service.MarkerServiceHandler; -import com.mogo.module.service.R; -import com.mogo.module.service.network.RefreshApiService; -import com.mogo.module.service.network.RefreshModel; -import com.mogo.module.service.network.bean.DemoUserInfoEntity; -import com.mogo.service.imageloader.MogoImageView; -import com.mogo.service.network.IMogoNetwork; -import com.mogo.utils.UiThreadHandler; -import com.mogo.utils.WindowUtils; -import com.mogo.utils.logger.Logger; -import com.mogo.utils.network.RequestOptions; -import com.zhidao.carchattingprovider.CallChattingProviderConstant; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.schedulers.Schedulers; - -/** - * @author congtaowang - * @since 2020-04-27 - *

- * 在线车辆点击后弹出的info window 样式 - */ -public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter { - - private static final String TAG = "UserDataMarkerInfoWindowAdapter"; - - private static volatile UserDataMarkerInfoWindowAdapter sInstance; - private final Context mContext; - private static RefreshApiService sRefreshApiService; - - private View mInfoWindowView = null; - - private View mContentContainer; - private MogoImageView mUserHeader; - private TextView mContent; - private TextView mTag; - private ImageView mCall; - - private UserDataMarkerInfoWindowAdapter( Context context ) { - this.mContext = context; - IMogoNetwork network = MarkerServiceHandler.getApis().getNetworkApi(); - sRefreshApiService = network.create( RefreshApiService.class, RefreshModel.getNetHost() ); - } - - public static UserDataMarkerInfoWindowAdapter getInstance( Context context ) { - if ( sInstance == null ) { - synchronized ( UserDataMarkerInfoWindowAdapter.class ) { - if ( sInstance == null ) { - sInstance = new UserDataMarkerInfoWindowAdapter( context ); - } - } - } - return sInstance; - } - - public synchronized void release() { - sInstance = null; - } - - @Override - public View getInfoWindow( IMogoMarker marker ) { - return inflateView( marker ); - } - - private View inflateView( IMogoMarker marker ) { - if ( marker == null ) { - return null; - } - - if ( mInfoWindowView == null ) { - mInfoWindowView = LayoutInflater.from( mContext ).inflate( R.layout.modudle_services_marker_info_window_layout, null ); - mContentContainer = mInfoWindowView.findViewById( R.id.module_service_id_marker_content ); - mUserHeader = mInfoWindowView.findViewById( R.id.module_service_id_user_header ); - mContent = mInfoWindowView.findViewById( R.id.module_service_id_content ); - mTag = mInfoWindowView.findViewById( R.id.module_service_id_tag ); - mCall = mInfoWindowView.findViewById( R.id.module_service_id_call ); - } - - if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) { - mContentContainer.setPadding( - mContentContainer.getPaddingLeft(), - mContentContainer.getPaddingTop(), - mContentContainer.getResources().getDimensionPixelSize( R.dimen.module_service_id_marker_content_paddingRight_widthoutCall ), - mContentContainer.getPaddingBottom() - ); - mCall.setVisibility( View.GONE ); - } - - try { - MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) marker.getObject(); - mContent.setText( markerShowEntity.getTextContent() ); - loadImageHeader( markerShowEntity ); - if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) { - try { - mTag.setText( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getUserInfo().getSafeLabel() ); - } catch ( Exception e ) { - e.printStackTrace(); - } - } - mCall.setOnClickListener( view -> { - if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) { - if ( DebugConfig.getNetMode() != DebugConfig.NET_MODE_DEMO ) { - callToFactUser( markerShowEntity ); - return; - } - sRefreshApiService.getMockUsers().subscribeOn( Schedulers.io() ) - .observeOn( AndroidSchedulers.mainThread() ) - .subscribe( new SubscribeImpl< DemoUserInfoEntity >( RequestOptions.create( mContext ) ) { - @Override - public void onSuccess( DemoUserInfoEntity o ) { - super.onSuccess( o ); - callToDemoUser( markerShowEntity, o ); - } - - @Override - public void onError( String message, int code ) { - super.onError( message, code ); - callToFactUser( markerShowEntity ); - } - } ); - } - } ); - } catch ( Exception e ) { - Logger.e( TAG, e, "error." ); - } - - return mInfoWindowView; - } - - private void callToDemoUser( MarkerShowEntity factUser, DemoUserInfoEntity demoUser ) { - if ( demoUser == null - || demoUser.getResult() == null - || demoUser.getResult().getUserList() == null - || demoUser.getResult().getUserList().isEmpty() ) { - callToFactUser( factUser ); - return; - } - List< DemoUserInfoEntity.ResultBean.UserListBean > users = demoUser.getResult().getUserList(); - for ( DemoUserInfoEntity.ResultBean.UserListBean user : users ) { - if ( user == null ) { - continue; - } - if ( TextUtils.equals( "1", user.getSceneType() ) ) { - try { - ( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo().setSn( user.getUserInfo().getSn() ); - callToFactUser( factUser ); - return; - } catch ( Exception e ) { - } - } - } - callToFactUser( factUser ); - } - - private void callToFactUser( MarkerShowEntity factUser ) { - if ( factUser == null ) { - return; - } - Map< String, String > params = new HashMap<>(); - MarkerUserInfo userInfo = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo(); - if ( userInfo != null ) { - params.put( CallChattingProviderConstant.CCPROVIDER_SN, userInfo.getSn() ); - params.put( CallChattingProviderConstant.CCPROVIDER_USER_IMG, userInfo.getUserHead() ); - params.put( CallChattingProviderConstant.CCPROVIDER_USER_AGE, userInfo.getAgeNumber() + "" ); - params.put( CallChattingProviderConstant.CCPROVIDER_NICK_NAME, userInfo.getUserName() ); - params.put( CallChattingProviderConstant.CCPROVIDER_USER_SEX, userInfo.getGender() + "" ); - } - MarkerLocation location = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getLocation(); - if ( location != null ) { - params.put( CallChattingProviderConstant.CCPROVIDER_ADDRESS, location.getAddress() ); - params.put( CallChattingProviderConstant.CCPROVIDER_LAT, location.getLat() + "" ); - params.put( CallChattingProviderConstant.CCPROVIDER_LON, location.getLon() + "" ); - } - Logger.d( TAG, "call parameters: %s", params ); - if ( MarkerServiceHandler.getApis().getStatusManagerApi().isV2XShow() ) { - MarkerServiceHandler.getCarChatting().callShowWindow( params ); - } else { - MarkerServiceHandler.getCarChatting().call( params ); - } - } - - protected void loadImageHeader( final MarkerShowEntity markerShowEntity ) { - - if ( Looper.myLooper() != Looper.getMainLooper() ) { - UiThreadHandler.post( () -> { - runOnUiThread( markerShowEntity ); - } ); - } else { - runOnUiThread( markerShowEntity ); - } - } - - private void runOnUiThread( final MarkerShowEntity markerShowEntity ) { - if ( !TextUtils.isEmpty( markerShowEntity.getIconUrl() ) ) { - MarkerServiceHandler.getImageloader().displayImage( markerShowEntity.getIconUrl(), - mUserHeader, - WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ), null ); - - } else { - mUserHeader.setBackgroundResource( R.drawable.icon_default_user_head ); - } - } -} diff --git a/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png b/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png new file mode 100644 index 0000000000..eca4f04cef Binary files /dev/null and b/modules/mogo-module-service/src/main/res/drawable-xhdpi/icon_map_marker_location_yellow_vr.png differ diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401003.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401003.java index 17eca2d238..fcceadaf2e 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401003.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401003.java @@ -101,10 +101,6 @@ public class V2XMessageListener_401003 implements IMogoOnMessageListener implements IMogoTopViewStatusListener { + private String TAG = "V2XPushVREventWindow"; private static V2XPushVREventScenario mV2XPushEventScenario; @@ -37,6 +36,7 @@ public class V2XPushVREventScenario if (mV2XPushEventScenario == null) { mV2XPushEventScenario = new V2XPushVREventScenario(); mV2XPushEventScenario.setV2XMarker(new V2XPushVREventMarker()); + mV2XPushEventScenario.setV2XWindow(new V2XPushVREventWindow()); } } } @@ -46,15 +46,17 @@ public class V2XPushVREventScenario @Override public void init(@Nullable V2XMessageEntity v2XMessageEntity) { - Logger.w(MODULE_NAME, "处理推送VR场景:" + GsonUtil.jsonFromObject(v2XMessageEntity)); + Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR场景:" + GsonUtil.jsonFromObject(v2XMessageEntity)); if (!isSameScenario(v2XMessageEntity) && V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) { setV2XMessageEntity(v2XMessageEntity); show(); } else { + closeWindow(); setV2XMessageEntity(v2XMessageEntity); - Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化"); + show(); + Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "要处理的场景已经存在,丢弃这次初始化"); } } @@ -70,7 +72,7 @@ public class V2XPushVREventScenario @Override public void showWindow() { if (getV2XWindow() != null) { - //TODO 这里调用 showLeftNoticeByType 进行展示左下角的弹窗 + getV2XWindow().show(getV2XMessageEntity().getContent()); } } @@ -115,22 +117,22 @@ public class V2XPushVREventScenario //////////////////////////////////////////////////////////////////////////////////////////////////// @Override public void onViewAdded(View view) { - Logger.d(MODULE_NAME, "展示 Window 动画结束"); + Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 动画结束"); } @Override public void onViewRemoved(View view) { - Logger.d(MODULE_NAME, "关闭 Window 动画结束"); + Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 动画结束"); } @Override public void beforeViewAddAnim(View view) { - Logger.d(MODULE_NAME, "展示 Window 开始"); + Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 开始"); } @Override public void beforeViewRemoveAnim(View view) { - Logger.d(MODULE_NAME, "关闭 Window 开始"); + Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 开始"); V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false); // 重置场景提示的消息 setV2XMessageEntity(null); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/pushVR/V2XPushVREventWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/pushVR/V2XPushVREventWindow.java new file mode 100644 index 0000000000..168cb90ec7 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/pushVR/V2XPushVREventWindow.java @@ -0,0 +1,93 @@ +package com.mogo.module.v2x.scenario.scene.pushVR; + +import android.os.Handler; +import android.view.View; + +import com.mogo.module.common.entity.V2XPushMessageEntity; +import com.mogo.module.v2x.R; +import com.mogo.module.v2x.V2XServiceManager; +import com.mogo.module.v2x.listener.V2XWindowStatusListener; +import com.mogo.module.v2x.scenario.view.IV2XWindow; +import com.mogo.service.entrance.IMogoEntranceButtonController; +import com.mogo.utils.logger.Logger; + +import static com.mogo.module.v2x.V2XConst.MODULE_NAME; + +/** + * author : donghongyu + * e-mail : 1358506549@qq.com + * date : 2020/4/14 2:37 PM + * desc : + * TODO 只有VR演示场景使用 + * version: 1.0 + */ +public class V2XPushVREventWindow implements IV2XWindow { + private String TAG = "V2XPushVREventWindow"; + + // 处理道路事件,30秒倒计时 + private Handler handlerV2XEvent = new Handler(); + private Runnable runnableV2XEvent; + private int mExpireTime = 30000; + + /** + * 展示道路事件详情Windows + */ + @Override + public void show(V2XPushMessageEntity entity) { + Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息:展示 Window=\n" + entity); + + V2XServiceManager + .getMogoEntranceButtonController() + .showLeftNoticeByType( + IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED, + R.drawable.module_v2x_left_notice_seek_help, + entity.getAlarmContent()); + countDownV2XEvent(); + } + + /** + * 关闭详情展示框 + */ + @Override + public void close() { + Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=关闭Window"); + V2XServiceManager + .getMogoEntranceButtonController() + .hideLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED); + + // 停止倒计时 + if (handlerV2XEvent != null && runnableV2XEvent != null) { + handlerV2XEvent.removeCallbacks(runnableV2XEvent); + runnableV2XEvent = null; + } + + } + + @Override + public View getView() { + return null; + } + + @Override + public void setWindowStatusListener(V2XWindowStatusListener listener) { + } + + /** + * 窗体倒计时 + */ + public void countDownV2XEvent() { + // 倒计时 + if (runnableV2XEvent == null) { + runnableV2XEvent = () -> { + Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=30秒倒计时结束。。。"); + // 移出Window详细信息 + close(); + }; + } else { + handlerV2XEvent.removeCallbacks(runnableV2XEvent); + } + Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息 Window 展示开始倒计时:" + mExpireTime); + handlerV2XEvent.postDelayed(runnableV2XEvent, mExpireTime); + } + +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java index 0c151faece..bc5fa627bd 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java @@ -220,7 +220,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { * 逆向车辆路线预判 * */ btnTriggerReverseVehicleRoutePrediction.setOnClickListener(v -> { - V2XMessageEntity> v2XMessageEntity = + V2XMessageEntity v2XMessageEntity = TestOnLineCarUtils.getV2XScenarionVRReverseCarData(); Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java index d1dbaf1236..ecfe654b5b 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java @@ -327,7 +327,7 @@ public class TestOnLineCarUtils { /** * 逆向车辆路线预判 */ - public static V2XMessageEntity> getV2XScenarionVRReverseCarData() { + public static V2XMessageEntity getV2XScenarionVRReverseCarData() { try { InputStream inputStream = V2XUtils.getApp() .getResources() @@ -341,14 +341,13 @@ public class TestOnLineCarUtils { inputStream.close(); // 加载数据源 - V2XSpecialCarRes v2xRoadEventEntity = - GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class); + V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class); - V2XMessageEntity> v2xMessageEntity = new V2XMessageEntity<>(); + V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); // 控制类型 - v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING); + v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW); // 设置数据 - v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates()); + v2xMessageEntity.setContent(v2xRoadEventEntity); // 控制展示状态 v2xMessageEntity.setShowState(true); return v2xMessageEntity; diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_barrier_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_barrier_data.json new file mode 100644 index 0000000000..a724bde64f --- /dev/null +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_barrier_data.json @@ -0,0 +1,820 @@ +{ + "sceneId": "200006", + "alarmContent": "及时发现前方障碍物并告知车主,降低事故发生概率", + "expireTime": 30000, + "sceneCategory": 0, + "sceneDescription": "利用用户分享数据以及单车识别能力将障碍物告知其他通过车主,从而降低事故发生概率", + "sceneName": "障碍物绕行", + "sceneLevel": 0, + "sceneChannel": "", + "sceneSn": "", + "tts": "前方发现障碍物注意避让", + "zoom": false, + "zoomScale": 15, + "lat": 40.968678, + "lon": 116.405467, + "userHead": "", + "msgImgUrl": "", + "polyline": [ + [ + 116.737779, + 40.196461 + ], + [ + 116.737689, + 40.196462 + ], + [ + 116.737545, + 40.196464 + ], + [ + 116.737396, + 40.196465 + ], + [ + 116.737215, + 40.196466 + ], + [ + 116.737064, + 40.196467 + ], + [ + 116.736875, + 40.196468 + ], + [ + 116.736744, + 40.196468 + ], + [ + 116.736602, + 40.196469 + ], + [ + 116.736458, + 40.19647 + ], + [ + 116.736304, + 40.196471 + ], + [ + 116.736175, + 40.196472 + ], + [ + 116.736044, + 40.196472 + ], + [ + 116.735883, + 40.196473 + ], + [ + 116.735228, + 40.196477 + ], + [ + 116.735117, + 40.196478 + ], + [ + 116.734994, + 40.196478 + ], + [ + 116.734878, + 40.196479 + ], + [ + 116.734748, + 40.19648 + ], + [ + 116.734636, + 40.196481 + ], + [ + 116.734557, + 40.196481 + ], + [ + 116.734472, + 40.196481 + ], + [ + 116.734392, + 40.196482 + ], + [ + 116.734293, + 40.196482 + ], + [ + 116.734226, + 40.196482 + ], + [ + 116.734138, + 40.196483 + ], + [ + 116.733983, + 40.196484 + ], + [ + 116.733862, + 40.196485 + ], + [ + 116.733725, + 40.196486 + ], + [ + 116.7336, + 40.196486 + ], + [ + 116.733432, + 40.196485 + ], + [ + 116.733331, + 40.196484 + ], + [ + 116.733259, + 40.196482 + ], + [ + 116.733173, + 40.19648 + ], + [ + 116.733106, + 40.196477 + ], + [ + 116.733002, + 40.196471 + ], + [ + 116.732923, + 40.196467 + ], + [ + 116.73282, + 40.196459 + ], + [ + 116.732724, + 40.19645 + ], + [ + 116.73263, + 40.196441 + ], + [ + 116.732529, + 40.19643 + ], + [ + 116.732431, + 40.196419 + ], + [ + 116.732376, + 40.196413 + ], + [ + 116.732295, + 40.196403 + ], + [ + 116.732215, + 40.196391 + ], + [ + 116.732154, + 40.196382 + ], + [ + 116.732076, + 40.196371 + ], + [ + 116.731991, + 40.196356 + ], + [ + 116.731927, + 40.196345 + ], + [ + 116.731847, + 40.19633 + ], + [ + 116.73177, + 40.196316 + ], + [ + 116.731728, + 40.196307 + ], + [ + 116.731664, + 40.196294 + ], + [ + 116.731571, + 40.196274 + ], + [ + 116.731509, + 40.19626 + ], + [ + 116.731435, + 40.196244 + ], + [ + 116.731357, + 40.196224 + ], + [ + 116.7313, + 40.196211 + ], + [ + 116.731226, + 40.196191 + ], + [ + 116.731148, + 40.196171 + ], + [ + 116.731076, + 40.19615 + ], + [ + 116.731016, + 40.196133 + ], + [ + 116.730949, + 40.196113 + ], + [ + 116.730892, + 40.196096 + ], + [ + 116.730827, + 40.196075 + ], + [ + 116.730761, + 40.196053 + ], + [ + 116.730675, + 40.196025 + ], + [ + 116.730616, + 40.196005 + ], + [ + 116.730549, + 40.195981 + ], + [ + 116.730353, + 40.195908 + ], + [ + 116.730214, + 40.195852 + ], + [ + 116.730081, + 40.195798 + ], + [ + 116.729945, + 40.195742 + ], + [ + 116.729836, + 40.195699 + ], + [ + 116.729727, + 40.195659 + ], + [ + 116.729611, + 40.195616 + ], + [ + 116.729486, + 40.195572 + ], + [ + 116.72935, + 40.195529 + ], + [ + 116.729181, + 40.195479 + ], + [ + 116.729013, + 40.195434 + ], + [ + 116.728924, + 40.195412 + ], + [ + 116.72877, + 40.195374 + ], + [ + 116.728622, + 40.195341 + ], + [ + 116.728469, + 40.195308 + ], + [ + 116.728325, + 40.195281 + ], + [ + 116.728174, + 40.195254 + ], + [ + 116.728018, + 40.195229 + ], + [ + 116.727794, + 40.1952 + ], + [ + 116.727599, + 40.195179 + ], + [ + 116.727432, + 40.195165 + ], + [ + 116.727299, + 40.195156 + ], + [ + 116.727073, + 40.195145 + ], + [ + 116.72695, + 40.195142 + ], + [ + 116.726733, + 40.195139 + ], + [ + 116.726488, + 40.19514 + ], + [ + 116.726312, + 40.195141 + ], + [ + 116.726115, + 40.195143 + ], + [ + 116.725869, + 40.195148 + ], + [ + 116.725651, + 40.195155 + ], + [ + 116.72537, + 40.195161 + ], + [ + 116.725188, + 40.195163 + ], + [ + 116.725092, + 40.195162 + ], + [ + 116.725091, + 40.195123 + ], + [ + 116.725335, + 40.195123 + ], + [ + 116.725499, + 40.195123 + ], + [ + 116.72602, + 40.195109 + ], + [ + 116.726235, + 40.195106 + ], + [ + 116.726424, + 40.195105 + ], + [ + 116.726658, + 40.195104 + ], + [ + 116.726733, + 40.195105 + ], + [ + 116.72688, + 40.195106 + ], + [ + 116.72704, + 40.195109 + ], + [ + 116.727217, + 40.195115 + ], + [ + 116.727388, + 40.195124 + ], + [ + 116.727562, + 40.195136 + ], + [ + 116.727735, + 40.195155 + ], + [ + 116.727887, + 40.195174 + ], + [ + 116.727979, + 40.195186 + ], + [ + 116.728056, + 40.195198 + ], + [ + 116.728165, + 40.195216 + ], + [ + 116.728237, + 40.195228 + ], + [ + 116.728345, + 40.195247 + ], + [ + 116.728411, + 40.19526 + ], + [ + 116.728533, + 40.195283 + ], + [ + 116.728589, + 40.195295 + ], + [ + 116.728694, + 40.195318 + ], + [ + 116.728761, + 40.195334 + ], + [ + 116.728868, + 40.19536 + ], + [ + 116.728918, + 40.195372 + ], + [ + 116.729088, + 40.195416 + ], + [ + 116.729262, + 40.195462 + ], + [ + 116.729424, + 40.195512 + ], + [ + 116.729547, + 40.195553 + ], + [ + 116.729584, + 40.195566 + ], + [ + 116.729692, + 40.195606 + ], + [ + 116.729739, + 40.195624 + ], + [ + 116.729844, + 40.195661 + ], + [ + 116.730011, + 40.195726 + ], + [ + 116.73014, + 40.195778 + ], + [ + 116.730309, + 40.195849 + ], + [ + 116.730467, + 40.195911 + ], + [ + 116.730608, + 40.195962 + ], + [ + 116.730673, + 40.195984 + ], + [ + 116.730766, + 40.196015 + ], + [ + 116.730831, + 40.196036 + ], + [ + 116.730935, + 40.196069 + ], + [ + 116.730993, + 40.196087 + ], + [ + 116.731086, + 40.196113 + ], + [ + 116.731164, + 40.196135 + ], + [ + 116.731285, + 40.196165 + ], + [ + 116.731315, + 40.196173 + ], + [ + 116.731434, + 40.196202 + ], + [ + 116.731486, + 40.196214 + ], + [ + 116.731586, + 40.196238 + ], + [ + 116.731652, + 40.196253 + ], + [ + 116.731749, + 40.196273 + ], + [ + 116.731818, + 40.196287 + ], + [ + 116.731924, + 40.196305 + ], + [ + 116.731991, + 40.196317 + ], + [ + 116.732108, + 40.196336 + ], + [ + 116.732269, + 40.196361 + ], + [ + 116.732333, + 40.19637 + ], + [ + 116.732464, + 40.196385 + ], + [ + 116.732507, + 40.19639 + ], + [ + 116.732628, + 40.196404 + ], + [ + 116.732678, + 40.196409 + ], + [ + 116.732784, + 40.196418 + ], + [ + 116.732851, + 40.196424 + ], + [ + 116.732985, + 40.196433 + ], + [ + 116.73314, + 40.196439 + ], + [ + 116.733198, + 40.196441 + ], + [ + 116.733379, + 40.196445 + ], + [ + 116.733548, + 40.196445 + ], + [ + 116.733722, + 40.196445 + ], + [ + 116.733903, + 40.196445 + ], + [ + 116.734081, + 40.196447 + ], + [ + 116.734251, + 40.196446 + ], + [ + 116.734439, + 40.196445 + ], + [ + 116.734624, + 40.196444 + ], + [ + 116.734805, + 40.196442 + ], + [ + 116.734982, + 40.196442 + ], + [ + 116.735164, + 40.196441 + ], + [ + 116.735329, + 40.19644 + ], + [ + 116.735519, + 40.196438 + ], + [ + 116.735682, + 40.196437 + ], + [ + 116.735855, + 40.196437 + ], + [ + 116.736034, + 40.196436 + ], + [ + 116.73621, + 40.196435 + ], + [ + 116.736385, + 40.196433 + ], + [ + 116.736566, + 40.196433 + ], + [ + 116.736742, + 40.196431 + ], + [ + 116.736926, + 40.196431 + ], + [ + 116.737046, + 40.19643 + ], + [ + 116.737173, + 40.19643 + ], + [ + 116.737298, + 40.196429 + ], + [ + 116.737449, + 40.196427 + ], + [ + 116.737582, + 40.196427 + ], + [ + 116.737662, + 40.196425 + ], + [ + 116.737748, + 40.196425 + ], + [ + 116.73778, + 40.196424 + ] + ] +} \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_xingren_yujing_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_xingren_yujing_data.json index 5e06b0a449..6fd53b8765 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_xingren_yujing_data.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_xingren_yujing_data.json @@ -1,5 +1,5 @@ { - "sceneId": "200006", + "sceneId": "200007", "alarmContent": "展现行人预测、提前预警能力", "expireTime": 30000, "sceneCategory": 0, diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java index d1e55e8f06..4d04c13d37 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/entrance/IMogoEntranceButtonController.java @@ -57,6 +57,11 @@ public interface IMogoEntranceButtonController extends IProvider { */ int NOTICE_TYPE_OBSTACLE_CAR_WARN = 1010; + /** + * 拥堵路线推荐 + */ + int NOTICE_TYPE_CONGESTION_RECOMMENDED = 1011; + /** * 获取入口按钮实例 *