opt
This commit is contained in:
@@ -125,4 +125,8 @@ public class V2XConst {
|
||||
*/
|
||||
public static final String V2X_MARKER_GOVERNMENT = "V2X_MARKER_GOVERNMENT";
|
||||
|
||||
/**
|
||||
* 绿波车速marker
|
||||
*/
|
||||
public static final String V2X_OPTIMAL_SPEED_MARKER = "V2X_OPTIMAL_SPEED_MARKER";
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.receiver.SceneBroadcastReceiver;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz;
|
||||
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkWindow;
|
||||
import com.mogo.module.v2x.utils.FatigueDrivingUtils;
|
||||
@@ -140,7 +141,7 @@ public class V2XModuleProvider implements
|
||||
V2XVoiceManager.INSTANCE.init(context);
|
||||
registerListener();
|
||||
initData();
|
||||
|
||||
initBiz(context);
|
||||
// 注册广播接收场景弹窗使用的
|
||||
SceneBroadcastReceiver localReceiver = new SceneBroadcastReceiver();
|
||||
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
|
||||
@@ -148,6 +149,12 @@ public class V2XModuleProvider implements
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
|
||||
|
||||
// obu数据转发初始化
|
||||
V2XObuManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
private void initBiz(Context context) {
|
||||
V2XVoiceCallLiveBiz.getInstance().init(context);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
@@ -175,6 +182,9 @@ public class V2XModuleProvider implements
|
||||
* 获取疲劳驾驶的配置
|
||||
*/
|
||||
private void refreshStrategyConfig() {
|
||||
//TODO V2XDemoManager这个是演示需求获取服务端配置可用直播车机
|
||||
V2XDemoManager.getInstance().initData();
|
||||
// 获取疲劳驾驶的配置
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel()
|
||||
.getStrategyPush(new V2XRefreshCallback<V2XStrategyPushRes>() {
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
package com.mogo.module.v2x;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.ObuManager;
|
||||
import com.zhidao.mogo.module.obu.obu.IObuCallback;
|
||||
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.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
import static com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario.ACTION_LAUNCHER_ADAS_APP_BIZ;
|
||||
|
||||
/**
|
||||
* obu数据管理类封装
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuManager implements IObuCallback, Handler.Callback {
|
||||
private static final String TAG = V2XObuManager.class.getSimpleName();
|
||||
|
||||
private static final long DEFAULT_INTERVAL_TIME = 30_000L;
|
||||
|
||||
private V2XObuManager() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuManager instance = null;
|
||||
|
||||
public static V2XObuManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
|
||||
private static final long DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY = 1500L;
|
||||
private Handler handler = new Handler(this);
|
||||
|
||||
public void init(Context context) {
|
||||
Logger.d(MODULE_NAME, "obuManager初始化--");
|
||||
ObuManager obuManager = new ObuManager();
|
||||
obuManager.init(context);
|
||||
obuManager.registerObuDataChangedListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用来处理30秒内不重复播报的情况
|
||||
*/
|
||||
private Map<String, Long> intervalMap = new ArrayMap<>();
|
||||
|
||||
private int parseObuEvent(String type) {
|
||||
switch (type) {
|
||||
case "06":
|
||||
// 紧急制动预警
|
||||
return ObuConstant.TYPE_URGENCY_COLLISION_WARNING;
|
||||
case "13":
|
||||
// 绿波车速引导
|
||||
return ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY;
|
||||
case "39":
|
||||
// 行人碰撞预警
|
||||
return ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING;
|
||||
case "vip变灯提醒":
|
||||
return ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLocation[] historyPath = new MogoLocation[2];
|
||||
|
||||
private float computeCarAngle(MogoLocation location) {
|
||||
float angle = 0f;
|
||||
if (historyPath[0] != null) {
|
||||
historyPath[1] = historyPath[0];
|
||||
}
|
||||
historyPath[0] = location;
|
||||
|
||||
if (historyPath[1] != null && historyPath[0] != null) {
|
||||
double carAngle =
|
||||
DrivingDirectionUtils.getCarAngle(
|
||||
historyPath[1].getLatitude(), historyPath[1].getLongitude(),
|
||||
historyPath[0].getLatitude(), historyPath[0].getLongitude()
|
||||
);
|
||||
// 这里是真实的车辆角度
|
||||
angle = (float) carAngle;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
private static final String CALL_ADAS_SHOW_TRAFFIC_LIGHT = "2";
|
||||
private static final String CALL_ADAS_HIDE_TRAFFIC_LIGHT = "1";
|
||||
|
||||
private void sendTrafficLightStatusToAdas(String status, MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
if (V2XObuEventScenario.getInstance().isInChangeLightForVip()) {
|
||||
status = CALL_ADAS_HIDE_TRAFFIC_LIGHT;
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
// String action "1" - 隐藏 "2" - 显示
|
||||
json.put("action", status);
|
||||
if (trafficLightInfo != null) {
|
||||
if (trafficLightInfo.getLightStatus() == null) {
|
||||
json.put("lightStatus", "G");
|
||||
} else {
|
||||
json.put("lightStatus", trafficLightInfo.getLightStatus());
|
||||
}
|
||||
if (trafficLightInfo.getSurplusTime() == null) {
|
||||
json.put("surplusTime", "0");
|
||||
} else {
|
||||
json.put("surplusTime", trafficLightInfo.getSurplusTime());
|
||||
}
|
||||
}
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送红绿灯广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 2);
|
||||
getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送红绿灯广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_HIDE_TRAFFIC_LIGHT) {
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventInfoCallback(MogoObuEventInfo info) {
|
||||
Logger.d("V2X_OBU_EVENT", "carEventInfo==" + info);
|
||||
Long last = intervalMap.get(info.getTypeCode());
|
||||
if (last == null) {
|
||||
last = 0L;
|
||||
}
|
||||
// int eventType = parseObuEvent(info.getTypeCode());
|
||||
int eventType = info.getMogoEventId();
|
||||
if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 加一个容错机制,如果已经驶过绿波车速路口,那么再收到绿波车速obu事件,就不再上报
|
||||
MogoLocation currentLocation = V2XLocationListener.getInstance().getLastCarLocation();
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLon(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
if (0 > eventAngle || eventAngle > 20) {
|
||||
Logger.e(MODULE_NAME, "超出绿波引导点范围,不处理此次事件===" + eventAngle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME||DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
|
||||
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
|
||||
// 华砺智行obu暂时去掉此判断
|
||||
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
switch (eventType) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
V2XObuEventEntity optimalEvent = new V2XObuEventEntity();
|
||||
optimalEvent.setType(ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY);
|
||||
optimalEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(optimalEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车紧急制动预警
|
||||
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
|
||||
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
messageEntity.setContent(urgencyEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
V2XServiceManager.getMogoEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SUDDENLY_BREAK, R.drawable.module_v2x_suddenly_break, "前车急刹,保持车距");
|
||||
break;
|
||||
case ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING:
|
||||
// 行人预警,给adas发送广播即可
|
||||
V2XPushMessageEntity entity = new V2XPushMessageEntity();
|
||||
// 盲区行人预警的sceneId-100003
|
||||
entity.setSceneId("100003");
|
||||
entity.setTts("前方行人,注意减速");
|
||||
entity.setExpireTime(30_000);
|
||||
entity.setAlarmContent("前方行人,注意减速");
|
||||
ADASUtils.broadcastToADAS(getContext(), entity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
V2XObuEventEntity changeLightEvent = new V2XObuEventEntity();
|
||||
changeLightEvent.setType(ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP);
|
||||
changeLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(changeLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
// 闯红灯预警
|
||||
V2XObuEventEntity rushRedLightEvent = new V2XObuEventEntity();
|
||||
rushRedLightEvent.setType(ObuConstant.TYPE_RUSH_RED_LIGHT);
|
||||
rushRedLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(rushRedLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CROSS_COLLISION_WARNING:
|
||||
// 交叉口碰撞预警
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioCrossCrash();
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
Logger.d(TAG,"未超过时限,不展示事件");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationInfoCallback( MogoObuLocationInfo locationInfo) {
|
||||
if (ObuConfig.useObuLocation) {
|
||||
MogoLocation currentLocation = new MogoLocation();
|
||||
|
||||
CoordinateConverter converter = new CoordinateConverter(getContext());
|
||||
converter.from(CoordinateConverter.CoordType.GPS);
|
||||
LatLng latLng = new LatLng(locationInfo.getLat(), locationInfo.getLon());
|
||||
converter.coord(latLng);
|
||||
LatLng convert = converter.convert();
|
||||
|
||||
currentLocation.setLatitude(convert.latitude);
|
||||
currentLocation.setLongitude(convert.longitude);
|
||||
currentLocation.setBearing(computeCarAngle(currentLocation));
|
||||
|
||||
V2XObuEventScenario.getInstance().updateLocation(currentLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrafficLightInfoCallback(MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT);
|
||||
if (trafficLightInfo == null) {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据为空===");
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
} else {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据==" + trafficLightInfo);
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT,
|
||||
DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY);
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_SHOW_TRAFFIC_LIGHT, trafficLightInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class V2XSocketManager {
|
||||
register401007();
|
||||
register401009();
|
||||
// TODO 这里是前瞻需求,量产版本需要注释
|
||||
//register401003();
|
||||
register401003();
|
||||
// TODO 旧版本的一种V2X预警形式,已经废弃了
|
||||
//register401006();
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ public class V2XPushEventVH extends V2XBaseViewHolder<V2XEventShowEntity> {
|
||||
break;
|
||||
|
||||
case "100017"://政府公告
|
||||
case "100018"://故障车辆推送
|
||||
ivRoadEventLike.setVisibility(View.VISIBLE);
|
||||
ivRoadCallChart.setVisibility(View.GONE);
|
||||
ivRoadEventNav.setVisibility(View.GONE);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.mogo.module.v2x.entity.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* author : unknown
|
||||
* desc : 路口实况返回数据
|
||||
*/
|
||||
public class V2XLiveCrossRoad extends BaseData implements Serializable {
|
||||
public V2XLiveCrossRoadEntity result;
|
||||
|
||||
public V2XLiveCrossRoadEntity getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(V2XLiveCrossRoadEntity result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "V2XLiveCrossRoad{" +
|
||||
"result=" + result +
|
||||
", code=" + code +
|
||||
", msg='" + msg + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public class V2XLiveCrossRoadEntity {
|
||||
private int cameraParentId;
|
||||
private int cameraId;
|
||||
private String url;
|
||||
private Double lat;
|
||||
private Double lon;
|
||||
private Double distance;
|
||||
|
||||
public V2XLiveCrossRoadEntity(int cameraParentId, int cameraId, String url, Double lat, Double lon, Double distance) {
|
||||
this.cameraParentId = cameraParentId;
|
||||
this.cameraId = cameraId;
|
||||
this.url = url;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public int getCameraParentId() {
|
||||
return cameraParentId;
|
||||
}
|
||||
|
||||
public void setCameraParentId(int cameraParentId) {
|
||||
this.cameraParentId = cameraParentId;
|
||||
}
|
||||
|
||||
public int getCameraId() {
|
||||
return cameraId;
|
||||
}
|
||||
|
||||
public void setCameraId(int cameraId) {
|
||||
this.cameraId = cameraId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(Double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public Double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(Double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "V2XLiveCrossRoadEntity{" +
|
||||
"cameraParentId=" + cameraParentId +
|
||||
", cameraId=" + cameraId +
|
||||
", url='" + url + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", distance=" + distance +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.module.common.entity.MarkerExploreWay
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.module.v2x.R
|
||||
import com.mogo.module.v2x.SpacesItemDecoration
|
||||
import com.mogo.module.v2x.V2XConst.MODULE_NAME
|
||||
@@ -39,6 +40,8 @@ import com.mogo.module.v2x.view.V2XEventPanelHistoryCountView
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener
|
||||
import com.mogo.service.statusmanager.StatusDescriptor
|
||||
import com.mogo.utils.logger.Logger
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -50,7 +53,7 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPresenter>(), SurroundingDetailItemListener {
|
||||
class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPresenter>(), SurroundingDetailItemListener ,IMogoStatusChangedListener{
|
||||
|
||||
private val TAG = "EventPanelFragment"
|
||||
|
||||
@@ -200,7 +203,6 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
mVpEventPanel?.setCurrentItem(1, false)
|
||||
}
|
||||
R.id.rbShareEvents -> {
|
||||
// 更改选中是否加粗
|
||||
// 更改选中是否加粗
|
||||
mRbScenarioHistory?.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
mRbSurroundingEvent?.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
@@ -245,7 +247,13 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
val y = resources.getDimensionPixelSize(R.dimen.module_v2x_event_panel_btn_y)
|
||||
V2XServiceManager.getMogoEntranceButtonController()
|
||||
.addBottomLayerView(mV2XEventPanelHistoryCountView, x, y)
|
||||
mV2XEventPanelHistoryCountView?.visibility = if (MogoApisHandler.getInstance().apis.statusManagerApi.isVrMode) {
|
||||
View.GONE
|
||||
}else{
|
||||
View.VISIBLE
|
||||
}
|
||||
changeEventCount()
|
||||
MogoApisHandler.getInstance().apis.statusManagerApi.registerStatusChangedListener(MODULE_NAME, StatusDescriptor.VR_MODE, this)
|
||||
} else {
|
||||
// 模拟手动点击,默认选择第二个,周边事件
|
||||
// http://jira.zhidaohulian.com/browse/E84XAD-250
|
||||
@@ -259,6 +267,7 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
|
||||
override fun onDestroyView() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
MogoApisHandler.getInstance().apis.statusManagerApi.unregisterStatusChangedListener(MODULE_NAME, StatusDescriptor.VR_MODE, this)
|
||||
mediator?.detach()
|
||||
// 避免内存泄漏
|
||||
fragment = null
|
||||
@@ -446,4 +455,13 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
// mV2XEventPanelHistoryCountView?.changeMsgCount(0)
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) {
|
||||
if (isTrue) {
|
||||
// 在vr模式
|
||||
mV2XEventPanelHistoryCountView?.visibility = View.GONE
|
||||
}else{
|
||||
mV2XEventPanelHistoryCountView?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,12 @@ import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.alarm.V2XAlarmServer;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.module.v2x.utils.TrackUtils;
|
||||
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -180,6 +182,10 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
|
||||
}
|
||||
}
|
||||
if (!ObuConfig.useObuLocation) {
|
||||
// 绿波车速引导刷新划线
|
||||
V2XObuEventScenario.getInstance().updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLocation getLastCarLocation() {
|
||||
|
||||
@@ -91,6 +91,7 @@ public class V2XMessageListener_401003 implements IMogoOnMessageListener<V2XPush
|
||||
case "100015"://取快递
|
||||
case "100016"://顺风车
|
||||
case "100017"://政府公告
|
||||
case "100018"://故障车辆推送
|
||||
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
|
||||
v2XMessageEntity.setContent(alarmMessage);
|
||||
v2XMessageEntity.setShowState(true);
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
@@ -21,8 +23,6 @@ import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.service.marker.IMarkerView;
|
||||
import com.mogo.module.service.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mogo.module.v2x.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerBaseView;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
|
||||
/**
|
||||
* 绿波速度引导在地图上打的marker
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class OptimalSpeedMarkerView extends MapMarkerBaseView {
|
||||
private String TAG = "OptimalSpeedMarkerView";
|
||||
|
||||
public OptimalSpeedMarkerView(Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public OptimalSpeedMarkerView(Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
}
|
||||
|
||||
public OptimalSpeedMarkerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate(R.layout.view_v2x_optimal_speed_marker, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateView( MarkerShowEntity markerShowEntity ) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,8 +5,11 @@ import android.graphics.Bitmap;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
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.R;
|
||||
import com.mogo.module.v2x.utils.ImageUtil;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -183,4 +186,39 @@ public class V2XMarkerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO 都是模拟数据
|
||||
* 获取VR道路事件
|
||||
*/
|
||||
public static Bitmap getV2XVRRoadEventViewPng(V2XPushMessageEntity alarmMessage) {
|
||||
Bitmap bitmap = ImageUtil.createBitmap(V2XUtils.getApp(),
|
||||
R.drawable.v_to_x_warning_car_orange);
|
||||
switch (alarmMessage.getSceneId()) {
|
||||
case "200001"://后方VIP车辆提示
|
||||
// bitmap = ImageUtil.createBitmap(V2XUtils.getApp(),
|
||||
// R.drawable.v2x_duixiang_laiche_che);
|
||||
break;
|
||||
case "200002"://前车急刹
|
||||
break;
|
||||
case "200003"://后方危险车辆预警
|
||||
break;
|
||||
case "200004"://逆向车辆路线预判
|
||||
// bitmap = ImageUtil.createBitmap(V2XUtils.getApp(),
|
||||
// R.drawable.v2x_duixiang_laiche_che);
|
||||
break;
|
||||
case "200005"://VIP变灯通行
|
||||
break;
|
||||
case "200006"://障碍物绕行
|
||||
break;
|
||||
case "200007"://行人预警,行人路线预测
|
||||
break;
|
||||
case "200008"://拥堵路线推荐
|
||||
break;
|
||||
case "200009"://双闪车辆,自动绕行
|
||||
break;
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCarRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
|
||||
import com.mogo.module.v2x.entity.net.V2XLivePushVoRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSeekHelpRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
|
||||
@@ -163,4 +164,12 @@ public interface V2XApiService {
|
||||
@FormUrlEncoded
|
||||
@POST("/deva/car/poi/no/manualMarkingTrafficJam")
|
||||
Observable<BaseData> manualMarkingTrafficJam(@FieldMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询路口实况
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-geo-fence-carService/car/camera/no/nextTest/v1")
|
||||
// @POST("/yycp-geo-fence-carService/car/camera/no/next/v1")
|
||||
Observable<V2XLiveCrossRoad> queryCrossRoadsLive(@FieldMap Map<String, Object> parameters);
|
||||
}
|
||||
|
||||
@@ -4,18 +4,22 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.network.RefreshBody;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCarBroadcastReq;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCarRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
|
||||
import com.mogo.module.v2x.entity.net.V2XLivePushVoRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSeekHelpRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XStrategyPushRes;
|
||||
@@ -613,4 +617,42 @@ public class V2XRefreshModel {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void queryCrossRoadsLive(V2XRefreshCallback<V2XLiveCrossRoad> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
MogoLocation lastKnowLocation = V2XServiceManager.getMapService().getSingletonLocationClient(AbsMogoApplication.getApp()).getLastKnowLocation();
|
||||
double lat = lastKnowLocation.getLatitude();
|
||||
double lon = lastKnowLocation.getLongitude();
|
||||
String tmpLat = String.valueOf(lat);
|
||||
String tmpLon = String.valueOf(lon);
|
||||
float bearing = lastKnowLocation.getBearing();
|
||||
String json = "{\"lat\":" + tmpLat + ",\"lon\":" + tmpLon + ",\"direction\":" + bearing + "}";
|
||||
map.put("sn", Utils.getSn());
|
||||
map.put("data", json);
|
||||
mV2XApiService.queryCrossRoadsLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLiveCrossRoad>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCrossRoad o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ import com.mogo.module.v2x.scenario.scene.animation.V2XAnimationScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.fatigue.V2XFatigueDrivingScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.help.V2XCarForHelpScenario;
|
||||
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.scenario.scene.ugc.V2XEventUgcScenario;
|
||||
@@ -100,6 +102,12 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING:
|
||||
mV2XScenario = V2XEventUgcScenario.getInstance();
|
||||
break;
|
||||
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消息类型未定义");
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
@@ -59,6 +60,7 @@ public class V2XAnimationWindow extends ConstraintLayout implements IV2XWindow<V
|
||||
@Override
|
||||
public void show(V2XPushMessageEntity entity) {
|
||||
Uri videoUri = null;
|
||||
String tts = null;
|
||||
switch (entity.getSceneId()) {
|
||||
// 前车紧急制动告警
|
||||
case "100005":
|
||||
@@ -67,6 +69,7 @@ public class V2XAnimationWindow extends ConstraintLayout implements IV2XWindow<V
|
||||
// 十字路口碰撞预警
|
||||
case "100006":
|
||||
videoUri = Uri.parse("android.resource://" + getContext().getPackageName() + "/raw/" + R.raw.video_left_right_car);
|
||||
tts = "注意路口车辆";
|
||||
break;
|
||||
// 岔路口碰撞预警
|
||||
case "100007":
|
||||
@@ -104,6 +107,9 @@ public class V2XAnimationWindow extends ConstraintLayout implements IV2XWindow<V
|
||||
vvCarAnimation.start();
|
||||
Logger.w(MODULE_NAME, "开始播放动画。。。。。");
|
||||
}
|
||||
if (tts != null) {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(tts);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
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;
|
||||
@@ -15,6 +16,7 @@ import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -109,6 +111,7 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().setOnActionListener(this::showDialog);
|
||||
getV2XButton().show();
|
||||
V2XServiceManager.getMogoEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP, R.drawable.module_v2x_left_notice_seek_help, "正在发起求助...");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -117,6 +120,7 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
|
||||
public void closeButton() {
|
||||
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
|
||||
Logger.d(TAG, "关闭自车求助按钮!");
|
||||
V2XServiceManager.getMogoEntranceButtonController().hideLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP);
|
||||
V2XServiceManager.getMoGoStatusManager().setSeekHelping(TAG, false);
|
||||
if (getV2XButton() != null) {
|
||||
getV2XButton().close();
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.mogo.module.v2x.scenario.scene.livecar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
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.V2XDemoManager;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.network.V2XRefreshModel;
|
||||
import com.mogo.module.v2x.utils.ToastUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.voice.V2XVoiceConstants.COMMAND_ZHIDAO_V2X_AHEAD_LIVE;
|
||||
import static com.mogo.module.v2x.voice.V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP;
|
||||
import static com.mogo.module.v2x.voice.V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CROSSROADS_LIVE;
|
||||
import static com.mogo.module.v2x.voice.V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP;
|
||||
import static com.mogo.service.statusmanager.StatusDescriptor.MAIN_PAGE_RESUME;
|
||||
|
||||
/**
|
||||
* author : unknown
|
||||
* desc : TODO 演示使用的语音呼叫查看直播车辆 或者 路口实况 业务模块
|
||||
*/
|
||||
public class V2XVoiceCallLiveBiz {
|
||||
|
||||
private static final String REGISTER_LIFECYCLE_TAG = V2XVoiceCallLiveBiz.class.getSimpleName();
|
||||
|
||||
private V2XVoiceCallLiveBiz() {
|
||||
|
||||
}
|
||||
|
||||
private static volatile V2XVoiceCallLiveBiz mV2XVoiceCallLiveBiz;
|
||||
|
||||
public static V2XVoiceCallLiveBiz getInstance() {
|
||||
if (mV2XVoiceCallLiveBiz == null) {
|
||||
synchronized (V2XVoiceCallLiveBiz.class) {
|
||||
if (mV2XVoiceCallLiveBiz == null) {
|
||||
mV2XVoiceCallLiveBiz = new V2XVoiceCallLiveBiz();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mV2XVoiceCallLiveBiz;
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
||||
//语音词指令 查看前车视频回调
|
||||
private V2XVoiceCallbackListener v2XVoiceCallbackFrontLiveCarListener = (command, intent) -> {
|
||||
Logger.d(MODULE_NAME, "语音词指令 查看前车视频回调");
|
||||
getFrontCarLive();
|
||||
};
|
||||
|
||||
//语音词指令 查看路口实况回调
|
||||
private V2XVoiceCallbackListener v2XVoiceCallbackOpenRoadCameraListener = (command, intent) -> {
|
||||
Logger.d(MODULE_NAME, "语音词指令 查看路口实况回调");
|
||||
AIAssist.getInstance(mContext).speakTTSVoice(mContext.getString(R.string.v2x_voice_see_crossroad_live));
|
||||
getOpenRoadCameraLive();
|
||||
};
|
||||
|
||||
public void init(Context context) {
|
||||
Logger.d(MODULE_NAME, "init");
|
||||
this.mContext = context;
|
||||
registerLifecycleChange();
|
||||
registerVoice();
|
||||
}
|
||||
|
||||
private void registerLifecycleChange() {
|
||||
V2XServiceManager.getMoGoStatusManager().registerStatusChangedListener(REGISTER_LIFECYCLE_TAG, MAIN_PAGE_RESUME, (descriptor, isTrue) -> {
|
||||
if (descriptor == StatusDescriptor.MAIN_PAGE_RESUME) {
|
||||
if (isTrue) {
|
||||
registerVoice();
|
||||
} else {
|
||||
unRegisterVoice();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerVoice() {
|
||||
V2XVoiceManager.INSTANCE.registerUnWakeVoice(COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP, v2XVoiceCallbackFrontLiveCarListener)
|
||||
.registerUnWakeVoice(COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP, v2XVoiceCallbackOpenRoadCameraListener)
|
||||
.registerWakeCmd(COMMAND_ZHIDAO_V2X_AHEAD_LIVE, v2XVoiceCallbackFrontLiveCarListener)
|
||||
.registerWakeCmd(COMMAND_ZHIDAO_V2X_CROSSROADS_LIVE, v2XVoiceCallbackOpenRoadCameraListener);
|
||||
}
|
||||
|
||||
private void unRegisterVoice() {
|
||||
V2XVoiceManager.INSTANCE.unRegisterUnWakeVoice(COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP)
|
||||
.unRegisterUnWakeVoice(COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP)
|
||||
.unRegisterWakeCmd(COMMAND_ZHIDAO_V2X_AHEAD_LIVE).unRegisterWakeCmd(COMMAND_ZHIDAO_V2X_CROSSROADS_LIVE);
|
||||
}
|
||||
|
||||
public void getFrontCarLive() {
|
||||
V2XDemoUserInfoRes.ResultBean.UserListBean.UserInfoBean userInfoBean = V2XDemoManager.getInstance().getV2XDemoUserInfoEntity1().getUserInfo();
|
||||
String liveCarSn = userInfoBean.getSn();
|
||||
if (TextUtils.isEmpty(liveCarSn)) {
|
||||
ToastUtils.showShort("附近没有可直播车机");
|
||||
Logger.d(MODULE_NAME, "getFrontCarLive : sn is null");
|
||||
return;
|
||||
}
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(liveCarSn, null);
|
||||
V2XVoiceCallLiveScenario.getInstance().setV2XWindow(new V2XVoiceCallLiveCarWindow());
|
||||
V2XVoiceCallLiveScenario.getInstance().init(v2XMessageEntity);
|
||||
}
|
||||
|
||||
public void getOpenRoadCameraLive() {
|
||||
// String liveUrl = "rtmp://154.8.189.110:19350/live/10_1";
|
||||
// V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, liveUrl);
|
||||
// V2XVoiceCallLiveScenario.getInstance().setV2XWindow(new V2XVoiceCrossRoadLiveWindow());
|
||||
// V2XVoiceCallLiveScenario.getInstance().init(v2XMessageEntity);
|
||||
V2XRefreshModel.getInstance(mContext).queryCrossRoadsLive(new V2XRefreshCallback<V2XLiveCrossRoad>() {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCrossRoad result) {
|
||||
if (result != null && result.getResult().getUrl() != null) {
|
||||
String liveUrl = result.getResult().getUrl();
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, liveUrl);
|
||||
V2XVoiceCallLiveScenario.getInstance().setV2XWindow(new V2XVoiceCrossRoadLiveWindow());
|
||||
V2XVoiceCallLiveScenario.getInstance().init(v2XMessageEntity);
|
||||
} else {
|
||||
Logger.d(MODULE_NAME, "getOpenRoadCameraLive 路口实况直播地址为空");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
Logger.d(MODULE_NAME, "getOpenRoadCameraLive : " + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private V2XMessageEntity<V2XPushMessageEntity> buildCallLiveParams(String sn, String liveUrl) {
|
||||
V2XPushMessageEntity v2XPushMessageEntity = new V2XPushMessageEntity();
|
||||
v2XPushMessageEntity.setVideoSn(sn);
|
||||
v2XPushMessageEntity.setVideoUrl(liveUrl);
|
||||
v2XPushMessageEntity.setShowWindow(true);
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = new V2XMessageEntity<>();
|
||||
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW);
|
||||
v2XMessageEntity.setContent(v2XPushMessageEntity);
|
||||
v2XMessageEntity.setShowState(true);
|
||||
return v2XMessageEntity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.mogo.module.v2x.scenario.scene.livecar;
|
||||
|
||||
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.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerCarInfo;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.module.v2x.view.V2XCarLiveVideoView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
public class V2XVoiceCallLiveCarWindow extends RelativeLayout
|
||||
implements IV2XWindow<V2XPushMessageEntity> {
|
||||
|
||||
private V2XCarLiveVideoView mV2XCarLiveVideoView;
|
||||
private TextView tvCountDown;
|
||||
private ImageView ivVideoPlayingSign;
|
||||
private boolean isVideoPlay = false;
|
||||
|
||||
// 处理道路事件,30秒倒计时
|
||||
private Handler handlerV2XEvent = new Handler();
|
||||
private Runnable runnableV2XEvent;
|
||||
private static final int COUNT_DOWN_TIMER = 1_000;
|
||||
private static final int ALL_EXPIRE_TIMER = 1_000 * 30;
|
||||
private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
|
||||
public V2XVoiceCallLiveCarWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
Logger.d(MODULE_NAME, "V2XVoiceCallLiveCarWindow INIT");
|
||||
}
|
||||
|
||||
public V2XVoiceCallLiveCarWindow(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public V2XVoiceCallLiveCarWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "V2X===初始化语音呼叫直播视图");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_see_carlive_video, this);
|
||||
mV2XCarLiveVideoView = findViewById(R.id.videoPlayer);
|
||||
tvCountDown = findViewById(R.id.tvCountDown);
|
||||
ivVideoPlayingSign = findViewById(R.id.ivVideoPlayingSign);
|
||||
mV2XCarLiveVideoView.addOnVideoStatusChangeListener(videoPlaying -> {
|
||||
isVideoPlay = videoPlaying;
|
||||
if (isVideoPlay) {
|
||||
startCountDown();
|
||||
} else {
|
||||
stopCountDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(V2XPushMessageEntity entity) {
|
||||
if (entity != null) {
|
||||
Logger.w(MODULE_NAME, "更新直播信息。。。。。" + entity);
|
||||
// 启动播放
|
||||
MarkerCarInfo.CarLiveInfo carLiveInfo = new MarkerCarInfo.CarLiveInfo();
|
||||
carLiveInfo.setVideoChannel(entity.getVideoChannel());
|
||||
carLiveInfo.setVideoSn(entity.getVideoSn());
|
||||
carLiveInfo.setVideoUrl(entity.getVideoUrl());
|
||||
Logger.w(MODULE_NAME, "更新直播信息 END");
|
||||
mV2XCarLiveVideoView.setCarLiveInfo(carLiveInfo);
|
||||
if (isVideoPlay) {
|
||||
startCountDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// 停止倒计时
|
||||
stopCountDown();
|
||||
if (V2XServiceManager
|
||||
.getMogoTopViewManager().isViewAdded(this)) {
|
||||
//移除窗体
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.removeView(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 窗体倒计时
|
||||
*/
|
||||
private void startCountDown() {
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时开始,当前 :" + EXPIRE_TIMER / COUNT_DOWN_TIMER + " 秒");
|
||||
tvCountDown.setVisibility(View.VISIBLE);
|
||||
ivVideoPlayingSign.setVisibility(View.VISIBLE);
|
||||
tvCountDown.setText(String.valueOf(EXPIRE_TIMER / COUNT_DOWN_TIMER));
|
||||
if (EXPIRE_TIMER > 0) {
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
}
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 展示开始倒计时");
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
}
|
||||
|
||||
private void stopCountDown() {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 倒计时停止。。。");
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
tvCountDown.setVisibility(View.GONE);
|
||||
ivVideoPlayingSign.setVisibility(View.GONE);
|
||||
EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.mogo.module.v2x.scenario.scene.livecar;
|
||||
|
||||
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.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : unknown
|
||||
* desc : TODO 演示使用的语音呼叫查看直播场景,包括车辆直播 或者 路口实况 window,区分不同页面window逻辑实现
|
||||
*/
|
||||
public class V2XVoiceCallLiveScenario extends AbsV2XScenario<V2XPushMessageEntity> implements IMogoTopViewStatusListener {
|
||||
|
||||
private V2XVoiceCallLiveScenario() {
|
||||
|
||||
}
|
||||
|
||||
private static volatile V2XVoiceCallLiveScenario mV2XVoiceCallLiveCarScenario;
|
||||
|
||||
public static V2XVoiceCallLiveScenario getInstance() {
|
||||
if (mV2XVoiceCallLiveCarScenario == null) {
|
||||
synchronized (V2XVoiceCallLiveScenario.class) {
|
||||
if (mV2XVoiceCallLiveCarScenario == null) {
|
||||
mV2XVoiceCallLiveCarScenario = new V2XVoiceCallLiveScenario();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mV2XVoiceCallLiveCarScenario;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
|
||||
if (v2XMessageEntity == null) {
|
||||
TipToast.shortTip("附近没有可直播车机");
|
||||
}
|
||||
if (v2XMessageEntity.isShowState()) {
|
||||
if (!isSameScenario(v2XMessageEntity)
|
||||
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
Logger.d(V2XConst.MODULE_NAME, "v2XMessageEntity : " + v2XMessageEntity + " getVideoSn : " + v2XMessageEntity.getContent().getVideoSn());
|
||||
if (v2XMessageEntity != null) {
|
||||
Logger.d(V2XConst.MODULE_NAME, "准备展示直播窗口");
|
||||
show();
|
||||
} else {
|
||||
TipToast.shortTip("附近没有可直播车机");
|
||||
Logger.e(V2XConst.MODULE_NAME, "直播地址为null");
|
||||
}
|
||||
} else {
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
|
||||
}
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
showWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_window_width),
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_event_see_live_window_height));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().close();
|
||||
}
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
Logger.d(MODULE_NAME, "展示 Window 动画结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
Logger.d(MODULE_NAME, "关闭 Window 动画结束");
|
||||
getV2XWindow().close();
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
Logger.d(MODULE_NAME, "展示 Window 开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
Logger.d(MODULE_NAME, "关闭 Window 开始");
|
||||
setV2XMessageEntity(null);
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.mogo.module.v2x.scenario.scene.livecar;
|
||||
|
||||
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.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerCarInfo;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.module.v2x.view.V2XCrossRoadVideoView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
public class V2XVoiceCrossRoadLiveWindow extends RelativeLayout
|
||||
implements IV2XWindow<V2XPushMessageEntity> {
|
||||
|
||||
private V2XCrossRoadVideoView mV2XCrossRoadVideoView;
|
||||
private TextView tvCountDown;
|
||||
private ImageView ivVideoPlayingSign;
|
||||
private boolean isVideoPlay = false;
|
||||
|
||||
// 处理道路事件,30秒倒计时
|
||||
private Handler handlerV2XEvent = new Handler();
|
||||
private Runnable runnableV2XEvent;
|
||||
private static final int COUNT_DOWN_TIMER = 1_000;
|
||||
private static final int ALL_EXPIRE_TIMER = 1_000 * 30;
|
||||
private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
|
||||
public V2XVoiceCrossRoadLiveWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
Logger.d(MODULE_NAME, "V2XVoiceCallLiveCarWindow INIT");
|
||||
}
|
||||
|
||||
public V2XVoiceCrossRoadLiveWindow(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public V2XVoiceCrossRoadLiveWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "V2X===初始化语音呼叫直播视图");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_see_crossroadlive_video, this);
|
||||
mV2XCrossRoadVideoView = findViewById(R.id.videoPlayer);
|
||||
tvCountDown = findViewById(R.id.tvCountDown);
|
||||
ivVideoPlayingSign = findViewById(R.id.ivVideoPlayingSign);
|
||||
mV2XCrossRoadVideoView.addOnVideoStatusChangeListener(videoPlaying -> {
|
||||
isVideoPlay = videoPlaying;
|
||||
if (isVideoPlay) {
|
||||
startCountDown();
|
||||
} else {
|
||||
stopCountDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(V2XPushMessageEntity entity) {
|
||||
if (entity != null) {
|
||||
Logger.w(MODULE_NAME, "更新直播信息。。。。。" + entity);
|
||||
// 启动播放
|
||||
MarkerCarInfo.CarLiveInfo carLiveInfo = new MarkerCarInfo.CarLiveInfo();
|
||||
carLiveInfo.setVideoChannel(entity.getVideoChannel());
|
||||
carLiveInfo.setVideoSn(entity.getVideoSn());
|
||||
carLiveInfo.setVideoUrl(entity.getVideoUrl());
|
||||
Logger.w(MODULE_NAME, "更新直播信息 END");
|
||||
mV2XCrossRoadVideoView.setCarLiveInfo(carLiveInfo);
|
||||
if (isVideoPlay) {
|
||||
startCountDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// 停止倒计时
|
||||
stopCountDown();
|
||||
if (V2XServiceManager
|
||||
.getMogoTopViewManager().isViewAdded(this)) {
|
||||
//移除窗体
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.removeView(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 窗体倒计时
|
||||
*/
|
||||
private void startCountDown() {
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时开始,当前 :" + EXPIRE_TIMER / COUNT_DOWN_TIMER + " 秒");
|
||||
tvCountDown.setVisibility(View.VISIBLE);
|
||||
ivVideoPlayingSign.setVisibility(View.VISIBLE);
|
||||
tvCountDown.setText(String.valueOf(EXPIRE_TIMER / COUNT_DOWN_TIMER));
|
||||
if (EXPIRE_TIMER > 0) {
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
} else {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
|
||||
// 移出Window详细信息
|
||||
close();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
}
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 展示开始倒计时");
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
}
|
||||
|
||||
private void stopCountDown() {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 倒计时停止。。。");
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
tvCountDown.setVisibility(View.GONE);
|
||||
ivVideoPlayingSign.setVisibility(View.GONE);
|
||||
EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
|
||||
/**
|
||||
* 绿波车速的marker
|
||||
*/
|
||||
class OptimalSpeedMarker implements IV2XMarker<MogoLatLng> {
|
||||
|
||||
private IMogoMarker optimalMarker = null;
|
||||
|
||||
@Override
|
||||
public void drawPOI(MogoLatLng entity) {
|
||||
Logger.d(MODULE_NAME, "绘制绿波marker===" + entity);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(entity.getLat())
|
||||
.longitude(entity.getLon()).anchor(0.5f,0.9f).icon(ViewUtils.fromView(new OptimalSpeedMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_OPTIMAL_SPEED_MARKER, optionsRipple);
|
||||
optimalMarker.setClickable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
Logger.d(MODULE_NAME,"准备清除绿波marker");
|
||||
if (optimalMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除绿波marker===" + optimalMarker);
|
||||
optimalMarker.remove();
|
||||
optimalMarker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.v2x.V2XObuManager;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu场景界面管理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventScenario extends AbsV2XScenario<V2XObuEventEntity> implements Handler.Callback {
|
||||
|
||||
public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹,注意保持安全距离!";
|
||||
private static final int MSG_CLOSE_OBU_WINDOW = 1001;
|
||||
private static final int DEFAULT_EXPIRE_TIME = 20_000;
|
||||
|
||||
private static final float DEFAULT_VIP_CROSSING_DISTANCE = 100F;
|
||||
|
||||
/**
|
||||
* 可以关闭绿波引导的距离路口的最大距离,单位是米
|
||||
*/
|
||||
private static final float DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL = 10F;
|
||||
|
||||
private IMogoPolyline optimalLine = null;
|
||||
private MogoLatLng defaultTarget = new MogoLatLng(39.969326, 116.407788);
|
||||
|
||||
private MogoLatLng optimalCrossing = new MogoLatLng(40.196431,116.738011);
|
||||
// private MogoLatLng vipCrossing = new MogoLatLng(40.200467,116.745498);
|
||||
|
||||
|
||||
private MogoLatLng vipCrossing1 = new MogoLatLng(40.200467,116.745498);
|
||||
private MogoLatLng vipCrossing2 = new MogoLatLng(40.200491,116.738535);
|
||||
private List<MogoLatLng> vipCrossingList = Arrays.asList(vipCrossing1, vipCrossing2);
|
||||
|
||||
private V2XObuEventScenario() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuEventScenario instance = null;
|
||||
|
||||
public static V2XObuEventScenario getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuEventScenario.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuEventScenario();
|
||||
instance.setV2XWindow(new V2XObuEventWindow(V2XServiceManager.getContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private V2XMessageEntity<V2XObuEventEntity> lastMessage = null;
|
||||
|
||||
private OptimalSpeedMarker optimalSpeedMarker = null;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper(), this);
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XObuEventEntity> v2XMessageEntity) {
|
||||
Logger.d(MODULE_NAME, "obu场景初始化: " + v2XMessageEntity);
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 如果需要区分路口,就在这里做一下判断,给默认目标点赋值
|
||||
defaultTarget = optimalCrossing;
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
// vip变灯提醒
|
||||
isInChangeLightForVip = true;
|
||||
V2XObuManager.getInstance().onTrafficLightInfoCallback(null);
|
||||
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
}
|
||||
show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示场景
|
||||
* <p>
|
||||
* 此场景需要语音提示和弹窗
|
||||
*/
|
||||
@Override
|
||||
public void show() {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(getV2XMessageEntity().getContent().getDesc());
|
||||
showWindow();
|
||||
if (handler.hasMessages(MSG_CLOSE_OBU_WINDOW)) {
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(MSG_CLOSE_OBU_WINDOW, DEFAULT_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示Window
|
||||
*/
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "上一条消息是绿波,发送隐藏广播===");
|
||||
// 上一条信息是绿波,需要隐藏上一条信息
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
}
|
||||
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"上一条是vip变灯,需要先把线隐藏===");
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = getV2XMessageEntity();
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
getV2XWindow().setWindowStatusListener(new V2XWindowStatusListener() {
|
||||
@Override
|
||||
public void onViewShow() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewClose() {
|
||||
// 只在上滑关闭topview的时候回调
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗,隐藏line");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
});
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
// 给adas发送显示绿波的广播
|
||||
Logger.d(MODULE_NAME, "收到绿波时间,发送广播给adas");
|
||||
sendBroadcastToAdas(CALL_ADAS_SHOW_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"收到vip变灯,画线");
|
||||
drawLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Window
|
||||
*/
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
Logger.d(MODULE_NAME, "obu场景关闭window");
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
getV2XWindow().close();
|
||||
// 给adas发送隐藏绿波的广播
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示按钮
|
||||
*/
|
||||
@Override
|
||||
public void showButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭按钮
|
||||
*/
|
||||
@Override
|
||||
public void closeButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制POI
|
||||
*/
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "绘制obu Poi点");
|
||||
optimalSpeedMarker.drawPOI(defaultTarget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除POI
|
||||
*/
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除obu Poi点");
|
||||
optimalSpeedMarker.clearPOI();
|
||||
optimalSpeedMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当定位发生变化时,调用此方法,在此方法中,根据当前状态判断是否需要消费此定位事件
|
||||
* <p>
|
||||
* 主要目的是更新绿波速度引导的划线
|
||||
*
|
||||
* @param currentLocation 更新后的定位信息
|
||||
*/
|
||||
public void updateLocation(MogoLocation currentLocation) {
|
||||
MogoLatLng currentLatLng = new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
if (optimalLine != null) {
|
||||
float distance = Utils.calculateLineDistance(defaultTarget, currentLatLng);
|
||||
if (distance <= DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL) {
|
||||
// 目标点和自身点小于DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL的时候,隐藏绿波车速
|
||||
closeWindow();
|
||||
} else {
|
||||
// 线不为空就更新位置,线为空了,也就隐藏了
|
||||
optimalLine.setPoints(Arrays.asList(currentLatLng, defaultTarget));
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前位置与vip点的距离,来判断是否触发vip通行
|
||||
for (MogoLatLng crossing : vipCrossingList) {
|
||||
float distance = Utils.calculateLineDistance(currentLatLng, crossing);
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
crossing.getLon(),
|
||||
crossing.getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
Logger.d("V2X_OBU_VIP", "监测是否需要进行vip弹框提醒\ndistance: " + distance + "\neventAngle: " + eventAngle + "\ntarget: " + crossing + "\ncurrent: " + currentLatLng);
|
||||
if (distance <= DEFAULT_VIP_CROSSING_DISTANCE && 0 <= eventAngle && eventAngle <= 20) {
|
||||
//距离小于DEFAULT_VIP_CROSSING_DISTANCE,且夹角在0~20(说明在前方),则触发vip通行
|
||||
defaultTarget = crossing;
|
||||
handler.post(() -> {
|
||||
MogoObuEventInfo eventInfo = new MogoObuEventInfo();
|
||||
eventInfo.setType("vip变灯提醒");
|
||||
eventInfo.setTypeCode("vip变灯提醒");
|
||||
eventInfo.setDescribe("将为您变灯,vip车辆可优先通行");
|
||||
V2XObuManager.getInstance().onEventInfoCallback(eventInfo);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg A {@link Message Message} object
|
||||
* @return True if no further handling is desired
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_CLOSE_OBU_WINDOW) {
|
||||
Logger.d(MODULE_NAME, "V2X Obu scenario expire===");
|
||||
closeWindow();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final String ACTION_LAUNCHER_ADAS_APP_BIZ = "com.mogo.launcher.adas.app.biz";
|
||||
private static final String CALL_ADAS_SHOW_OPTIMAL = "2";
|
||||
private static final String CALL_ADAS_HIDE_OPTIMAL = "1";
|
||||
|
||||
private void sendBroadcastToAdas(String status) {
|
||||
if (status.equals(CALL_ADAS_SHOW_OPTIMAL)) {
|
||||
// 给adas发送显示绿波的广播,同时自己也要开始划线
|
||||
if(DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
drawLine();
|
||||
}
|
||||
} else {
|
||||
// 给adas发送隐藏绿波的广播,同时自己也需要结束划线动画
|
||||
hideLine();
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("action", status);
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送绿波广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 1);
|
||||
V2XServiceManager.getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送绿波广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLatLng getOptimalCrossing(){
|
||||
return optimalCrossing;
|
||||
}
|
||||
public float cacheZoomLevel = 16f;
|
||||
/**
|
||||
* 开始划线,同时添加marker,调整地图比例尺
|
||||
*/
|
||||
private void drawLine() {
|
||||
Logger.d(MODULE_NAME, "绘制绿波车速的线=====");
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
}
|
||||
// 绘制marker
|
||||
drawPOI();
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(16).useGradient(true).colorValues(Arrays.asList(Color.parseColor("#FF1DAAA5"), Color.parseColor("#3337DED9")));
|
||||
|
||||
// 当前车辆位置
|
||||
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (carLocation != null) {
|
||||
options.add(carLocation);
|
||||
} else {
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
}
|
||||
// 目标车辆位置
|
||||
options.add(defaultTarget);
|
||||
|
||||
// 绘制线的对象
|
||||
optimalLine = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
cacheZoomLevel = V2XServiceManager.getMapUIController().getZoomLevel();
|
||||
Logger.d(MODULE_NAME, "V2xObuEventScenario cacheZoomLevel==" + cacheZoomLevel);
|
||||
V2XServiceManager.getMapUIController().changeZoom(16);
|
||||
// V2XServiceManager.getMapUIController().changeZoom(17);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束划线,同时隐藏marker
|
||||
*/
|
||||
private void hideLine() {
|
||||
Logger.d(MODULE_NAME, "隐藏绿波车速的线====");
|
||||
clearPOI();
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
optimalLine = null;
|
||||
}
|
||||
V2XServiceManager.getMapUIController().changeZoom(cacheZoomLevel);
|
||||
}
|
||||
|
||||
private volatile boolean isInChangeLightForVip = false;
|
||||
|
||||
/**
|
||||
* 是否在显示vip通行
|
||||
* @return true - 在显示vip通行
|
||||
*/
|
||||
public boolean isInChangeLightForVip(){
|
||||
return isInChangeLightForVip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu事件window
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuEventEntity> {
|
||||
public V2XObuEventWindow(@NonNull Context context) {
|
||||
this(context,null);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs,0);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private ImageView ivTypeIcon;
|
||||
private TextView tvType, tvDesc;
|
||||
|
||||
private void initView(Context context){
|
||||
Logger.d(MODULE_NAME,"初始化obu场景view");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_simple_obu_event_detail, this);
|
||||
ivTypeIcon = findViewById(R.id.ivObuTypeIcon);
|
||||
tvType = findViewById(R.id.tvObuType);
|
||||
tvDesc = findViewById(R.id.tvObuDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示1/2窗口
|
||||
*
|
||||
* 目前只处理如下obu事件
|
||||
* 绿波车速: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_OPTIMAL_SPEED_ADVISORY}
|
||||
* 前车急刹: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_URGENCY_COLLISION_WARNING}
|
||||
* vip车辆变灯提示(暂无回调,暂不处理)
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void show(V2XObuEventEntity entity) {
|
||||
Logger.d(MODULE_NAME, "ObuEventWindow show " + entity);
|
||||
switch (entity.getType()) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_optimal_speed);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("车速引导");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车急刹预警
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_urgency_collision);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("前车急刹");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_traffic_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("优先通行");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_rush_red_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("红灯警告");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
default:
|
||||
Logger.w(MODULE_NAME, "其他obu类型,暂不处理: " + entity.getType());
|
||||
break;
|
||||
}
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 210);
|
||||
V2XServiceManager.getMogoTopViewManager().addView(this, params,topViewStatusListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭1/2窗口
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
V2XServiceManager.getMogoTopViewManager().removeView(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回窗体
|
||||
*
|
||||
* @return 当前窗体
|
||||
*/
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private V2XWindowStatusListener statusListener = null;
|
||||
|
||||
/**
|
||||
* 设置Window状态监听
|
||||
*
|
||||
* @param listener 监听器
|
||||
*/
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
statusListener = listener;
|
||||
}
|
||||
|
||||
private IMogoTopViewStatusListener topViewStatusListener = new IMogoTopViewStatusListener() {
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
if (statusListener != null) {
|
||||
statusListener.onViewClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
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;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
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> {
|
||||
private final String TAG = "V2XPushVREventMarker";
|
||||
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
private static IMogoMarker mAlarmInfoMarker;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XPushMessageEntity entity) {
|
||||
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "drawPOI 绘制VR Marker");
|
||||
|
||||
try {
|
||||
// 清除道路事件
|
||||
V2XServiceManager
|
||||
.getMoGoV2XMarkerManager().clearALLPOI();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制推荐引导线
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
void drawableRecommendPolyline(V2XPushMessageEntity entity) {
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0xFFF95959);
|
||||
colors.add(0xFF942B48);
|
||||
colors.add(0xFFCB253A);
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(15).useGradient(true).color(0xFFEF3A3A);
|
||||
|
||||
for (double[] doubles : entity.getRecommendPolyline()) {
|
||||
options.add(doubles[0], doubles[1]);
|
||||
}
|
||||
|
||||
// 绘制线的对象
|
||||
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
|
||||
MarkerUtils.resetMapZoom(16);
|
||||
// 移除线
|
||||
clearLine();
|
||||
// 移除事件POI
|
||||
clearAlarmPOI();
|
||||
// 绘制上次的数据
|
||||
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
|
||||
}
|
||||
|
||||
void clearAlarmPOI() {
|
||||
if (mAlarmInfoMarker != null) {
|
||||
mAlarmInfoMarker.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 String TAG = "V2XPushVREventWindow";
|
||||
|
||||
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());
|
||||
mV2XPushEventScenario.setV2XWindow(new V2XPushVREventWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
return mV2XPushEventScenario;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
|
||||
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR场景:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
|
||||
if (!isSameScenario(v2XMessageEntity)
|
||||
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
show();
|
||||
} else {
|
||||
closeWindow();
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
show();
|
||||
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "要处理的场景已经存在,丢弃这次初始化");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
speakTTSVoice(getV2XMessageEntity().getContent().getTts(), null);
|
||||
drawPOI();
|
||||
showWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (getV2XWindow() != null) {
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@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(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 动画结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 动画结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 开始");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 开始");
|
||||
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
|
||||
// 重置场景提示的消息
|
||||
setV2XMessageEntity(null);
|
||||
clearPOI();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mogo.module.v2x.scenario.scene.pushVR;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/14 2:37 PM
|
||||
* desc :
|
||||
* TODO 只有VR演示场景使用
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
|
||||
private String TAG = "V2XPushVREventWindow";
|
||||
|
||||
// 处理道路事件,30秒倒计时
|
||||
private Handler handlerV2XEvent = new Handler();
|
||||
private Runnable runnableV2XEvent;
|
||||
private int mExpireTime = 30000;
|
||||
|
||||
/**
|
||||
* 展示道路事件详情Windows
|
||||
*/
|
||||
@Override
|
||||
public void show(V2XPushMessageEntity entity) {
|
||||
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息:展示 Window=\n" + entity);
|
||||
|
||||
V2XServiceManager
|
||||
.getMogoEntranceButtonController()
|
||||
.showLeftNoticeByType(
|
||||
IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED,
|
||||
R.drawable.module_v2x_left_notice_seek_help,
|
||||
entity.getAlarmContent());
|
||||
//countDownV2XEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭详情展示框
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=关闭Window");
|
||||
V2XServiceManager
|
||||
.getMogoEntranceButtonController()
|
||||
.hideLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED);
|
||||
|
||||
// 停止倒计时
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 窗体倒计时
|
||||
*/
|
||||
public void countDownV2XEvent() {
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=30秒倒计时结束。。。");
|
||||
// 移出Window详细信息
|
||||
close();
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
}
|
||||
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息 Window 展示开始倒计时:" + mExpireTime);
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, mExpireTime);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
|
||||
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.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private LinearLayout mFlTestPanel;
|
||||
private FlexboxLayout flTestPanelShunNormal;
|
||||
private FlexboxLayout flTestPanelShunYi;
|
||||
private FlexboxLayout flTestPanelVR;
|
||||
private Button mBtnTriggerOpen;
|
||||
private Button mBtnTriggerRoadEvent;
|
||||
private Button mBtnClearRoadEvent;
|
||||
@@ -56,6 +57,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private Button mBtnTriggerEventUgc;
|
||||
private Button mBtnTriggerTrafficSearch;
|
||||
|
||||
private Button btnTriggerRearVIPCarTip,
|
||||
btnTriggerVehicleBrakes,
|
||||
btnTriggerRearDangerousVehicles,
|
||||
btnTriggerReverseVehicleRoutePrediction,
|
||||
btnTriggerVIPLightChange,
|
||||
btnTriggerObstacleDetour,
|
||||
btnTriggerPedestrianWarning,
|
||||
btnTriggerCongestedRouteRecommendation,
|
||||
btnTriggerDoubleFlash;
|
||||
|
||||
public static V2XTestConsoleWindow getInstance(Context context, int showType) {
|
||||
if (mV2XTestConsoleWindow == null) {
|
||||
synchronized (V2XTestConsoleWindow.class) {
|
||||
@@ -91,6 +102,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
mFlTestPanel = findViewById(R.id.flTestPanel);
|
||||
flTestPanelShunNormal = findViewById(R.id.flTestPanelShunNormal);
|
||||
flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi);
|
||||
flTestPanelVR = findViewById(R.id.flTestPanelVR);
|
||||
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
|
||||
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
|
||||
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
|
||||
@@ -118,6 +130,35 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
}
|
||||
|
||||
|
||||
btnTriggerRearVIPCarTip = findViewById(R.id.btnTriggerRearVIPCarTip);
|
||||
btnTriggerVehicleBrakes = findViewById(R.id.btnTriggerVehicleBrakes);
|
||||
btnTriggerRearDangerousVehicles = findViewById(R.id.btnTriggerRearDangerousVehicles);
|
||||
btnTriggerReverseVehicleRoutePrediction = findViewById(R.id.btnTriggerReverseVehicleRoutePrediction);
|
||||
btnTriggerVIPLightChange = findViewById(R.id.btnTriggerVIPLightChange);
|
||||
btnTriggerObstacleDetour = findViewById(R.id.btnTriggerObstacleDetour);
|
||||
btnTriggerPedestrianWarning = findViewById(R.id.btnTriggerPedestrianWarning);
|
||||
btnTriggerCongestedRouteRecommendation = findViewById(R.id.btnTriggerCongestedRouteRecommendation);
|
||||
btnTriggerDoubleFlash = findViewById(R.id.btnTriggerDoubleFlash);
|
||||
|
||||
|
||||
switch (showType) {
|
||||
case 0:
|
||||
flTestPanelShunNormal.setVisibility(View.VISIBLE);
|
||||
flTestPanelShunYi.setVisibility(View.VISIBLE);
|
||||
flTestPanelVR.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 1:
|
||||
flTestPanelShunNormal.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 2:
|
||||
flTestPanelShunYi.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 3:
|
||||
flTestPanelVR.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
mBtnTriggerCallUserInfo.setOnClickListener(v -> {
|
||||
MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
|
||||
mogoDriverInfo.setAge(24);
|
||||
@@ -219,6 +260,78 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
});
|
||||
|
||||
mBtnTriggerTrafficSearch.setOnClickListener(v-> V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus());
|
||||
|
||||
|
||||
/*
|
||||
*后方VIP车辆提示
|
||||
* */
|
||||
btnTriggerRearVIPCarTip.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
/*
|
||||
*前车急刹
|
||||
* */
|
||||
btnTriggerVehicleBrakes.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
/*
|
||||
*后方危险车辆预警
|
||||
* */
|
||||
btnTriggerRearDangerousVehicles.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
* 逆向车辆路线预判
|
||||
* */
|
||||
btnTriggerReverseVehicleRoutePrediction.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarionVRReverseCarData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
});
|
||||
|
||||
/*
|
||||
*VIP变灯通行
|
||||
* */
|
||||
btnTriggerVIPLightChange.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
*障碍物绕行
|
||||
* */
|
||||
btnTriggerObstacleDetour.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
*行人预警,行人路线预测
|
||||
* */
|
||||
btnTriggerPedestrianWarning.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
*拥堵路线推荐
|
||||
* */
|
||||
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);
|
||||
});
|
||||
|
||||
/*
|
||||
*双闪车辆,自动绕行
|
||||
* */
|
||||
btnTriggerDoubleFlash.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,4 +75,16 @@ public class ImageUtil {
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Bitmap createBitmap(Context context, int resId) {
|
||||
if (resId != 0) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
BitmapFactory.decodeResource(context.getResources(), resId, opts);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId, opts);
|
||||
return bitmap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.v2x.utils;
|
||||
|
||||
/**
|
||||
* obu相关设置项
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class ObuConfig {
|
||||
/**
|
||||
* 设置是否使用obu定位信息
|
||||
*
|
||||
* 此定位信息目前只用于obu计算绿波车速引导和vip变灯提醒
|
||||
*/
|
||||
public static boolean useObuLocation = false;
|
||||
}
|
||||
@@ -223,6 +223,39 @@ public class TestOnLineCarUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟H5推送场景--十字路口碰撞
|
||||
*/
|
||||
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioCrossCrash() {
|
||||
try {
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_push_cross_crash);
|
||||
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_ANIMATION_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟 疲劳驾驶
|
||||
*/
|
||||
@@ -290,4 +323,104 @@ public class TestOnLineCarUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟 后方VIP
|
||||
*/
|
||||
public static V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> getV2XScenarionVRBehindVIPData() {
|
||||
try {
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_push_vr_hehind_vip_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();
|
||||
|
||||
// 加载数据源
|
||||
V2XSpecialCarRes v2xRoadEventEntity =
|
||||
GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class);
|
||||
|
||||
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates());
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向车辆路线预判
|
||||
*/
|
||||
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarionVRReverseCarData() {
|
||||
try {
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_push_vr_reverse_car_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<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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.mogo.module.v2x.view
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Surface
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.mogo.module.v2x.R
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/8
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class SimpleLiveVideoPlayer : StandardGSYVideoPlayer {
|
||||
|
||||
companion object {
|
||||
const val PLAY_EVT_PLAY_LOADING = 1000
|
||||
const val PLAY_EVT_PLAY_BEGIN = 2000
|
||||
const val PLAY_EVT_PLAY_ERROR = 3000
|
||||
}
|
||||
|
||||
private var playListener: PlayListener? = null
|
||||
private lateinit var start: ImageView
|
||||
|
||||
interface PlayListener {
|
||||
fun onPlayEvent(event: Int)
|
||||
}
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
start = findViewById(R.id.start)
|
||||
if (mThumbImageViewLayout != null
|
||||
&& (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR)
|
||||
) {
|
||||
mThumbImageViewLayout.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.item_v2x_crossroad_live_video
|
||||
}
|
||||
|
||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
||||
GSYVideoManager.instance().initContext(context.applicationContext)
|
||||
return GSYVideoManager.instance()
|
||||
}
|
||||
|
||||
override fun setProgressAndTime(
|
||||
progress: Int,
|
||||
secProgress: Int,
|
||||
currentTime: Int,
|
||||
totalTime: Int,
|
||||
forceChange: Boolean
|
||||
) {
|
||||
super.setProgressAndTime(progress, secProgress, currentTime, totalTime, forceChange)
|
||||
if (progress != 0) {
|
||||
mProgressBar?.progress = progress
|
||||
}
|
||||
}
|
||||
|
||||
fun setPlayListener(listener: PlayListener) {
|
||||
this.playListener = listener
|
||||
}
|
||||
|
||||
override fun updateStartImage() {
|
||||
}
|
||||
|
||||
override fun changeUiToCompleteShow() {
|
||||
super.changeUiToCompleteShow()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun hideAllWidget() {
|
||||
super.hideAllWidget()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun changeUiToPrepareingClear() {
|
||||
super.changeUiToPrepareingClear()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun changeUiToPlayingBufferingClear() {
|
||||
super.changeUiToPlayingBufferingClear()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
|
||||
}
|
||||
|
||||
override fun changeUiToClear() {
|
||||
super.changeUiToClear()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun changeUiToCompleteClear() {
|
||||
super.changeUiToCompleteClear()
|
||||
mBottomContainer?.visibility = View.INVISIBLE
|
||||
mProgressBar?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onAutoCompletion() {
|
||||
super.onAutoCompletion()
|
||||
mProgressBar?.progress = 0
|
||||
}
|
||||
|
||||
override fun showWifiDialog() {
|
||||
//直接播放,不显示WIFI对话框
|
||||
startPlayLogic()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
mProgressBar?.progress = 0
|
||||
mFullPauseBitmap = null
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
}
|
||||
|
||||
override fun onCompletion() {
|
||||
isPostBufferUpdate = false
|
||||
}
|
||||
|
||||
override fun onSurfaceUpdated(surface: Surface) {
|
||||
super.onSurfaceUpdated(surface)
|
||||
if (mThumbImageViewLayout != null && mThumbImageViewLayout.visibility == View.VISIBLE) {
|
||||
mThumbImageViewLayout.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPrepared() {
|
||||
super.onPrepared()
|
||||
playListener?.onPlayEvent(PLAY_EVT_PLAY_LOADING)
|
||||
}
|
||||
|
||||
private var isPostBufferUpdate = false
|
||||
|
||||
override fun onBufferingUpdate(percent: Int) {
|
||||
super.onBufferingUpdate(percent)
|
||||
if (!isPostBufferUpdate && percent == 0) {
|
||||
isPostBufferUpdate = true
|
||||
playListener?.onPlayEvent(PLAY_EVT_PLAY_BEGIN)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(what: Int, extra: Int) {
|
||||
super.onError(what, extra)
|
||||
playListener?.onPlayEvent(PLAY_EVT_PLAY_ERROR)
|
||||
isPostBufferUpdate = false
|
||||
}
|
||||
|
||||
override fun setViewShowState(view: View?, visibility: Int) {
|
||||
if (view === mThumbImageViewLayout && visibility != View.VISIBLE) {
|
||||
return
|
||||
}
|
||||
super.setViewShowState(view, visibility)
|
||||
}
|
||||
|
||||
override fun onSurfaceAvailable(surface: Surface) {
|
||||
super.onSurfaceAvailable(surface)
|
||||
mProgressBar?.visibility = View.GONE
|
||||
if (GSYVideoType.getRenderType() != GSYVideoType.TEXTURE) {
|
||||
if (mThumbImageViewLayout != null && mThumbImageViewLayout.visibility == View.VISIBLE) {
|
||||
mThumbImageViewLayout.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.mogo.module.v2x.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.common.entity.MarkerCarInfo;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XLivePushVoRes;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.tencent.rtmp.ITXLivePlayListener;
|
||||
import com.tencent.rtmp.TXLiveConstants;
|
||||
import com.tencent.rtmp.TXLivePlayer;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-02-0623:07
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XCarLiveVideoView extends RoundLayout {
|
||||
private final String TAG = "V2XLiveGSYVideoView";
|
||||
|
||||
private TXCloudVideoView mTxcVideoView;
|
||||
private ProgressBar mLoading;
|
||||
private TXLivePlayer mLivePlayer;
|
||||
private ConstraintLayout mClLoadError;
|
||||
private TextView mTvRefreshButton;
|
||||
|
||||
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
|
||||
// 重新刷新直播流
|
||||
private V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
|
||||
@Override
|
||||
public void onCallback(String command, Intent intent) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public V2XCarLiveVideoView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public V2XCarLiveVideoView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public V2XCarLiveVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context)
|
||||
.inflate(R.layout.view_video_layout_see_live, this);
|
||||
//mPlayerView 即 step1 中添加的界面 view
|
||||
mTxcVideoView = findViewById(R.id.txcVideoView);
|
||||
//创建 player 对象
|
||||
mLivePlayer = new TXLivePlayer(context);
|
||||
//关键 player 对象与界面 view
|
||||
mLivePlayer.setPlayerView(mTxcVideoView);
|
||||
mLivePlayer.setMute(true);
|
||||
mLivePlayer.enableHardwareDecode(true);
|
||||
|
||||
mLoading = findViewById(R.id.loading);
|
||||
mLoading.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(context, R.color.live_video_progress_bar_loading_color), PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
mClLoadError = findViewById(R.id.clLoadError);
|
||||
mTvRefreshButton = findViewById(R.id.tvRefreshButton);
|
||||
mTvRefreshButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直播信息
|
||||
*/
|
||||
public void setCarLiveInfo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
mCarLiveInfo = carLiveInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始直播
|
||||
*
|
||||
* @param carLiveInfo 要直播的车机,如果没有直播的地址需要重新获取最新的直播地址
|
||||
*/
|
||||
public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
// 进行直播播放
|
||||
if (mLivePlayer != null
|
||||
&& carLiveInfo != null) {
|
||||
if (!TextUtils.isEmpty(carLiveInfo.getVideoUrl())) {
|
||||
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live));
|
||||
setCarLiveInfo(carLiveInfo);
|
||||
playLiveVideo(carLiveInfo);
|
||||
}
|
||||
// 根据SN重新获取直播流地址
|
||||
else {
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel()
|
||||
.livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
|
||||
@Override
|
||||
public void onSuccess(V2XLivePushVoRes result) {
|
||||
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live));
|
||||
mClLoadError.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
try {
|
||||
MarkerCarInfo.CarLiveInfo carRealLiveInfo = new MarkerCarInfo.CarLiveInfo();
|
||||
carRealLiveInfo.setVideoUrl(result.getResult().getPlayUrl().getRtmp());
|
||||
carRealLiveInfo.setVideoSn(carLiveInfo.getVideoSn());
|
||||
carRealLiveInfo.setVideoChannel(result.getResult().getVideoChannel());
|
||||
setCarLiveInfo(carLiveInfo);
|
||||
playLiveVideo(carRealLiveInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
Logger.e(MODULE_NAME, "播放器:" + msg);
|
||||
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live_error));
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
}
|
||||
}, carLiveInfo.getVideoSn(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放直播流,且开始心跳
|
||||
*/
|
||||
private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
startHeartLive(carLiveInfo);
|
||||
if (mLivePlayer != null) {
|
||||
mLivePlayer.startPlay(carLiveInfo.getVideoUrl(), TXLivePlayer.PLAY_TYPE_LIVE_RTMP);
|
||||
mLivePlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int event, Bundle bundle) {
|
||||
Logger.w(MODULE_NAME, "播放器:onPlayEvent==" + event + "===bundle===" + bundle);
|
||||
if (event == TXLiveConstants.PLAY_EVT_PLAY_LOADING) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event == TXLiveConstants.PLAY_EVT_PLAY_BEGIN) {
|
||||
refreshStatusToListener(true);
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event < 0) {
|
||||
refreshStatusToListener(false);
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取识败,可以对我说重试", null);
|
||||
stopLive(mCarLiveInfo);
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
// 注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE,
|
||||
v2XVoiceCallbackRefreshListener)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP,
|
||||
v2XVoiceCallbackRefreshListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
//Logger.w(MODULE_NAME, "播放器:onNetStatus===bundle===" + bundle);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新直播心跳
|
||||
private void startHeartLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(carLiveInfo.getVideoSn())
|
||||
&& !TextUtils.isEmpty(carLiveInfo.getVideoChannel())) {
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel()
|
||||
.refreshHeartBeat(carLiveInfo.getVideoSn(),
|
||||
carLiveInfo.getVideoChannel(),
|
||||
null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
try {
|
||||
Logger.w(MODULE_NAME, "心跳:关闭直播...");
|
||||
// 暂停
|
||||
mLivePlayer.pause();
|
||||
// true 代表清除最后一帧画面
|
||||
mLivePlayer.stopPlay(true);
|
||||
mTxcVideoView.onDestroy();
|
||||
// 停止推流
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel()
|
||||
.livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
|
||||
@Override
|
||||
public void onSuccess(V2XLivePushVoRes result) {
|
||||
Logger.d(MODULE_NAME, "播放器:" + result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
Logger.e(MODULE_NAME, "播放器:" + msg);
|
||||
}
|
||||
}, carLiveInfo.getVideoSn(), 1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
stopLive(mCarLiveInfo);
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
// 反注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE)
|
||||
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
private void refreshStatusToListener(boolean videoPlaying) {
|
||||
if (onVideoStatusChange != null) {
|
||||
onVideoStatusChange.videoPlaying(videoPlaying);
|
||||
}
|
||||
}
|
||||
|
||||
private OnVideoStatusChange onVideoStatusChange;
|
||||
|
||||
public void addOnVideoStatusChangeListener(OnVideoStatusChange onVideoStatusChange) {
|
||||
this.onVideoStatusChange = onVideoStatusChange;
|
||||
}
|
||||
|
||||
public interface OnVideoStatusChange {
|
||||
void videoPlaying(boolean videoPlaying);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.mogo.module.v2x.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.common.entity.MarkerCarInfo;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.network.V2XRefreshModel;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
|
||||
import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager;
|
||||
import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
|
||||
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
|
||||
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_BEGIN;
|
||||
import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_LOADING;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-02-0623:07
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XCrossRoadVideoView extends RoundLayout {
|
||||
|
||||
private static final String TAG = "CrossRoadVideo";
|
||||
|
||||
private SimpleLiveVideoPlayer mTxcVideoView;
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
private ProgressBar mLoading;
|
||||
private ConstraintLayout mClLoadError;
|
||||
private TextView mTvRefreshButton;
|
||||
private boolean init = false;
|
||||
|
||||
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
|
||||
// 重新刷新直播流
|
||||
private V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
|
||||
@Override
|
||||
public void onCallback(String command, Intent intent) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public V2XCrossRoadVideoView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public V2XCrossRoadVideoView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public V2XCrossRoadVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
if(init){
|
||||
return;
|
||||
}
|
||||
Logger.d("V2XCrossRoadVideoView", "V2X===初始化语音呼叫路口直播视图");
|
||||
LayoutInflater.from(context)
|
||||
.inflate(R.layout.view_video_layout_see_crossroad, this);
|
||||
//mPlayerView 即 step1 中添加的界面 view
|
||||
mTxcVideoView = findViewById(R.id.txcVideoView);
|
||||
initGSYVideoConfig();
|
||||
|
||||
mLoading = findViewById(R.id.loading);
|
||||
mLoading.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(context, R.color.live_video_progress_bar_loading_color), PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
mClLoadError = findViewById(R.id.clLoadError);
|
||||
mTvRefreshButton = findViewById(R.id.tvRefreshButton);
|
||||
mTvRefreshButton.setOnClickListener(v -> {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
});
|
||||
init = true;
|
||||
}
|
||||
|
||||
private void initGSYVideoConfig() {
|
||||
PlayerFactory.setPlayManager(IjkPlayerManager.class);
|
||||
CacheFactory.setCacheManager(ProxyCacheManager.class);
|
||||
List<VideoOptionModel> list = new ArrayList<>();
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp"));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_flags", "prefer_tcp"));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video"));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 20000));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 1316));
|
||||
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "infbuf", 1));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1));
|
||||
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 10240));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_timeout", -1));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration",1));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "packet-buffering", 0));
|
||||
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "reconnect",10));
|
||||
|
||||
GSYVideoManager.instance().setOptionModelList(list);
|
||||
GSYVideoType.enableMediaCodec();
|
||||
GSYVideoType.enableMediaCodecTexture();
|
||||
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直播信息
|
||||
*/
|
||||
public void setCarLiveInfo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
mCarLiveInfo = carLiveInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始直播
|
||||
*
|
||||
* @param carLiveInfo 要直播的车机,如果没有直播的地址需要重新获取最新的直播地址
|
||||
*/
|
||||
public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
initView(this.getContext());
|
||||
// 进行直播播放
|
||||
if (mTxcVideoView != null
|
||||
&& carLiveInfo != null) {
|
||||
if (!TextUtils.isEmpty(carLiveInfo.getVideoUrl())) {
|
||||
setCarLiveInfo(carLiveInfo);
|
||||
playLiveVideo(carLiveInfo);
|
||||
}
|
||||
//重新获取直播流地址
|
||||
else {
|
||||
V2XRefreshModel.getInstance(AbsMogoApplication.getApp()).queryCrossRoadsLive(new V2XRefreshCallback<V2XLiveCrossRoad>() {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCrossRoad result) {
|
||||
if (result != null && result.getResult().getUrl() != null) {
|
||||
String liveUrl = result.getResult().getUrl();
|
||||
MarkerCarInfo.CarLiveInfo carLiveInfo = new MarkerCarInfo.CarLiveInfo();
|
||||
carLiveInfo.setVideoUrl(liveUrl);
|
||||
setCarLiveInfo(carLiveInfo);
|
||||
playLiveVideo(carLiveInfo);
|
||||
} else {
|
||||
Logger.d(MODULE_NAME, "startLive 路口实况直播地址为空");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
//获取路口实况失败
|
||||
Logger.d(MODULE_NAME, "获取路口实况失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放直播流,且开始心跳
|
||||
*/
|
||||
private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
if (mTxcVideoView != null) {
|
||||
mTxcVideoView.setPlayListener(event -> {
|
||||
Logger.w(MODULE_NAME, "播放器:onPlayEvent==" + event);
|
||||
if (event == PLAY_EVT_PLAY_LOADING) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event == PLAY_EVT_PLAY_BEGIN) {
|
||||
refreshStatusToListener(true);
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event < 0) {
|
||||
refreshStatusToListener(false);
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取识败,可以对我说重试", null);
|
||||
stopLive();
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
// 注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP,
|
||||
v2XVoiceCallbackRefreshListener);
|
||||
}
|
||||
});
|
||||
gsyVideoOptionBuilder.setUrl(carLiveInfo.getVideoUrl()).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(mTxcVideoView);
|
||||
mTxcVideoView.getStartButton().performClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopLive() {
|
||||
try {
|
||||
Logger.w(MODULE_NAME, "关闭直播...");
|
||||
GSYVideoManager.releaseAllVideos();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (mCarLiveInfo != null) {
|
||||
startLive(mCarLiveInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
stopLive();
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
// 反注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
private void refreshStatusToListener(boolean videoPlaying) {
|
||||
if (onVideoStatusChange != null) {
|
||||
onVideoStatusChange.videoPlaying(videoPlaying);
|
||||
}
|
||||
}
|
||||
|
||||
private OnVideoStatusChange onVideoStatusChange;
|
||||
|
||||
public void addOnVideoStatusChangeListener(OnVideoStatusChange onVideoStatusChange) {
|
||||
this.onVideoStatusChange = onVideoStatusChange;
|
||||
}
|
||||
|
||||
public interface OnVideoStatusChange {
|
||||
void videoPlaying(boolean videoPlaying);
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,16 @@ public class V2XVoiceConstants {
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE = "com.zhidao.user.action.retry";
|
||||
|
||||
/**
|
||||
* 唤醒词:查看前车视频
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_V2X_AHEAD_LIVE = "com.zhidao.ahead.live";
|
||||
|
||||
/**
|
||||
* 唤醒词:查看周围路口直播
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_V2X_CROSSROADS_LIVE = "com.zhidao.crossroads.live";
|
||||
|
||||
/**
|
||||
* 应用内免唤醒
|
||||
* 发起定向车聊聊
|
||||
@@ -194,6 +204,19 @@ public class V2XVoiceConstants {
|
||||
public static final String COMMAND_ZHIDAO_V2X_ILLEGAL_PARKMARKER_FEEDBACK_YOUYONG_UN_WAKEUP = "COMMAND_ZHIDAO_V2X_ILLEGAL_PARKMARKER_FEEDBACK_YOUYONG_UN_WAKEUP";
|
||||
public static final String[] COMMAND_ZHIDAO_V2X_ILLEGAL_PARKMARKER_FEEDBACK_YOUYONG_UN_WAKEUP_WORDS = {"有用"};
|
||||
|
||||
/**
|
||||
* 应用内免唤醒
|
||||
* "查看前车视频","查看前车直播","查看前车视角"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP = "COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP";
|
||||
public static final String[] COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP_WORDS = {"查看前车视频", "查看前车直播", "查看前车视角"};
|
||||
|
||||
/**
|
||||
* 应用内免唤醒
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP = "COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP";
|
||||
public static final String[] COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP_WORDS = {"查看路口实况", "查看路口直播", "查看路口视频"};
|
||||
|
||||
/**
|
||||
* 违章停车
|
||||
* 没用
|
||||
@@ -297,5 +320,11 @@ public class V2XVoiceConstants {
|
||||
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GU_NO_UN_WAKEUP, COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GU_NO_UN_WAKEUP_WORDS);
|
||||
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GONG_YES_UN_WAKEUP, COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GONG_YES_UN_WAKEUP_WORDS);
|
||||
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GONG_NO_UN_WAKEUP, COMMAND_ZHIDAO_V2X_FEEDBACK_SHI_GONG_NO_UN_WAKEUP_WORDS);
|
||||
|
||||
|
||||
//2020-6-24 顺义演示需求添加,现合并至launcher 更新时间:2020-08-25
|
||||
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP, COMMAND_ZHIDAO_V2X_CALL_FRONT_CAR_DEMO_UN_WAKEUP_WORDS);
|
||||
sVoiceCmds.put(COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP, COMMAND_ZHIDAO_V2X_OPEN_ROAD_CAMERA_LIVE_UN_WAKEUP_WORDS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user