diff --git a/libraries/map-custom/build.gradle b/libraries/map-custom/build.gradle index b08b482942..986849f098 100644 --- a/libraries/map-custom/build.gradle +++ b/libraries/map-custom/build.gradle @@ -67,7 +67,7 @@ dependencies { implementation project(':foudations:mogo-commons') } - implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.1.3' + implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.1.5' } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapMarkerClickHandler.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapMarkerClickHandler.java index 0b89685535..f2775c4894 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapMarkerClickHandler.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapMarkerClickHandler.java @@ -19,6 +19,30 @@ import java.util.Map; */ public class AMapMarkerClickHandler { + private static volatile AMapMarkerClickHandler sInstance; + + private AMapMarkerClickHandler(){} + + public static AMapMarkerClickHandler getInstance(){ + if( sInstance == null ){ + synchronized( AMapMarkerClickHandler.class ) { + if( sInstance == null ){ + sInstance = new AMapMarkerClickHandler(); + } + } + } + return sInstance; + } + + public synchronized void release(){ + sInstance = null; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + public boolean handleMarkerClicked( Marker marker ) { if ( marker == null ) { return false; diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index bc680db52f..5a903d4115 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -162,7 +162,7 @@ public class AMapViewWrapper implements IMogoMapView, private void initListeners() { mMapView.setOnMarkClickListener( this ); - mMarkerClickHandler = new AMapMarkerClickHandler(); + mMarkerClickHandler = AMapMarkerClickHandler.getInstance(); mMapView.setOnMapLoadedListener( this ); mMapView.setOnMapTouchListener( this ); mMapView.setOnMapClickListener( this ); @@ -251,7 +251,7 @@ public class AMapViewWrapper implements IMogoMapView, @Override public void setTrafficEnabled( boolean visible ) { if ( checkAMapView() ) { - mMapView.getMapAutoViewHelper().setTraffic( visible ); +// mMapView.getMapAutoViewHelper().setTraffic( visible ); } } diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/marker/AMapInfoWindowAdapter.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/marker/AMapInfoWindowAdapter.java index 1e06b9ddbb..78150eabb5 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/marker/AMapInfoWindowAdapter.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/marker/AMapInfoWindowAdapter.java @@ -2,32 +2,44 @@ package com.mogo.map.impl.custom.marker; import android.view.View; +import com.mogo.map.impl.custom.AMapMarkerClickHandler; import com.mogo.map.marker.IMogoInfoWindowAdapter; import com.mogo.map.marker.IMogoMarker; import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter; import com.zhidaoauto.map.sdk.open.marker.Marker; +import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.FileInputStream; + /** * @author congtaowang * @since 2019-12-24 *

* 自定义infowindow */ -public final class AMapInfoWindowAdapter implements InfoWindowAdapter { +public final class AMapInfoWindowAdapter implements InfoWindowAdapter, OnInfoWindowClickListener { public View getInfoWindow( Marker marker ) { if ( marker.getMObject() instanceof IMogoMarker ) { IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getMObject() ); IMogoInfoWindowAdapter delegate = mogoMarker.getInfoWindowAdapter(); if ( delegate != null ) { - return delegate.getInfoWindow( mogoMarker ); + final View infoView = delegate.getInfoWindow( mogoMarker ); + marker.setOnInfoWindowClickListener( this ); + return infoView; } } return null; } + @Override + public void onInfoWindowClick( @NotNull Marker marker ) { + AMapMarkerClickHandler.getInstance().handleMarkerClicked( marker ); + } + @Nullable @Override public View getInfoContents(@Nullable Marker marker) { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java new file mode 100644 index 0000000000..f543e4b242 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/TrafficLightConst.java @@ -0,0 +1,18 @@ +package com.mogo.module.common.constants; + +/** + * 用于内部标识红绿灯颜色 + * + * @author tongchenfei + */ +public class TrafficLightConst { + public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0; + public static final int TRAFFIC_LIGHT_COLOR_RED = 1; + public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2; + public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3; + + public static final int TRAFFIC_LIGHT_DIRECTION_TURN_AROUND = 0; + public static final int TRAFFIC_LIGHT_DIRECTION_TURN_LEFT = 1; + public static final int TRAFFIC_LIGHT_DIRECTION_STRAIGHT = 2; + public static final int TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT = 3; +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java index 8fea64910c..0f687f677f 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java @@ -60,10 +60,14 @@ class MarkerDrawer { } public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) { + return drawMapMarkerImpl(markerShowEntity, zIndex, 0, listener); + } + + public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, int icon3DRes, 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() ); + MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).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 { 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 index 5829eee710..621692464e 100644 --- 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 @@ -8,6 +8,7 @@ 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.R; import com.mogo.module.common.entity.MarkerCarPois; import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerOnlineCar; @@ -104,7 +105,7 @@ class OnlineCarDrawer { 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 ); + mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener ); } if ( mogoMarker != null ) { mogoMarker.setVisible( true ); 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 index 8fa79aaf08..fde64b7020 100644 --- 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 @@ -9,6 +9,7 @@ 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.drawer.marker.RoadConditionInfoWindow3DAdapter; import com.mogo.module.common.entity.MarkerExploreWay; import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerShowEntity; @@ -84,10 +85,16 @@ class RoadConditionDrawer { if ( mogoMarker == null || mogoMarker.isDestroyed() ) { Logger.d( TAG, "draw road condition, sn = %s", sn ); try { - if ( DebugConfig.isRoadEventAnimated() ) { - post2AddAndStartAnimation( markerShowEntity, i * 100L, listener ); - } else { + if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener ); + mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) ); + mogoMarker.showInfoWindow(); + } else { + 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(); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/EmptyMarkerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/EmptyMarkerView.java new file mode 100644 index 0000000000..be4771ae5a --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/EmptyMarkerView.java @@ -0,0 +1,46 @@ +package com.mogo.module.common.drawer.marker; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; + +import androidx.annotation.Nullable; + +import com.mogo.map.marker.IMogoMarker; + +public +/** + * @author congtaowang + * @since 2020/12/16 + * + * 描述 + */ +class EmptyMarkerView extends View implements IMarkerView { + + public EmptyMarkerView( Context context ) { + this( context, null ); + } + + public EmptyMarkerView( Context context, @Nullable AttributeSet attrs ) { + this( context, attrs, 0 ); + } + + public EmptyMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) { + super( context, attrs, defStyleAttr ); + } + + @Override + public View getView() { + return this; + } + + @Override + public void setMarker( IMogoMarker marker ) { + + } + + @Override + protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) { + setMeasuredDimension( 1, 1 ); + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java index 94d682ca4a..8a130a1f59 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerAdapter.java @@ -5,6 +5,7 @@ import android.text.TextUtils; import com.mogo.map.marker.MogoMarkerOptions; import com.mogo.module.common.ModuleNames; +import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.entity.MarkerShowEntity; /** @@ -23,17 +24,36 @@ public class MapMarkerAdapter { * @param markerShowEntity 要填充的数据 * @return MarkerView */ - public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) { + public static IMarkerView getMarkerView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) { if ( TextUtils.equals( markerShowEntity.getMarkerType(), ModuleNames.CARD_TYPE_USER_DATA ) ) { return OnlineCarMarkerView.getInstance(); } else { - if (markerShowEntity.isChecked()) { - return new MapMarkerInfoView(context, markerShowEntity, options); + if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { + return new EmptyMarkerView( context ); } else { - return new MapMarkerView(context, markerShowEntity, options); + if ( markerShowEntity.isChecked() ) { + return new MapMarkerInfoView( context, markerShowEntity, options ); + } else { + return new MapMarkerView( context, markerShowEntity, options ); + } } } } + + /** + * 获取 MarkerShowEntity 填充好的 MarkerView + * + * @param context 上下文 + * @param markerShowEntity 要填充的数据 + * @return MarkerView + */ + public static IMarkerView getMarkerInfoWindowView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) { + if ( markerShowEntity.isChecked() ) { + return new MapMarkerInfoView( context, markerShowEntity, options ); + } else { + return new MapMarkerView( context, markerShowEntity, options ); + } + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java index 404ded1d88..9ded911563 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java @@ -13,6 +13,7 @@ import androidx.constraintlayout.widget.ConstraintLayout; import com.mogo.map.marker.MogoMarkerOptions; 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.MarkerShareMusic; import com.mogo.module.common.entity.MarkerShowEntity; @@ -71,7 +72,11 @@ public class MapMarkerInfoView extends MapMarkerBaseView { Object bindObj = markerShowEntity.getBindObj(); - ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow ); + if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { + ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr ); + } else { + ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow ); + } clMarkerContent.setBackgroundResource( R.drawable.bg_map_marker_yellow_info ); ivReverseTriangle.setImageResource( R.drawable.bg_shape_reverse_yellow ); switch ( markerShowEntity.getMarkerType() ) { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/RoadConditionInfoWindow3DAdapter.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/RoadConditionInfoWindow3DAdapter.java new file mode 100644 index 0000000000..063be888e7 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/RoadConditionInfoWindow3DAdapter.java @@ -0,0 +1,37 @@ +package com.mogo.module.common.drawer.marker; + +import android.content.Context; +import android.view.View; + +import com.mogo.map.marker.IMogoInfoWindowAdapter; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.module.common.entity.MarkerShowEntity; + +public +/** + * @author congtaowang + * @since 2020/12/15 + * + * 描述 + */ +class RoadConditionInfoWindow3DAdapter implements IMogoInfoWindowAdapter { + + private MarkerShowEntity mEntity; + private Context mContext; + private MogoMarkerOptions mOptions; + + public RoadConditionInfoWindow3DAdapter( MarkerShowEntity entity, + Context context, + MogoMarkerOptions options ) { + this.mEntity = entity; + this.mContext = context; + this.mOptions = options; + } + + @Override + public View getInfoWindow( IMogoMarker marker ) { + IMarkerView creator = MapMarkerAdapter.getMarkerInfoWindowView( mContext, mEntity, mOptions ); + return creator.getView(); + } +} diff --git a/modules/mogo-module-common/src/main/res/raw/taxi.n3d b/modules/mogo-module-common/src/main/res/raw/taxi.n3d new file mode 100644 index 0000000000..8352a248bc Binary files /dev/null and b/modules/mogo-module-common/src/main/res/raw/taxi.n3d differ diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java index f736c8b38d..43b17f467a 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/navi/VrModeNavInfoView.java @@ -88,6 +88,9 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb } } + private int[] lightArray = new int[4]; + private String[] surplusTimeArray = new String[4]; + /** * 刷新红绿灯显示状态 * @@ -95,10 +98,22 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb * @param surplusTime 固定数组长度为4的剩余时长数组,从0-3依次代表 掉头,左转,执行,右转 */ public void refreshTrafficLightStatus(int[] laneLight, String[] surplusTime) { + lightArray = laneLight; + surplusTimeArray = surplusTime; + turnAroundLight.setTrafficLightStatus(laneLight[0], surplusTime[0]); turnLeftLight.setTrafficLightStatus(laneLight[1], surplusTime[1]); straightLight.setTrafficLightStatus(laneLight[2], surplusTime[2]); turnRightLight.setTrafficLightStatus(laneLight[3], surplusTime[3]); + // todo 再根据当前所在车道,置灰不需关注的灯 + + } + + /** + * 根据所在车道,控制红绿灯展示 + */ + public void refreshLaneStatus(){ + } @Override diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java index 0eb32beb06..b27e21bfd1 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/AdasNoticeHelper.java @@ -21,6 +21,7 @@ import com.mogo.service.connection.IMogoOnWebSocketMessageListener; import com.mogo.service.connection.WebSocketMsgType; import com.mogo.utils.logger.Logger; +import org.json.JSONArray; import org.json.JSONObject; /** @@ -33,9 +34,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca private static final String TAG = "AdasNoticeHelper"; private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001; - private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002; +// private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002; 先去掉云端下发红绿灯信息 private static final int MSG_HIDE_LIMIT_SPEED = 1003; - private static final int MSG_REFRESH_CAR_STRATEGY = 1004; +// private static final int MSG_REFRESH_CAR_STRATEGY = 1004; private static final long HIDE_TRAFFIC_LIGHT_DELAY = 2_000L; private static final long HIDE_LIMIT_SPEED_DELAY = 10_000L; @@ -53,23 +54,14 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca private VrModeNavInfoView vrModeNavInfoView; - private Handler handler = new Handler(this); - - private boolean isObuLightData = false; - - - private boolean lightCenter = true; + private final Handler handler = new Handler(this); public void init(Context context) { this.context = context; - if (!lightCenter) { - } Logger.d(TAG, "init===="); } public void initView(VrModeNavInfoView vrModeNavInfoView) { - if (lightCenter) { - } this.vrModeNavInfoView = vrModeNavInfoView; } @@ -84,10 +76,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca context.registerReceiver(adasReceiver, filter); MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this); MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this); - MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this); - if (!lightCenter) { - handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY); - } + // 先不监听服务端下发消息 +// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this); + } } @@ -96,11 +87,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca if (isVrMode) { isVrMode = false; MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS(); - handler.removeMessages(MSG_REFRESH_CAR_STRATEGY); MogoApisHandler.getInstance().getApis().getAdasControllerApi().removeAdasWarnMessageCallback(this); MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG); - MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this); - +// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this); context.unregisterReceiver(adasReceiver); } } @@ -129,44 +118,15 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca return; } currentSpeed = (int) (location.getSpeed() * 3.6F); - if (lightCenter) { - } } @Override public boolean handleMessage(Message msg) { switch (msg.what) { - case MSG_REFRESH_CAR_STRATEGY: - // todo 暂时不采用此种渲染方式 - // 自车速度 - // todo 设置字体颜色、背景颜色、leftDrawable - switch (lightStatus) { - case "Y": - // 黄灯 - break; - case "R": - // 红灯 - break; - default: - // 默认绿灯 - break; - } - - if (isVrMode) { - handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY); - } - return true; case MSG_HIDE_LIMIT_SPEED: limitSpeed = -1; return true; - case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD: - if (!isObuLightData && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) { - } - return true; case MSG_HIDE_TRAFFIC_LIGHT_BY_OBU: - isObuLightData = false; - if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD)) { - } return true; default: return false; @@ -209,7 +169,17 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca String lightStatus = jsonObject.optString("lightStatus"); String surplusTime = jsonObject.optString("surplusTime"); if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) { - handleObuTrafficLightInfo(lightStatus, surplusTime); +// String strArray = jsonObject.getString("lightArray"); +// Logger.d(TAG, "strArray: " + strArray); + JSONArray lightJsonArray = jsonObject.getJSONArray("lightArray"); + JSONArray timeJsonArray = jsonObject.getJSONArray("surplusTimeArray"); + int[] lightArray = new int[4]; + String[] surplusTimeArray = new String[4]; + for (int i = 0; i < 4; i++) { + lightArray[i] = lightJsonArray.getInt(i); + surplusTimeArray[i] = timeJsonArray.getString(i); + } + handleObuTrafficLightInfo(lightArray, surplusTimeArray); } else { Logger.d(TAG, "红绿灯必要信息都为空,不做展示"); } @@ -224,22 +194,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca } } - private void handleObuTrafficLightInfo(String lightStatus, String surplusTime) { - isObuLightData = true; - } - - private void handleCloudTrafficLight(CloudRoadData roadData) { - if (isObuLightData) { - handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD); - return; - } - } - - private void drawTrafficLight(String lightStatus, String surplusTime) { - this.lightStatus = lightStatus; - this.surplusTime = surplusTime; - if (lightCenter) { - } + private void handleObuTrafficLightInfo(int[] lightArray,String[] surplusTimeArray) { + vrModeNavInfoView.refreshTrafficLightStatus(lightArray, surplusTimeArray); } @Override @@ -254,14 +210,6 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca @Override public void onMsgReceived(MogoSnapshotSetData obj) { - Logger.d(TAG, "收到大而全数据: " + obj); - CloudRoadData roadData = obj.getTrafficLight(); - if (roadData != null) { - Logger.d(TAG, "收到红绿灯数据"); - handleCloudTrafficLight(roadData); - } else { - handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD); - } - } + } } diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java index e16882fbcb..aa20aae227 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/view/VerticalTrafficLightView.java @@ -13,12 +13,18 @@ import androidx.annotation.IntDef; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.Group; +import com.mogo.module.common.constants.TrafficLightConst; import com.mogo.module.extensions.R; import com.mogo.utils.logger.Logger; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GRAY; +import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GREEN; +import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_RED; +import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_YELLOW; + /** * vr模式下的纵向显示的红绿灯封装 * @@ -26,10 +32,6 @@ import java.lang.annotation.RetentionPolicy; */ public class VerticalTrafficLightView extends ConstraintLayout { private static final String TAG = "VerticalTrafficLightView"; - public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0; - public static final int TRAFFIC_LIGHT_COLOR_RED = 1; - public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2; - public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3; private ImageView ivTrafficLight, ivNoLeftTime; private TextView tvLeftTime, tvLeftTimeUnit; @@ -90,7 +92,7 @@ public class VerticalTrafficLightView extends ConstraintLayout { /** * 设置红绿灯的颜色,根据颜色来展示不同的效果 * - * @param color 红绿灯颜色{@link #TRAFFIC_LIGHT_COLOR_GRAY},{@link #TRAFFIC_LIGHT_COLOR_RED}等四个颜色 + * @param color 红绿灯颜色{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_GRAY},{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个颜色 */ private void setTrafficLightColor(@TrafficLightColor int color) { if (iconRes == null) { @@ -123,7 +125,7 @@ public class VerticalTrafficLightView extends ConstraintLayout { /** * 设置红绿灯状态,需设置颜色及时长 * - * @param color 红绿灯颜色,使用{@link #TRAFFIC_LIGHT_COLOR_RED}等四个值 + * @param color 红绿灯颜色,使用{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个值 * @param leftTime 剩余时长,null或者empty表示没有时长数据 */ public void setTrafficLightStatus(@TrafficLightColor int color, String leftTime) { diff --git a/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml index e6efac5899..1a2d4c4241 100644 --- a/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml +++ b/modules/mogo-module-extensions/src/main/res/layout/include_navi_in_vr.xml @@ -39,7 +39,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="@dimen/module_ext_navi_in_vr_speed_margin_start" - android:text="78" + android:text="--" android:textColor="#fff" android:textSize="@dimen/module_ext_navi_in_vr_speed_text_size" app:layout_constraintBottom_toTopOf="@id/module_ext_id_navi_in_vr_traffic_bg" diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt index 68e61eb3c7..b67be3a6fe 100644 --- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt +++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/MockUtil.kt @@ -45,7 +45,7 @@ class MockUtil:Handler.Callback { if (msg.what == 1001) { Logger.d(TAG,"准备添加调试view") val api = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis - api.windowManagerApi.addView(view, 1000, 600, false) + api.windowManagerApi.addView(view, 500, 300, false) } return false } diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt index 33437fedd1..0930bbedc2 100644 --- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt +++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuTrafficLightInfo.kt @@ -1,5 +1,6 @@ package com.zhidao.mogo.module.obu.obu.bean +import com.mogo.module.common.constants.TrafficLightConst.* import com.zhidao.smartv2x.model.obu.TrafficLightInfo /** @@ -10,20 +11,72 @@ import com.zhidao.smartv2x.model.obu.TrafficLightInfo * * @author tongchenfei */ -class MogoObuTrafficLightInfo(){ - var id:String? =null - var lightStatus:String? =null - var surplusTime:String? =null - var lightPriority:String? =null - override fun toString(): String { - return "MogoObuTrafficLightInfo(id=$id, lightStatus=$lightStatus, surplusTime=$surplusTime, lightPriority=$lightPriority)" - } +class MogoObuTrafficLightInfo() { + var id: String? = null + var lightStatus: String? = null + set(value) { + field = value + resetLightArray(value) + } + var surplusTime: String? = null + set(value) { + field = value + resetSurplusTimeArray(value) + } + var lightPriority: String? = null - constructor(info:TrafficLightInfo):this(){ + var lightArray: IntArray = IntArray(4) { 0 } + var surplusTimeArray: Array = Array(4) { "" } + + constructor(info: TrafficLightInfo) : this() { this.id = info.id this.lightStatus = info.lightStatus this.surplusTime = info.surplusTime this.lightPriority = info.lightPriority + + resetLightArray(lightStatus) + resetSurplusTimeArray(surplusTime) + } + + override fun toString(): String { + return "MogoObuTrafficLightInfo(id=$id, lightStatus=$lightStatus, surplusTime=$surplusTime, lightPriority=$lightPriority, lightArray=${lightArray.contentToString()}, surplusTimeArray=${surplusTimeArray.contentToString()})" + } + + private fun resetLightArray(lightStatus: String?) { + when (lightStatus) { + "R" -> { + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_RED + lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_RED + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN + + } + "Y" -> { + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_YELLOW + lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_YELLOW + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN + } + "G" -> { + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GREEN + lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GREEN + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN + } + else -> { + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GRAY + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GRAY + lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GRAY + lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GRAY + } + } + } + + private fun resetSurplusTimeArray(surplusTime: String?) { + surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = "" + surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = surplusTime ?: "" + surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = surplusTime ?: "" + surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = "" } } \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index 03a9399a1b..6fc36fbb25 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -941,9 +941,11 @@ public class MogoServices implements IMogoMapListener, if ( ui == EnumMapUI.Type_VR ) { MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, true ); MapCenterPointStrategy.resetByChangeMode(); + MapMarkerManager.getInstance().redrawMarkerByStyleChanged(); } else { MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, false ); MapCenterPointStrategy.resetByChangeMode(); + MapMarkerManager.getInstance().redrawMarkerByStyleChanged(); } } } 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 2b7d073ed3..2abcaf7a2f 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 @@ -262,7 +262,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object; markerShowEntity.setChecked( true ); IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() ); - markerView.setMarker(mogoMarker); + markerView.setMarker( mogoMarker ); if ( markerView instanceof OnlineCarMarkerView ) { try { mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) ); @@ -270,7 +270,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener, mogoMarker.setIcon( markerView.getBitmap( 0 ) ); } } else { - mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) ); + if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) { + mogoMarker.hideInfoWindow(); + mogoMarker.showInfoWindow(); + } else { + mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) ); + } } mogoMarker.setToTop(); } @@ -309,7 +314,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object; markerShowEntity.setChecked( false ); IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() ); - markerView.setMarker(mogoMarker); + markerView.setMarker( mogoMarker ); if ( markerView instanceof OnlineCarMarkerView ) { try { mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) ); @@ -317,7 +322,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener, mogoMarker.setIcon( markerView.getBitmap( 0 ) ); } } else { - mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) ); + if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) { + mogoMarker.hideInfoWindow(); + mogoMarker.showInfoWindow(); + } else { + mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) ); + } } } } @@ -693,19 +703,23 @@ public class MapMarkerManager implements IMogoMarkerClickListener, // if ( !AppUtils.isAppForeground( mContext ) ) { // return; // } - if ( mLastDataResult != null ) { - runOnTargetThread( () -> { - MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION ); - drawMarkerByCurrentType( mLastDataResult ); - mLastCheckMarker = null; - } ); - } + redrawMarkerByStyleChanged(); break; } } - public void onCloseCurrentSelectedMarker(){ - if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) { + public void redrawMarkerByStyleChanged() { + if ( mLastDataResult != null ) { + runOnTargetThread( () -> { + MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION ); + drawMarkerByCurrentType( mLastDataResult ); + mLastCheckMarker = null; + } ); + } + } + + public void onCloseCurrentSelectedMarker() { + if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed() ) { closeMarker( mLastCheckMarker ); mLastCheckMarker = null; } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java index fb4766fe4f..72141cfbdf 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java @@ -30,6 +30,7 @@ import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo; import com.zhidao.mogo.module.obu.obu.bean.MogoObuLocationInfo; import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo; +import org.json.JSONArray; import org.json.JSONObject; import java.util.Map; @@ -142,6 +143,10 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { } else { json.put("surplusTime", trafficLightInfo.getSurplusTime()); } + JSONArray lightJsonArray = new JSONArray(trafficLightInfo.getLightArray()); + JSONArray surplusTimeJsonArray = new JSONArray(trafficLightInfo.getSurplusTimeArray()); + json.put("lightArray", lightJsonArray); + json.put("surplusTimeArray", surplusTimeJsonArray); } String data = json.toString(); Logger.d(MODULE_NAME, "发送红绿灯广播: " + data);