增加了推送VR的场景处理,目前是空实现

This commit is contained in:
董宏宇
2020-10-28 16:16:42 +08:00
parent 503e053b7a
commit 735f5a6812
6 changed files with 269 additions and 0 deletions

View File

@@ -139,6 +139,8 @@ public class V2XMessageEntity<T> implements Serializable {
int ALERT_ILLEGAL_PARK_WARNING = 1_008;
// 呼叫、请求直播事件
int ALERT_VOICE_CALL_FOR_LIVECAR_SHOW = 1_009;
// 推送VR消息展示
int ALERT_PUSH_VR_SHOW = 2_000;
// 自车求助
int ALERT_CAR_FOR_HELP = 8_000;
// obu事件
@@ -157,6 +159,7 @@ public class V2XMessageEntity<T> implements Serializable {
V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING,
V2XTypeEnum.ALERT_CAR_FOR_HELP,
V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW,
V2XTypeEnum.ALERT_PUSH_VR_SHOW,
V2XTypeEnum.ALERT_OBU_EVENT,
})
@Target({

View File

@@ -15,6 +15,7 @@ import com.mogo.module.v2x.scenario.scene.livecar.V2XPushLiveCarScenario;
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveScenario;
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
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.utils.V2XUtils;
@@ -99,6 +100,9 @@ public class V2XScenarioManager implements IV2XScenarioManager {
case V2XMessageEntity.V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW:
mV2XScenario = V2XVoiceCallLiveScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
mV2XScenario = V2XPushVREventScenario.getInstance();
break;
default:
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
TipToast.tip("当前V2X消息类型未定义");

View File

@@ -0,0 +1,78 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerExploreWayItem;
import com.mogo.module.common.entity.MarkerLocation;
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.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XMarkerClickListener;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.utils.MarkerUtils;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : 推送VR场景
* version: 1.0
*/
public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
@Override
public void drawPOI(V2XPushMessageEntity entity) {
try {
// 清除道路事件
V2XServiceManager
.getMoGoV2XMarkerManager().clearALLPOI();
// 位置信息
MarkerLocation markerLocation = new MarkerLocation();
markerLocation.setLon(entity.getLon());
markerLocation.setLat(entity.getLat());
// 进行数据转换用于Marker展示
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setLocation(markerLocation);
// 探路目前只有上报拥堵
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
MarkerExploreWay markerNoveltyInfo = new MarkerExploreWay();
List<MarkerExploreWayItem> items = new ArrayList<>();
MarkerExploreWayItem exploreWayItem = new MarkerExploreWayItem();
exploreWayItem.setThumbnail(entity.getMsgImgUrl());
items.add(exploreWayItem);
markerNoveltyInfo.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
markerNoveltyInfo.setItems(items);
markerNoveltyInfo.setUploadType("1");
v2XRoadEventEntity.setNoveltyInfo(markerNoveltyInfo);
v2XRoadEventEntity.setExpireTime(20000);
V2XServiceManager
.getMoGoV2XMarkerManager()
.drawableAlarmPOI(V2XServiceManager.getContext(),
v2XRoadEventEntity,
V2XMarkerClickListener.getInstance());
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearPOI() {
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
MarkerUtils.resetMapZoom(16);
// 移除线
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
// 移除事件POI
V2XServiceManager.getMoGoV2XMarkerManager().clearAlarmPOI();
// 绘制上次的数据
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
}
}

View File

@@ -0,0 +1,141 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.view.View;
import androidx.annotation.Nullable;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : 推送VR场景控制
* version: 1.0
*/
public class V2XPushVREventScenario
extends AbsV2XScenario<V2XPushMessageEntity>
implements IMogoTopViewStatusListener {
private static V2XPushVREventScenario mV2XPushEventScenario;
private V2XPushVREventScenario() {
}
public static V2XPushVREventScenario getInstance() {
if (mV2XPushEventScenario == null) {
synchronized (V2XPushVREventScenario.class) {
if (mV2XPushEventScenario == null) {
mV2XPushEventScenario = new V2XPushVREventScenario();
mV2XPushEventScenario.setV2XMarker(new V2XPushVREventMarker());
}
}
}
return mV2XPushEventScenario;
}
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
Logger.w(MODULE_NAME, "处理推送VR场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
if (!isSameScenario(v2XMessageEntity)
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
setV2XMessageEntity(v2XMessageEntity);
show();
} else {
setV2XMessageEntity(v2XMessageEntity);
Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
}
}
@Override
public void show() {
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
speakTTSVoice(getV2XMessageEntity().getContent().getTts(), null);
drawPOI();
showWindow();
}
}
@Override
public void showWindow() {
if (getV2XWindow() != null) {
//TODO 这里调用 showLeftNoticeByType 进行展示左下角的弹窗
}
}
@Override
public void closeWindow() {
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
if (getV2XWindow() != null) {
getV2XWindow().close();
}
}
@Override
public void showButton() {
if (getV2XButton() != null) {
getV2XButton().show();
}
}
@Override
public void closeButton() {
if (getV2XButton() != null) {
getV2XButton().close();
}
}
@Override
public void drawPOI() {
if (getV2XMarker() != null) {
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, true);
}
}
@Override
public void clearPOI() {
if (getV2XMarker() != null) {
getV2XMarker().clearPOI();
}
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, false);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onViewAdded(View view) {
Logger.d(MODULE_NAME, "展示 Window 动画结束");
}
@Override
public void onViewRemoved(View view) {
Logger.d(MODULE_NAME, "关闭 Window 动画结束");
}
@Override
public void beforeViewAddAnim(View view) {
Logger.d(MODULE_NAME, "展示 Window 开始");
}
@Override
public void beforeViewRemoveAnim(View view) {
Logger.d(MODULE_NAME, "关闭 Window 开始");
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
// 重置场景提示的消息
setV2XMessageEntity(null);
clearPOI();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}

View File

@@ -206,6 +206,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
});
btnTriggerCongestedRouteRecommendation.setOnClickListener(v -> {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushVR();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
});
}
}

View File

@@ -357,4 +357,37 @@ public class TestOnLineCarUtils {
}
return null;
}
/**
* 模拟H5推送场景---推送VR场景信息
*/
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioPushVR() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_push_vr_event_data_yongdu);
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<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}