Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

# Conflicts:
#	modules/mogo-module-v2x/src/main/res/values/colors.xml
This commit is contained in:
wujifei
2021-03-29 16:06:25 +08:00
104 changed files with 18333 additions and 5603 deletions

View File

@@ -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";
}

View File

@@ -36,6 +36,12 @@ public class V2XConst {
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
/**
* V2X ADASData Action
*/
public static final String BROADCAST_ADAS_SCENE_HANDLER_ACTION = "com.v2x.adas_data_broadcast";
public static final String BROADCAST_ADAS_EXTRA_KEY = "ADASData";
/**
* V2X 测试控制面板广播Action
*/

View File

@@ -3,18 +3,25 @@ package com.mogo.module.v2x;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.overlay.IMogoOverlayManager;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.service.MarkerServiceHandler;
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.realtime.entity.ADASRecognizedResult;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
@@ -40,6 +47,9 @@ import com.mogo.service.windowview.IMogoWindowManager;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
@@ -96,6 +106,10 @@ public class V2XServiceManager {
private static IMoGoV2XMarkerManager moGoV2XMarkerManager;
private static IMoGoV2XPolylineManager moGoV2XPolylineManager;
private static IMoGoV2XStatusManager moGoV2XStatusManager;
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
List<ADASRecognizedResult> resultList = new ArrayList<>();
private V2XServiceManager() {
@@ -147,10 +161,41 @@ 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);
List<MogoLatLng> lonLats = new ArrayList<>();
// adas 每隔一秒传递的他车或行人数据
mIMogoADASController.addAdasRecognizedDataCallback(resultList -> {
// 绘制近景识别到的车辆,行人和二轮车 TODO
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// 绘制连接线 TODO 来的是列表数据
// V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(context, roadEventEntity);
//更新数据
for (ADASRecognizedResult result : resultList) {
MogoLatLng latLng = new MogoLatLng(result.lat, result.lon);
lonLats.add(latLng);
}
IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
mMogoPolyline.setPoints(lonLats);
} );
//绘制自车数据 liyz
}
}
public static Context getContext() {
return mContext;
}
@@ -239,6 +284,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());

View File

@@ -0,0 +1,44 @@
package com.mogo.module.v2x.entity.model;
import com.mogo.map.MogoLatLng;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class DrawLineInfo {
//报警类型
private String type;
// 起点位置
private MogoLatLng startLocation;
//结束点位置
private MogoLatLng endLocation;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public MogoLatLng getStartLocation() {
return startLocation;
}
public void setStartLocation(MogoLatLng startLocation) {
this.startLocation = startLocation;
}
public MogoLatLng getEndLocation() {
return endLocation;
}
public void setEndLocation(MogoLatLng endLocation) {
this.endLocation = endLocation;
}
}

View File

@@ -0,0 +1,29 @@
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;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.realtime.entity.ADASRecognizedResult;
/**
* 绘制可变宽度和渐变的线
*/
public interface IMoGoWarnPolylineManager extends IProvider {
/**
* 绘制连接线,目标车,与当前车辆间连线
*
* @param context
* @param info
*/
void drawableWarnPolyline(Context context, DrawLineInfo info);
/**
* 移除连接线
*/
void clearLine();
IMogoPolyline getMogoWarnPolyline();
}

View File

@@ -0,0 +1,88 @@
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.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
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;
@Override
public void drawableWarnPolyline(Context context, DrawLineInfo info) {
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
if (info.getType().equals("1")) { //预警 TODO
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}
// 线条粗细,渐变,渐变色值
options.width(30).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getStartLocation());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearLine() {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
mMogoPolyline = null;
}
}
@Override
public void init(Context context) {
}
/**
* @return 绘制连接线的对象
*/
@Override
public IMogoPolyline getMogoWarnPolyline() {
return mMogoPolyline;
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.module.v2x.V2XConst;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
/**
* 单车预警,车辆盲区预警,弱势交通参与者预警
*/
public class AdasDataBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
ADASRecognizedResult adasResult = (ADASRecognizedResult) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
Logger.d("AdasDataBroadcastReceiver", "adasResult:" + GsonUtil.jsonFromObject(adasResult));
// V2XScenarioManager.getInstance().handlerMessage(adasResult);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -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消息类型未定义。");

View File

@@ -36,7 +36,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* e-mail : 1358506549@qq.com
* date : 2020/4/14 2:37 PM
* desc :
* TODO 目前前瞻推送使用的消息都在这里展示
* TODO 目前前瞻推送使用的消息都在这里展示
* version: 1.0
*/
public class V2XPushEventWindow extends V2XBasWindow implements IV2XWindow<V2XPushMessageEntity> {

View File

@@ -1,9 +1,7 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.common.drawer.PushRoadConditionDrawer;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
@@ -25,7 +23,6 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
private final String TAG = "V2XPushVREventMarker";
private static IMogoPolyline mMogoPolyline;
private static IMogoMarker mAlarmInfoMarker;
@Override
public void drawPOI(V2XPushMessageEntity entity) {
@@ -39,44 +36,13 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
// 绘制事件点Marker
PushRoadConditionDrawer.getInstance().drawRoadConditionMarker(entity);
// 绘制引导线
drawablePloyLine(entity);
drawableRecommendPolyline(entity);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 绘制引导线
*
* @param entity
*/
void drawablePloyLine(V2XPushMessageEntity entity) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
colors.add(0xFFFA8C34);
colors.add(0xFFBD6D36);
colors.add(0xFFFA8C34);
// 线条粗细,渐变,渐变色值
options.width(15).useGradient(true).color(0xFF1F7EFF);
for (double[] doubles : entity.getPolyline()) {
options.add(doubles[0], doubles[1]);
}
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
}
/**
* 绘制推荐引导线
*
@@ -93,7 +59,7 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
colors.add(0xFFCB253A);
// 线条粗细,渐变,渐变色值
options.width(15).useGradient(true).color(0xFFEF3A3A);
options.width(15).useGradient(true).color(0xFFF95959);
for (double[] doubles : entity.getRecommendPolyline()) {
options.add(doubles[0], doubles[1]);
@@ -109,18 +75,10 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
MarkerUtils.resetMapZoom(16);
// 移除线
clearLine();
// 移除事件POI
clearAlarmPOI();
// 绘制上次的数据
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
}
void clearAlarmPOI() {
if (mAlarmInfoMarker != null) {
mAlarmInfoMarker.remove();
}
}
public void clearLine() {
if (mMogoPolyline != null) {
mMogoPolyline.remove();

View File

@@ -1,14 +1,17 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
@@ -32,7 +35,7 @@ public class V2XPushVREventScenario
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR" + GsonUtil.jsonFromObject(v2XMessageEntity));
if (!isSameScenario(v2XMessageEntity)
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
@@ -58,7 +61,15 @@ public class V2XPushVREventScenario
@Override
public void showWindow() {
if (getV2XWindow() != null) {
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_window_height_ground));
V2XServiceManager
.getMogoTopViewManager()
.addView(getV2XWindow().getView(), layoutParams, this);
getV2XWindow().show(getV2XMessageEntity().getContent());
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, true);
}
}

View File

@@ -1,14 +1,17 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
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.scene.V2XBasWindow;
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;
@@ -21,7 +24,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* TODO 只有VR演示场景使用
* version: 1.0
*/
public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
public class V2XPushVREventWindow extends V2XBasWindow implements IV2XWindow<V2XPushMessageEntity> {
private String TAG = "V2XPushVREventWindow";
// 处理道路事件30秒倒计时
@@ -29,6 +32,26 @@ public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
private Runnable runnableV2XEvent;
private int mExpireTime = 30000;
public V2XPushVREventWindow() {
this(V2XServiceManager.getContext());
}
public V2XPushVREventWindow(Context context) {
this(context, null);
}
public V2XPushVREventWindow(Context context, AttributeSet attrs) {
this(V2XServiceManager.getContext(), null, 0);
}
public V2XPushVREventWindow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// 填充布局
LayoutInflater.from(context).inflate(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.layout.window_road_event_detail_vr : R.layout.window_road_event_detail, this);
}
/**
* 展示道路事件详情Windows
*/
@@ -36,13 +59,7 @@ public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
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();
countDownV2XEvent();
}
/**
@@ -51,21 +68,22 @@ public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
@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;
}
//移除窗体
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
@Override
public View getView() {
return null;
return this;
}
@Override

View File

@@ -7,7 +7,9 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ToggleButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -17,6 +19,7 @@ import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
@@ -51,6 +54,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;
@@ -61,7 +65,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerEventUgc;
private Button mBtnTriggerTrafficSearch;
private Button mBtnTriggerRecommendRouteEvent;
private Button nBtnTriggerVR;
private ToggleButton nBtnTriggerVR;
private Button btnTriggerRearVIPCarTip,
btnTriggerVehicleBrakes,
@@ -112,6 +116,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);
@@ -138,10 +143,11 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
break;
}
nBtnTriggerVR.setOnClickListener(new OnClickListener() {
nBtnTriggerVR.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onClick(View v) {
V2XServiceManager.getMoGoStatusManager().setVrMode("nBtnTriggerVR", true);
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
V2XServiceManager.getMoGoStatusManager().setVrMode("nBtnTriggerVR", isChecked);
}
});
@@ -213,6 +219,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
});
//车路云—场景预警-V1.0 碰撞预警
mBtnTriggerWarningEvent.setOnClickListener(v->{
V2XMessageEntity<V2XWarningEntity> 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<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushEventData();

View File

@@ -0,0 +1,128 @@
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.common.entity.V2XWarningEntity;
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 direction;
private V2XWarningEntity mMarkerEntity;
public V2XFrontWarningScenario() {
setV2XWindow(new V2XWarningWindow());
}
@Override
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
try {
if (v2XMessageEntity != null && V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
direction = mMarkerEntity.getDirection();
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@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(mMarkerEntity);
}
}
@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) {
}
}

View File

@@ -0,0 +1,124 @@
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.commons.voice.AIAssist;
import com.mogo.commons.voice.VoicePreemptType;
import com.mogo.module.common.entity.V2XWarningEntity;
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.module.v2x.utils.V2XUtils;
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;
private V2XWarningEntity mV2XWarningEntity;
//倒计时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) {
mV2XWarningEntity = (V2XWarningEntity) entity;
//行人0/自行车1/摩托车2/小汽车3/公交车4
switch (mV2XWarningEntity.getType()) {
case 0:
typeImage.setImageResource(R.drawable.v2x_road_front_p_warning);
break;
case 1:
case 2:
typeImage.setImageResource(R.drawable.v2x_road_front_p_warning);
break;
default:
break;
}
distance.setText(String.valueOf(mV2XWarningEntity.getDistance()) + "");
warningTextView.setText(mV2XWarningEntity.getTipContent());
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice(mV2XWarningEntity.getTts());
}
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);
}
}

View File

@@ -5,6 +5,7 @@ import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.utils.network.utils.GsonUtil;
@@ -156,6 +157,35 @@ public class TestOnLineCarUtils {
return null;
}
public static V2XMessageEntity<V2XWarningEntity> 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();
// 加载数据源
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
V2XMessageEntity<V2XWarningEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
// 设置数据
v2xMessageEntity.setContent(warningEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 模拟H5推送直播数据
@@ -398,7 +428,7 @@ public class TestOnLineCarUtils {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_push_vr_event_data_yongdu);
.openRawResource(R.raw.scenario_push_vr_event_data_yongdu_gongsi);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = -1;
byte[] buffer = new byte[1024];