diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 6560a98983..986b1962d3 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -32,5 +32,6 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java
index 2266035c7a..19b8567590 100644
--- a/app/src/main/java/com/mogo/launcher/MogoApplication.java
+++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java
@@ -105,6 +105,8 @@ public class MogoApplication extends AbsMogoApplication {
// 小地图模块
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SMALL_MAP, "IMogoSmallMapProvider" ) );
+ //前方碰撞预警
+ MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_V2X_FRONT_CRASH_WARNING, "IV2XManagerProvider" ) );
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_GLOBAL_UNWAKE, "GlobalUnwake" ) );
diff --git a/main-extensions/mogo-module-main-launcher/build.gradle b/main-extensions/mogo-module-main-launcher/build.gradle
index 3de4bf61cd..efd300157a 100644
--- a/main-extensions/mogo-module-main-launcher/build.gradle
+++ b/main-extensions/mogo-module-main-launcher/build.gradle
@@ -43,9 +43,11 @@ dependencies {
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.modulemain
implementation rootProject.ext.dependencies.mogooch
+ implementation rootProject.ext.dependencies.moduleservice
} else {
api project(":modules:mogo-module-main")
implementation project(":OCH:mogo-och")
+ implementation project(':modules:mogo-module-service')
}
}
diff --git a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
index 9cccae807c..bbe709f901 100644
--- a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
+++ b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java
@@ -2,10 +2,13 @@ package com.zhidao.mogo.module.main.launcher;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import android.os.Process;
import android.text.TextUtils;
+import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import androidx.annotation.Nullable;
@@ -13,26 +16,42 @@ import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.main.MainActivity;
import com.mogo.module.main.cards.MogoModulesManager;
+import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.och.IMogoOCH;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
+import com.mogo.service.v2x.IV2XListener;
import com.mogo.utils.logger.Logger;
+import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM;
+import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT;
+import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT;
+import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
+
/**
* 针对作为Launcher的情况,做个性化操作
*
* @author tongchenfei
*/
-public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener {
+public class MainLauncherActivity extends MainActivity implements IMogoIntentListener, IMogoStatusChangedListener, IV2XListener {
private static final String TAG = "MainLauncherActivity";
protected boolean mIsHomeKeyDown = false;
+ private static Handler handlerV2XEvent = new Handler();
+ private static Runnable runnableV2XEvent;
+ private static final int COUNT_DOWN_TIMER = 1_000;
+ private static final int ALL_EXPIRE_TIMER = 3_000;
+ private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
+
@Override
- protected void onCreate( @Nullable Bundle savedInstanceState ) {
- super.onCreate( savedInstanceState );
- DebugConfig.setNeedRequestUserInfo( true );
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ DebugConfig.setNeedRequestUserInfo(true);
+ Log.d(TAG, "onCreate");
+ mServiceApis.getV2XListenerManager().registerIntentListener(MogoReceiver.ACTION_V2X_FRONT_WARNING, this);
mServiceApis.getStatusManagerApi().registerStatusChangedListener(TAG,
StatusDescriptor.VR_MODE, this);
}
@@ -43,10 +62,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
// 显示左边遮罩
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
mLeftShadowFrame.setVisibility(View.GONE);
- }else {
+ } else {
mLeftShadowFrame.setVisibility(View.VISIBLE);
}
- MogoModulesManager.getInstance().loadAppsListModule( com.mogo.module.main.R.id.module_main_id_apps_fragment_container );
+ MogoModulesManager.getInstance().loadAppsListModule(com.mogo.module.main.R.id.module_main_id_apps_fragment_container);
}
@Override
@@ -57,21 +76,21 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
@Override
protected void hideLayout() {
super.hideLayout();
- mApps.setVisibility( View.GONE );
- mLeftShadowFrame.setVisibility( View.GONE );
+ mApps.setVisibility(View.GONE);
+ mLeftShadowFrame.setVisibility(View.GONE);
}
@Override
protected void showLayout() {
super.showLayout();
- mApps.setVisibility( View.VISIBLE );
- mLeftShadowFrame.setVisibility( View.VISIBLE );
+ mApps.setVisibility(View.VISIBLE);
+ mLeftShadowFrame.setVisibility(View.VISIBLE);
}
@Override
protected void onStart() {
super.onStart();
- getApis().getIntentManagerApi().registerIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
+ getApis().getIntentManagerApi().registerIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
}
@Override
@@ -83,13 +102,13 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
@Override
protected void onStop() {
super.onStop();
- getApis().getIntentManagerApi().unregisterIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
+ getApis().getIntentManagerApi().unregisterIntentListener(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this);
}
@Override
- public void onIntentReceived( String intentStr, Intent intent ) {
- if ( TextUtils.equals( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr ) ) {
- mIsHomeKeyDown = intent.getBooleanExtra( "isHomeKeyDown", true );
+ public void onIntentReceived(String intentStr, Intent intent) {
+ if (TextUtils.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr)) {
+ mIsHomeKeyDown = intent.getBooleanExtra("isHomeKeyDown", true);
}
}
@@ -107,10 +126,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
/**
* 加载网约车模块
*/
- private void loadOCHModule(){
- IMogoOCH och = ARouter.getInstance().navigation( IMogoOCH.class );
- if ( och != null ) {
- och.init( this, R.id.module_main_id_och_fragment );
+ private void loadOCHModule() {
+ IMogoOCH och = ARouter.getInstance().navigation(IMogoOCH.class);
+ if (och != null) {
+ och.init(this, R.id.module_main_id_och_fragment);
}
}
@@ -119,40 +138,108 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
super.onDestroy();
mServiceApis.getStatusManagerApi().unregisterStatusChangedListener(TAG,
StatusDescriptor.VR_MODE, this);
+ mServiceApis.getV2XListenerManager().unregisterIntentListener(TAG, this);
+ stopCountDown();
try {
// acc off 之后会出现进程还在,但是页面被杀的情况,这个直接杀掉进程,然后让整个进程重启
- Process.killProcess( Process.myPid() );
- } catch ( Exception e ) {
+ Process.killProcess(Process.myPid());
+ } catch (Exception e) {
e.printStackTrace();
}
}
@Override
- public void onMapUiModeChanged( EnumMapUI mapUI ) {
- super.onMapUiModeChanged( mapUI );
- Intent intent = new Intent( "com.mogo.style.SKIN_CHANGED" );
- intent.putExtra( "type", -1 );
- if ( mapUI == EnumMapUI.Type_Light ) {
- intent.putExtra( "type", 1 );
- } else if( mapUI == EnumMapUI.Type_Night ){
- intent.putExtra( "type", 0 );
+ public void onMapUiModeChanged(EnumMapUI mapUI) {
+ super.onMapUiModeChanged(mapUI);
+ Intent intent = new Intent("com.mogo.style.SKIN_CHANGED");
+ intent.putExtra("type", -1);
+ if (mapUI == EnumMapUI.Type_Light) {
+ intent.putExtra("type", 1);
+ } else if (mapUI == EnumMapUI.Type_Night) {
+ intent.putExtra("type", 0);
}
- sendBroadcast( intent );
- Logger.d( TAG, "send msg to AI Voice" );
+ sendBroadcast(intent);
+ Logger.d(TAG, "send msg to AI Voice");
}
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
- FrameLayout.LayoutParams entranceParams = ( ( FrameLayout.LayoutParams ) mEntrance.getLayoutParams() );
+ FrameLayout.LayoutParams entranceParams = ((FrameLayout.LayoutParams) mEntrance.getLayoutParams());
if (isTrue) {
- entranceParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_entrance_fragment_container_marginLeft_in_vr_mode );
+ entranceParams.leftMargin = getResources().getDimensionPixelSize(R.dimen.module_main_entrance_fragment_container_marginLeft_in_vr_mode);
mLeftShadowFrame.setVisibility(View.GONE);
mApps.setVisibility(View.GONE);
- }else{
- entranceParams.leftMargin = getResources().getDimensionPixelSize( R.dimen.module_main_id_entrance_fragment_container_marginLeft );
+ } else {
+ entranceParams.leftMargin = getResources().getDimensionPixelSize(R.dimen.module_main_id_entrance_fragment_container_marginLeft);
mLeftShadowFrame.setVisibility(View.VISIBLE);
mApps.setVisibility(View.VISIBLE);
}
- mEntrance.setLayoutParams( entranceParams );
+ mEntrance.setLayoutParams(entranceParams);
+ }
+
+ @Override
+ public void warningChangedWithType(int type) {
+ Log.d(TAG, "显示红色预警蒙层");
+ switch (type) {
+ case ALERT_THE_FRONT_CRASH_WARNING_TOP:
+ mWarningTop.setVisibility(View.VISIBLE);
+ mWarningLeft.setVisibility(View.GONE);
+ mWarningRight.setVisibility(View.GONE);
+ mWarningBottom.setVisibility(View.GONE);
+ startCountDownWithView(mWarningTop);
+ break;
+ case ALERT_THE_FRONT_CRASH_WARNING_LEFT:
+ mWarningLeft.setVisibility(View.VISIBLE);
+ mWarningTop.setVisibility(View.GONE);
+ mWarningRight.setVisibility(View.GONE);
+ mWarningBottom.setVisibility(View.GONE);
+ startCountDownWithView(mWarningLeft);
+ break;
+ case ALERT_THE_FRONT_CRASH_WARNING_RIGHT:
+ mWarningRight.setVisibility(View.VISIBLE);
+ mWarningTop.setVisibility(View.GONE);
+ mWarningLeft.setVisibility(View.GONE);
+ mWarningBottom.setVisibility(View.GONE);
+ startCountDownWithView(mWarningRight);
+ break;
+ case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM:
+ mWarningBottom.setVisibility(View.VISIBLE);
+ mWarningRight.setVisibility(View.GONE);
+ mWarningTop.setVisibility(View.GONE);
+ mWarningLeft.setVisibility(View.GONE);
+ startCountDownWithView(mWarningBottom);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * 预警蒙层显示时间为3秒
+ * */
+ private void startCountDownWithView(ImageView view) {
+ if (runnableV2XEvent == null) {
+ runnableV2XEvent = () -> {
+ EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
+ Logger.d(TAG, "当前蒙层显示时间为 :" + EXPIRE_TIMER / COUNT_DOWN_TIMER + " 秒");
+ if (EXPIRE_TIMER > 0) {
+ handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
+ } else {
+ view.setVisibility(View.GONE);
+ stopCountDown();
+ }
+ };
+ } else {
+ handlerV2XEvent.removeCallbacks(runnableV2XEvent);
+ }
+ handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
+ }
+
+ private void stopCountDown() {
+ if (handlerV2XEvent != null && runnableV2XEvent != null) {
+ handlerV2XEvent.removeCallbacks(runnableV2XEvent);
+ runnableV2XEvent = null;
+ EXPIRE_TIMER = ALL_EXPIRE_TIMER;
+ }
}
}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
index fce034aab3..336e7d5a27 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java
@@ -145,6 +145,14 @@ public class V2XMessageEntity implements Serializable {
int ALERT_RECOMMEND_ROUTE = 1_011;
// 基于预判目的地违章高发停车场推荐
int ALERT_RECOMMEND_PARKING = 1_012;
+ // 前方碰撞预警
+ int ALERT_THE_FRONT_CRASH_WARNING_TOP = 1_0013;
+ // 左前方碰撞预警
+ int ALERT_THE_FRONT_CRASH_WARNING_LEFT = 1_0014;
+ // 右前方碰撞预警
+ int ALERT_THE_FRONT_CRASH_WARNING_RIGHT = 1_0015;
+ // 后方碰撞预警
+ int ALERT_THE_FRONT_CRASH_WARNING_BOTTOM = 1_0016;
// 推送VR消息展示
int ALERT_PUSH_VR_SHOW = 2_000;
// 自车求助
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
index 1fc72806d6..d80612b0dc 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -29,6 +30,7 @@ import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.statusmanager.IMogoStatusManager;
+import com.mogo.service.v2x.IV2XListener;
import com.mogo.skin.support.SkinMode;
import com.mogo.utils.NetworkUtils;
import com.mogo.utils.logger.Logger;
@@ -64,6 +66,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
protected FrameLayout mLeftPanelLayout;
protected View mLeftShadowFrame;
+ protected ImageView mWarningTop;
+ protected ImageView mWarningLeft;
+ protected ImageView mWarningRight;
+ protected ImageView mWarningBottom;
+
@Override
protected int getLayoutId() {
if ( !DebugConfig.isMapBased() ) {
@@ -103,6 +110,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
mLeftPanelLayout = findViewById( R.id.module_main_id_left_panel_fragment_container );
mHistoryMessagePanel = findViewById( R.id.module_main_id_message_history_fragment_container );
+ mWarningTop = findViewById(R.id.warning_top);
+ mWarningLeft = findViewById(R.id.warning_left);
+ mWarningRight = findViewById(R.id.warning_right);
+ mWarningBottom = findViewById(R.id.warning_bottom);
+
// 避免事件穿透导致地图被滑动
mLeftShadowFrame.setOnClickListener( view -> {
} );
diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml
new file mode 100644
index 0000000000..72aa9cfff4
--- /dev/null
+++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_bottom.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml
new file mode 100644
index 0000000000..bc04920106
--- /dev/null
+++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_left.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml
new file mode 100644
index 0000000000..7300bc5cf7
--- /dev/null
+++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_right.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml
new file mode 100644
index 0000000000..a6317a7428
--- /dev/null
+++ b/modules/mogo-module-main/src/main/res/drawable-xhdpi/module_main_warning_bkg_top.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
index 6712a3a36d..b785d02a94 100644
--- a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
+++ b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
@@ -2,8 +2,8 @@
@@ -12,6 +12,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+
+
+
+
+
+
+
18px
18px
18px
+
+ 1530px
\ No newline at end of file
diff --git a/modules/mogo-module-obu/doc/obu.md b/modules/mogo-module-obu/doc/obu.md
new file mode 100644
index 0000000000..7735e59252
--- /dev/null
+++ b/modules/mogo-module-obu/doc/obu.md
@@ -0,0 +1,36 @@
+# OBU
+
+## 基本介绍
+OBU:安装在车上的车载单元,一台车安装一个
+RSU:路测单元,装在路边杆子上的
+
+obu模块入口类是ObuManager
+
+## 基本通信流程
+RSU与OBU可互相通信,OBU与OBU可互相通信,对于我们是黑盒,可以不用关心;
+OBU对外暴露两种通信方式:
+ 1. 以OBU为wifi热点,车机连接OBU后,与OBU进行通信,使用这种通信方式,分体机无法和工控机进行通信,而且分体机也没有网,无法和服务端进行通信,所以这种方式基本无用;
+ 2. 先用OBU连接车载路由,分体机也连接车载路由,拿到OBU的IP地址后,可与此IP(OBU)进行通信,使用这种通信方式,需要在车载路由上配置OBU的IP地址,__使其固定__,这样每次都连接同一IP地址即可,__目前使用的就是这种方式__;
+
+## 需要处理的数据
+目前将obu返回的数据封装成了三种类型:
+1. 道路事件 MogoObuEventInfo
+2. 红绿灯信息 MogoObuTrafficLightInfo
+3. 自车定位 MogoObuLocationInfo
+目前只用到了道路事件和红绿灯信息,自车定位没有使用。
+
+## 数据展示
+收到obu数据后,是在v2x模块进行的展示,关键类是V2XObuManager和v2x包下scenario/scene/obu下的类,其中一部分是在v2x展示,一部分是通过adas展示,但是在鹰眼模式可能都需要在智慧交通展示,所以做了一个中间类接收给adas的广播,用来处理在鹰眼模式下的展示,关键类AdasNoticeHelper;
+
+## 通信方式
+通信方式分两种:__TCP通信__和__UDP通信__,不同的OBU通信方式也不一样。
+
+### Cidi 希迪 obu
+cidi是接的sdk进行通信,由于sdk封装了ip地址设置这一步,也就是说ip地址在sdk层就已经固定了,无法修改,如果想有修改的话,需要需要把核心sdk抽取出来,重新封装sdk,此步骤可查阅源码进行分析,固定的IP地址为192.168.8.121;
+关键类是CidiObu;
+
+### 华砺智行 obu
+目前应用在了苏州演示项目,采用tcp通信方式,关键类HualiObu,通信关键类是SimpleSocketManager;
+
+### 大唐高鸿 obu
+目前应用在了国展演示项目,采用udp通信方式,关键类是NetCarObu,通信关键类是UdpSocketManager;
\ 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 367840cca3..abbc83a430 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
@@ -26,6 +26,7 @@ import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoActionManager;
import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.statusmanager.IMogoStatusManager;
+import com.mogo.service.v2x.IV2XProvider;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
@@ -59,6 +60,8 @@ public class MarkerServiceHandler {
private static IMogoLauncher sLauncher;
private static IMogoFragmentManager sFragmentManager;
private static ICarsChattingProvider sCarChatting;
+ private static IV2XProvider sIV2XProvider;
+
// private static IMogoGpsSimulatorManager sGpsSimulatorManager;
public static synchronized void init( final Context context ) {
@@ -86,6 +89,7 @@ public class MarkerServiceHandler {
sFragmentManager = sApis.getFragmentManagerApi();
sCarChatting = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context );
+ sIV2XProvider = sApis.getV2XListenerManager();
MapMarkerManager.getInstance().init( context );
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
index 8ba5edf003..5e193cf211 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
@@ -26,10 +26,16 @@ public interface RefreshApiService {
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync" )
Observable< BaseData > refreshData( @FieldMap Map< String, Object > parameters );
+ /*
+ * 大而全
+ * */
@FormUrlEncoded
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync" )
Observable< MarkerResponse > refreshDataSync( @FieldMap Map< String, Object > parameters );
+ /*
+ * 周边在线车辆
+ * */
@FormUrlEncoded
@POST( "/yycp-launcherSnapshot/user/queryOnLineCarWithRoute" )
Observable< MarkerResponse > queryOnLineCarWithRoute( @FieldMap Map< String, Object > parameters );
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java
index 5ac444b6c0..07b2ed3cf1 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java
@@ -63,6 +63,9 @@ public class MogoReceiver extends BroadcastReceiver {
// 同行者 查询xxx堵不堵发送的广播
public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo";
+ //车路云—场景预警
+ public static final String ACTION_V2X_FRONT_WARNING = "ACTION_V2X_FRONT_WARNING";
+
private IMogoIntentManager mMogoIntentManager;
public MogoReceiver(Context context) {
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
index 20c8dde883..4248f06ef1 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
@@ -31,4 +31,12 @@ public class MoGoV2XServicePaths {
@Keep
public static final String PATH_V2X_POLYLINE_MANAGER = "/v2xPolylineManager/api";
+ /**
+ * V2X 道路事件与车辆的连接线
+ */
+ @Keep
+ public static final String PATH_V2X_WARN_POLYLINE_MANAGER = "/v2xWarnPolylineManager/api";
+
+
+
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
index d541614125..da66d70c52 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
@@ -13,6 +13,7 @@ import com.mogo.module.v2x.alarm.V2XCalculateServer;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
+import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
import com.mogo.module.v2x.network.V2XRefreshModel;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.IMogoServiceApis;
@@ -96,6 +97,7 @@ public class V2XServiceManager {
private static IMoGoV2XMarkerManager moGoV2XMarkerManager;
private static IMoGoV2XPolylineManager moGoV2XPolylineManager;
private static IMoGoV2XStatusManager moGoV2XStatusManager;
+ private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
private V2XServiceManager() {
@@ -147,6 +149,8 @@ public class V2XServiceManager {
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
+ moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
+
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
}
}
@@ -239,6 +243,10 @@ public class V2XServiceManager {
return moGoV2XPolylineManager;
}
+ public static IMoGoWarnPolylineManager getMoGoWarnPolylineManager() {
+ return moGoWarnPolylineManager;
+ }
+
public static IMoGoV2XStatusManager getMoGoV2XStatusManager() {
if (moGoV2XStatusManager == null) {
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(V2XUtils.getApp());
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoWarnPolylineManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoWarnPolylineManager.java
new file mode 100644
index 0000000000..c2a2913d3f
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoWarnPolylineManager.java
@@ -0,0 +1,27 @@
+package com.mogo.module.v2x.manager;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+import com.mogo.map.overlay.IMogoPolyline;
+import com.mogo.module.common.entity.V2XRoadEventEntity;
+
+/**
+ * 绘制可变宽度和渐变的线
+ */
+public interface IMoGoWarnPolylineManager extends IProvider {
+ /**
+ * 绘制连接线,目标车,与当前车辆间连线
+ *
+ * @param context
+ * @param roadEventEntity
+ */
+ void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity);
+
+ /**
+ * 移除连接线
+ */
+ void clearLine();
+
+ IMogoPolyline getMogoWarnPolyline();
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java
new file mode 100644
index 0000000000..40d19c0b03
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java
@@ -0,0 +1,99 @@
+package com.mogo.module.v2x.manager.impl;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.map.MogoLatLng;
+import com.mogo.map.overlay.IMogoPolyline;
+import com.mogo.map.overlay.MogoPolylineOptions;
+import com.mogo.module.common.entity.V2XPoiTypeEnum;
+import com.mogo.module.common.entity.V2XRoadEventEntity;
+import com.mogo.module.v2x.MoGoV2XServicePaths;
+import com.mogo.module.v2x.V2XServiceManager;
+import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 当前车辆与道路事件的连接线
+ */
+@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER)
+public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
+ private static final String TAG = "MoGoWarnPolylineManager";
+ private static IMogoPolyline mMogoPolyline;
+
+ //TODO liyz
+ @Override
+ public void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity) {
+ try {
+ if (mMogoPolyline != null) {
+ mMogoPolyline.remove();
+ }
+ if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
+ || V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
+ && V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
+ // 连接线参数
+ MogoPolylineOptions options = new MogoPolylineOptions();
+
+ // 渐变色
+ List colors = new ArrayList<>();
+
+ switch (roadEventEntity.getPoiType()) {
+ case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
+ case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
+ case V2XPoiTypeEnum.FOURS_BLOCK_UP:
+ case V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING + "":
+ colors.add(0xFFFFA31A);
+ colors.add(0xFFFFA31A);
+ break;
+ default:
+ colors.add(0xFFE32F46);
+ colors.add(0xFFE32F46);
+ break;
+ }
+
+ // 线条粗细,渐变,渐变色值
+ options.width(10).useGradient(true).colorValues(colors);
+
+ // 当前车辆位置
+ MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
+ if (carLocation != null) {
+ options.add(carLocation);
+ } else {
+ options.add(V2XServiceManager.getV2XStatusManager().getLocation());
+ }
+ // 目标车辆位置
+ options.add(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng());
+
+ // 绘制线的对象
+ mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void clearLine() {
+ if (mMogoPolyline != null) {
+ mMogoPolyline.remove();
+ mMogoPolyline = null;
+ V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
+ }
+ }
+
+ @Override
+ public void init(Context context) {
+
+ }
+
+ /**
+ * @return 绘制连接线的对象
+ */
+ @Override
+ public IMogoPolyline getMogoWarnPolyline() {
+ return mMogoPolyline;
+ }
+
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java
index f46bc7a74b..285d808e28 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java
@@ -1,7 +1,6 @@
package com.mogo.module.v2x.scenario.impl;
import android.content.Intent;
-import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -21,6 +20,7 @@ import com.mogo.module.v2x.scenario.scene.pushVR.V2XPushVREventScenario;
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
import com.mogo.module.v2x.scenario.scene.ugc.V2XEventUgcScenario;
+import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
@@ -75,8 +75,8 @@ public class V2XScenarioManager implements IV2XScenarioManager {
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
mV2XScenario = new V2XSeekHelpScenario();
break;
- case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING :
- case ALERT_RECOMMEND_PARKING :
+ case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
+ case ALERT_RECOMMEND_PARKING:
mV2XScenario = new V2XFatigueDrivingScenario();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
@@ -106,6 +106,12 @@ public class V2XScenarioManager implements IV2XScenarioManager {
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
mV2XScenario = new V2XPushVREventScenario();
break;
+ case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP:
+ case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT:
+ case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT:
+ case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM:
+ mV2XScenario = new V2XFrontWarningScenario();
+ break;
default:
mV2XScenario = null;
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
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 ddac88ec6b..919831af2b 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
@@ -51,6 +51,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerRoadEvent;
private Button mBtnClearRoadEvent;
private Button mBtnTriggerPushEvent;
+ private Button mBtnTriggerWarningEvent;
private Button mBtnTriggerPushLiveCarEvent;
private Button mBtnTriggerAnimationEvent;
private Button mBtnbtnFrontCarLiveEvent;
@@ -112,6 +113,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
+ mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent);
mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent);
mBtnTriggerPushLiveCarEvent = findViewById(R.id.btnTriggerPushLiveCarEvent);
mBtnTriggerAnimationEvent = findViewById(R.id.btnTriggerAnimationEvent);
@@ -213,6 +215,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
});
+ //车路云—场景预警-V1.0 碰撞预警
+ mBtnTriggerWarningEvent.setOnClickListener(v->{
+ V2XMessageEntity v2XMessageEntity =
+ TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
+
+ Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
+ intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
+ LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
+ });
+
mBtnTriggerPushEvent.setOnClickListener(v -> {
V2XMessageEntity v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushEventData();
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java
new file mode 100644
index 0000000000..a24044b98c
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java
@@ -0,0 +1,132 @@
+package com.mogo.module.v2x.scenario.scene.warning;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.Nullable;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.entity.V2XMessageEntity;
+import com.mogo.module.common.entity.V2XPoiTypeEnum;
+import com.mogo.module.common.entity.V2XPushMessageEntity;
+import com.mogo.module.common.entity.V2XRoadEventEntity;
+import com.mogo.module.service.MarkerServiceHandler;
+import com.mogo.module.service.MogoServices;
+import com.mogo.module.service.receiver.MogoReceiver;
+import com.mogo.module.v2x.R;
+import com.mogo.module.v2x.V2XServiceManager;
+import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
+import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
+import com.mogo.module.v2x.utils.ADASUtils;
+import com.mogo.module.v2x.utils.V2XUtils;
+import com.mogo.service.MogoServicePaths;
+import com.mogo.service.impl.MogoServiceApis;
+import com.mogo.service.impl.v2x.V2XManager;
+import com.mogo.service.v2x.IV2XListener;
+import com.mogo.service.v2x.IV2XProvider;
+import com.mogo.service.windowview.IMogoTopViewStatusListener;
+
+import java.util.List;
+
+/**
+ * @author liujing
+ * @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
+ * @since: 2021/3/24
+ */
+public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
+ private int type;
+ private IV2XListener mIV2XListener;
+ private List mMarkerEntity;
+ private V2XPushMessageEntity mV2XPushMessageEntity;
+
+ public V2XFrontWarningScenario() {
+ setV2XWindow(new V2XWarningWindow());
+ }
+
+ @Override
+ public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
+ type = v2XMessageEntity.getType();
+ MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING);
+ try {
+ if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
+ if (getV2XMessageEntity() != null &&
+ !V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
+ show();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ show();
+ }
+
+ @Override
+ public void show() {
+ showWindow();
+ }
+
+ @Override
+ public void showWindow() {
+// if (getV2XWindow() != null && mMarkerEntity != null) {
+ View view = getV2XWindow().getView();
+ //Logger.d(MODULE_NAME, "添加window= " + view);
+ ViewGroup.LayoutParams layoutParams =
+ new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ (int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
+ V2XServiceManager
+ .getMogoTopViewManager()
+ .addView(getV2XWindow().getView(), layoutParams, this);
+ getV2XWindow().show(mV2XPushMessageEntity);
+// }
+ }
+
+ @Override
+ public void closeWindow() {
+
+ }
+
+ @Override
+ public void showButton() {
+
+ }
+
+ @Override
+ public void closeButton() {
+
+ }
+
+ @Override
+ public void drawPOI() {
+
+ }
+
+ @Override
+ public void clearPOI() {
+
+ }
+
+ @Override
+ public void onViewAdded(View view) {
+
+ }
+
+ @Override
+ public void onViewRemoved(View view) {
+
+ }
+
+ @Override
+ public void beforeViewAddAnim(View view) {
+
+ }
+
+ @Override
+ public void beforeViewRemoveAnim(View view) {
+
+ }
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java
new file mode 100644
index 0000000000..726d245649
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java
@@ -0,0 +1,104 @@
+package com.mogo.module.v2x.scenario.scene.warning;
+
+import android.content.Context;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+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.scene.V2XBasWindow;
+import com.mogo.module.v2x.scenario.view.IV2XWindow;
+import com.mogo.utils.logger.Logger;
+
+/**
+ * @author liujing
+ * @description 车路云—场景预警 http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52829799
+ * @since: 2021/3/25
+ */
+public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
+
+ private ImageView typeImage;
+ private TextView warningTextView;
+ private TextView distance;
+
+ //倒计时3s弹框取消
+ private static Handler handlerV2XEvent = new Handler();
+ private static Runnable runnableV2XEvent;
+ private static final int COUNT_DOWN_TIMER = 1_000;
+ private static final int ALL_EXPIRE_TIMER = 3_000;
+ private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
+
+ public V2XWarningWindow() {
+ this(V2XServiceManager.getContext(), null);
+ }
+
+ public V2XWarningWindow(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public V2XWarningWindow(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initView(context);
+ }
+
+ private void initView(Context context) {
+ LayoutInflater.from(context).inflate(R.layout.v2x_road_front_warning_vr, this);
+ typeImage = findViewById(R.id.warning_type_image);
+ warningTextView = findViewById(R.id.warning_content_text);
+ distance = findViewById(R.id.warning_distance);
+ }
+
+ @Override
+ public void show(Object entity) {
+ if (entity != null) {
+
+ }
+ if (runnableV2XEvent == null) {
+ runnableV2XEvent = () -> {
+ EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
+ if (EXPIRE_TIMER > 0) {
+ handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
+ } else {
+ stopCountDown();
+ }
+ };
+ } else {
+ handlerV2XEvent.removeCallbacks(runnableV2XEvent);
+ }
+ handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
+
+ }
+
+ @Override
+ public void close() {
+ stopCountDown();
+ }
+
+ @Override
+ public View getView() {
+ return this;
+ }
+
+ @Override
+ public void setWindowStatusListener(V2XWindowStatusListener listener) {
+
+ }
+
+ private void stopCountDown() {
+ if (handlerV2XEvent != null && runnableV2XEvent != null) {
+ handlerV2XEvent.removeCallbacks(runnableV2XEvent);
+ runnableV2XEvent = null;
+ EXPIRE_TIMER = ALL_EXPIRE_TIMER;
+ }
+ //移除窗体
+ V2XServiceManager
+ .getMogoTopViewManager()
+ .removeView(this);
+
+ }
+}
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 7757a27b51..bd0e95de1e 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
@@ -156,6 +156,35 @@ public class TestOnLineCarUtils {
return null;
}
+ public static V2XMessageEntity getV2XScenarioPushFrontWarningEventData() {
+ try {
+ InputStream inputStream = V2XUtils.getApp()
+ .getResources()
+ .openRawResource(R.raw.scenario_warning_event_data);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int len = -1;
+ byte[] buffer = new byte[1024];
+ while ((len = inputStream.read(buffer)) != -1) {
+ baos.write(buffer, 0, len);
+ }
+ inputStream.close();
+
+ // 加载数据源
+ V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class);
+
+ V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>();
+ // 控制类型
+ v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
+ // 设置数据
+ v2xMessageEntity.setContent(v2xRoadEventEntity);
+ // 控制展示状态
+ v2xMessageEntity.setShowState(true);
+ return v2xMessageEntity;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
/**
* 模拟H5推送直播数据
diff --git a/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/v2x_road_front_car_warning.png b/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/v2x_road_front_car_warning.png
new file mode 100644
index 0000000000..f5fd2de5e0
Binary files /dev/null and b/modules/mogo-module-v2x/src/main/res/drawable-xhdpi/v2x_road_front_car_warning.png differ
diff --git a/modules/mogo-module-v2x/src/main/res/drawable/v2x_front_warning_bg.xml b/modules/mogo-module-v2x/src/main/res/drawable/v2x_front_warning_bg.xml
new file mode 100644
index 0000000000..54f571d1e5
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/res/drawable/v2x_front_warning_bg.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml b/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml
new file mode 100644
index 0000000000..47b06a1102
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
index b9253925c9..2e1d5e64cb 100644
--- a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
+++ b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml
@@ -239,6 +239,20 @@
android:textSize="@dimen/dp_22"
android:textStyle="bold" />
+
+