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

This commit is contained in:
董宏宇
2021-04-09 18:41:38 +08:00
50 changed files with 577 additions and 543 deletions

View File

@@ -166,6 +166,7 @@ public class V2XWaringManager {
// } );
//
//adas自车定位
// MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient().getLastKnowLocation()
// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
}

View File

@@ -1,20 +1,21 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.receiver.MogoReceiver;
@@ -23,15 +24,17 @@ import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
@@ -59,7 +62,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
pointsBetween();
//发送预警提示
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
isSelfLineClear = false;
@@ -73,8 +76,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
//绘制识别物与交汇点连线,并且更新连线数据
drawStopLine(cloundWarningInfo, newLocation);
//添加停止线marker
handleStopLine();
}, 0);
drawStopLineWith2Resource();
}, 200);
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
@@ -90,7 +93,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
}, 0);
}, 200);
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
@@ -108,8 +111,9 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
for (int i = 0; i < fillPoints.size(); i++) {
V2XWarningEntity entity = new V2XWarningEntity();
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
Log.d("liyz", "handleStopLine lat = " + latLng.lat + "--lon =" + latLng.lon);
entity.setLat(latLng.lat);
entity.setLat(latLng.lon);
entity.setLon(latLng.lon);
entity.setCollisionLat(mCloundWarningInfo.getCollisionLat());
entity.setCollisionLon(mCloundWarningInfo.getCollisionLon());
entity.heading = mCloundWarningInfo.heading;
@@ -117,6 +121,32 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
}
/*
* 2D资源绘制停止线
* */
private void drawStopLineWith2Resource() {
mCloundWarningInfo.setCarLocation(new MogoLatLng(39.976866,116.417622));//测试数据
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
if (carlo == null){
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
carlo = new MogoLatLng(lat, lon);
}
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(drawStopLineLon.getLat())
.longitude(drawStopLineLon.getLon())
.anchor(0.5f, 0.5f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
stopLine.showInfoWindow();
}
/**
* 绘制停止线前方线 TODO 需要实时给行人当前位置
*/
@@ -192,9 +222,20 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
*/
@Override
public void onCarLocationChanged2(Location latLng) {
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
//当行人经纬度交点 经纬度不为空,开始画线,否则清理
//自车只需要关注移动
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
//当行人经纬度交点 开始画线,否则清理
drawSlefCarLine(latLng);
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
/**
* 绘制自车连线
*/
private void drawSlefCarLine(Location latLng) {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
@@ -223,12 +264,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
/**
* 补点后的停止线经纬度合集
*/
@@ -258,4 +293,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getDistance(), mCloundWarningInfo.getDirection());
return newLocation;
}
}

View File

@@ -0,0 +1,44 @@
package com.mogo.module.v2x.marker;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
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;
/**
* @author liujing
* @description 前方预警目标物2D资源实现,目前只有停止线,可以按需添加其他类型
* @since: 2021/4/9
*/
public class V2XFrontTargetMarkerView extends MapMarkerBaseView {
private String TAG = "V2XFrontTargetMarkerView";
public V2XFrontTargetMarkerView(Context context) {
super(context);
}
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void initView(Context context) {
LayoutInflater.from( context ).inflate(R.layout.v2x_front_target_info_view, this );
}
@Override
public void updateView(MarkerShowEntity markerShowEntity) {
}
}

View File

@@ -47,10 +47,10 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
private V2XSeekHelpButton mV2XSeekHelpButton;
public V2XCarForHelpScenario() {
setV2XWindow(new V2XCarForHelpWindow(V2XServiceManager.getContext()));
mV2XSeekHelpButton = new V2XSeekHelpButton();
setV2XButton(mV2XSeekHelpButton);
V2XServiceManager.getMoGoStatusManager().registerStatusChangedListener(TAG, StatusDescriptor.SEEK_HELPING, this);
V2XServiceManager.getMoGoStatusManager().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
}
@Override
@@ -61,14 +61,6 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
}
setV2XMessageEntity(v2XMessageEntity);
Boolean isShow = getV2XMessageEntity().getContent();
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
if (isShow) {
showWindow();
} else {
closeWindow();
}
return;
}
if (isShow) {
showButton();
mySeekHelpCountDownTimerCancel();
@@ -96,20 +88,10 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
@Override
public void showWindow() {
if (getV2XWindow() != null) {
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.dp_140));
V2XServiceManager.getMogoTopViewManager().addView(getV2XWindow().getView(), layoutParams);
getV2XWindow().show(getV2XMessageEntity().getContent());
}
}
@Override
public void closeWindow() {
// if (getV2XWindow() != null) {
// getV2XWindow().close();
// }
}
private V2XVoiceCallbackListener cancelCb = null;
@@ -122,7 +104,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, "正在发起求助...");
// V2XServiceManager.getMogoEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SEEK_HELP, R.drawable.module_v2x_left_notice_seek_help, "正在发起求助...");
}
});
}
@@ -241,6 +223,18 @@ public class V2XCarForHelpScenario extends AbsV2XScenario<Boolean> implements IM
entity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP);
entity.setContent(isTrue);
init(entity);
} else if (descriptor == StatusDescriptor.VR_MODE) {
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
if (isTrue) {
((V2XSeekHelpButton) getV2XButton()).showTopView();
V2XServiceManager.getMogoEntranceButtonController()
.getButton(ButtonIndex.BUTTON2).setVisibility(View.GONE);
} else {
((V2XSeekHelpButton) getV2XButton()).closeTopView();
V2XServiceManager.getMogoEntranceButtonController()
.getButton(ButtonIndex.BUTTON2).setVisibility(View.VISIBLE);
}
}
}
}
}

View File

@@ -1,114 +0,0 @@
package com.mogo.module.v2x.scenario.scene.help;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.voice.AIAssist;
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.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.scenario.scene.V2XBasWindow;
import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
import com.mogo.module.v2x.voice.V2XVoiceConstants;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.utils.storage.SharedPrefsMgr;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* created by wujifei on 2021/4/1 16:04
* describe:
*/
public class V2XCarForHelpWindow extends V2XBasWindow implements IV2XWindow<Boolean> {
private static final String TAG = MODULE_NAME + "_" + V2XCarForHelpScenario.class.getSimpleName();
private TextView tvCancel;
private V2XVoiceCallbackListener cancelCb = (String command, Intent intent) -> {
close();
};
public V2XCarForHelpWindow(Context context) {
this(context, null);
}
public V2XCarForHelpWindow(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public V2XCarForHelpWindow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context);
}
private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.window_carforhelp_detail, this);
tvCancel = (TextView) findViewById(R.id.tv_cancel);
tvCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
close();
}
});
}
@Override
public void show(Boolean entity) {
V2XVoiceManager.INSTANCE.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CANCEL_HELP, cancelCb);
}
@Override
public void close() {
if (V2XServiceManager.getMoGoStatusManager().isSeekHelping()) {
V2XServiceManager.getMoGoStatusManager().setSeekHelping(TAG, false);
SharedPrefsMgr.getInstance(V2XUtils.getApp()).putLong(V2XConst.SEEK_HELP_TIME, 0);
V2XServiceManager.getV2XRefreshModel().cancelHelpSignal(new V2XRefreshCallback<BaseData>() {
@Override
public void onSuccess(BaseData result) {
//移除窗体
V2XServiceManager.getMogoTopViewManager().removeView(V2XCarForHelpWindow.this);
}
@Override
public void onFail(String msg) {
Toast.makeText(V2XServiceManager.getContext(), msg, Toast.LENGTH_SHORT).show();
}
});
}
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已取消", null);
//移除窗体
V2XServiceManager.getMogoTopViewManager().removeView(V2XCarForHelpWindow.this);
V2XVoiceManager.INSTANCE.unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CANCEL_HELP);
if (V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow()) {
// 移除线
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
// 移除事件POI
V2XServiceManager.getMoGoV2XMarkerManager().clearSpecialCarPOI();
// 绘制上次的数据
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
}
}
@Override
public View getView() {
return this;
}
@Override
public void setWindowStatusListener(V2XWindowStatusListener listener) {
}
}

View File

@@ -1,7 +1,9 @@
package com.mogo.module.v2x.scenario.scene.help;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mogo.commons.data.BaseData;
@@ -35,6 +37,8 @@ public class V2XSeekHelpButton implements IV2XButton {
private V2XVoiceCallbackListener cancelCb = (String command, Intent intent) -> {
doAction();
};
private View topView;
private void doAction() {
if (mListener != null) {
@@ -53,31 +57,57 @@ public class V2XSeekHelpButton implements IV2XButton {
try {
tv = V2XServiceManager.getMogoEntranceButtonController().getButton(ButtonIndex.BUTTON2);
tv.setText("取消\n求助");
tv.setVisibility(View.VISIBLE);
tv.setOnClickListener(v -> {
//调用取消求助接口
// TODO: 2020/5/18 回调,显示对话框
doAction();
});
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
showTopView();
tv.setVisibility(View.GONE);
} else {
closeTopView();
tv.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void showTopView() {
topView = View.inflate(V2XServiceManager.getContext(), R.layout.window_carforhelp_detail, null);
TextView tvCancel = topView.findViewById(R.id.tv_cancel);
tvCancel.setOnClickListener(v -> {
doAction();
});
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.dp_140));
V2XServiceManager.getMogoTopViewManager().addView(topView, layoutParams);
}
public void closeTopView() {
V2XServiceManager.getMogoTopViewManager().removeView(topView);
}
@Override
public void close() {
if (tv != null) {
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已取消", null);
tv.setVisibility(View.GONE);
closeTopView();
V2XServiceManager.getV2XRefreshModel().cancelHelpSignal(new V2XRefreshCallback<BaseData>() {
@Override
public void onSuccess(BaseData result) {
tv.setVisibility(View.GONE);
closeTopView();
}
@Override
public void onFail(String msg) {
tv.setVisibility(View.VISIBLE);
showTopView();
}
});
mListener = null;

View File

@@ -20,7 +20,7 @@ import com.mogo.utils.TipToast;
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : TODO 演示使用的推送单车机直播场景
* desc : TODO 推送直播场景 非演示
* version: 1.0
*/
public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity> implements IMogoTopViewStatusListener {
@@ -44,11 +44,9 @@ public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity>
show();
} else {
TipToast.shortTip("附近没有可直播车机");
//Logger.e(V2XConst.MODULE_NAME, "直播地址为null");
}
} else {
setV2XMessageEntity(v2XMessageEntity);
//Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
}
}
@@ -65,9 +63,15 @@ public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity>
int height = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_see_live_window_height_vr : R.dimen.module_v2x_event_see_live_window_height);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height);
V2XServiceManager
.getMogoTopViewManager()
.addViewNoLinkage(getV2XWindow().getView(), layoutParams, this);
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()
.addViewNoLinkage(getV2XWindow().getView(), layoutParams, this);
} else {
V2XServiceManager
.getMogoTopViewManager()
.addView(getV2XWindow().getView(), layoutParams, this);
}
getV2XWindow().show(getV2XMessageEntity().getContent());
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, true);
}
@@ -111,23 +115,19 @@ public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity>
@Override
public void onViewAdded(View view) {
//Logger.d(MODULE_NAME, "展示 Window 动画结束");
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), getV2XMessageEntity().getContent());
}
@Override
public void onViewRemoved(View view) {
//Logger.d(MODULE_NAME, "关闭 Window 动画结束");
}
@Override
public void beforeViewAddAnim(View view) {
//Logger.d(MODULE_NAME, "展示 Window 开始");
}
@Override
public void beforeViewRemoveAnim(View view) {
//Logger.d(MODULE_NAME, "关闭 Window 开始");
// 重置场景提示的消息
setV2XMessageEntity(null);
V2XServiceManager.getMoGoV2XStatusManager().setLiveCarWindowShow(TAG, false);

View File

@@ -6,6 +6,7 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
@@ -19,7 +20,6 @@ import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.module.v2x.view.V2XLiveGSYVideoView;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
@@ -27,20 +27,18 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/24 11:34 AM
* desc : TODO 演示使用的推送单车机直播场景
* version: 1.0
*/
public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2XPushMessageEntity> {
private Context mContext;
private V2XLiveGSYVideoView mV2XLiveGSYVideoView;
private MogoImageView mIvReportHead;
private ImageView pushVideoClose;
// 弹窗状态监听
private V2XWindowStatusListener mV2XWindowStatusListener;
// 直播30秒自动关闭
private static Handler handlerV2XEvent = new Handler();
private static final Handler handlerV2XEvent = new Handler();
private static Runnable runnableV2XEvent;
public V2XPushLiveCarWindow() {
@@ -57,17 +55,18 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
public V2XPushLiveCarWindow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
initView(context);
}
public void initView(Context context) {
//Logger.w(MODULE_NAME, "初始化直播小窗口View。。。。。");
LayoutInflater.from(context).inflate(R.layout.item_v2x_push_live_video, this);
LayoutInflater.from(context).inflate(V2XServiceManager.getMoGoStatusManager().isVrMode()
? R.layout.item_v2x_push_live_video_vr
: R.layout.item_v2x_push_live_video, this);
// 详情列表
mV2XLiveGSYVideoView = findViewById(R.id.videoPlayer);
mIvReportHead = findViewById(R.id.ivReportHead);
pushVideoClose = findViewById(R.id.pushVideoClose);
ImageView pushVideoClose = findViewById(R.id.pushVideoClose);
pushVideoClose.setOnClickListener(v -> {
//移除窗体
V2XServiceManager
@@ -114,7 +113,7 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
mV2XWindowStatusListener.onViewClose();
}
// 停止倒计时
if (handlerV2XEvent != null && runnableV2XEvent != null) {
if (runnableV2XEvent != null) {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
runnableV2XEvent = null;
}

View File

@@ -14,6 +14,7 @@ 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.V2XServiceManager;
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;
@@ -52,7 +53,6 @@ public class V2XVoiceCallLiveBiz {
}
private Context mContext;
private V2XVoiceCallLiveScenario mV2XVoiceCallLiveScenario;
//语音词指令 查看前车视频回调
private final V2XVoiceCallbackListener v2XVoiceCallbackFrontLiveCarListener = (command, intent) -> {
@@ -106,8 +106,7 @@ public class V2XVoiceCallLiveBiz {
LiveStreamManagerImpl.getInstance(AbsMogoApplication.getApp(),
MoGoAiCloudClientConfig.getInstance().getThirdPartyDeviceId());
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, null);
mV2XVoiceCallLiveScenario = new V2XVoiceCallLiveScenario();
mV2XVoiceCallLiveScenario.setV2XWindow(new V2XVoiceCallLiveCarWindow());
V2XVoiceCallLiveScenario mV2XVoiceCallLiveScenario = new V2XVoiceCallLiveScenario();
mV2XVoiceCallLiveScenario.init(v2XMessageEntity);
}
@@ -121,17 +120,18 @@ public class V2XVoiceCallLiveBiz {
public void liveUrlResult(String liveUrl) {
if (!TextUtils.isEmpty(liveUrl)) {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, liveUrl);
mV2XVoiceCallLiveScenario = new V2XVoiceCallLiveScenario();
mV2XVoiceCallLiveScenario.setV2XWindow(new V2XVoiceCrossRoadLiveWindow());
mV2XVoiceCallLiveScenario.init(v2XMessageEntity);
V2XPushLiveCarScenario pushLiveCarScenario = new V2XPushLiveCarScenario();
pushLiveCarScenario.init(v2XMessageEntity);
} else {
Logger.d(MODULE_NAME, "getOpenRoadCameraLive 路口实况直播地址为空");
ToastUtils.showShort(R.string.v2x_front_live_url_null);
}
}
@Override
public void onError(String errorMsg) {
Logger.d(MODULE_NAME, "getOpenRoadCameraLive : " + errorMsg);
ToastUtils.showShort(R.string.v2x_front_live_url_null);
}
});
}
@@ -148,6 +148,7 @@ public class V2XVoiceCallLiveBiz {
v2XPushMessageEntity.setVideoSn(sn);
v2XPushMessageEntity.setVideoUrl(liveUrl);
v2XPushMessageEntity.setShowWindow(true);
v2XPushMessageEntity.setExpireTime(1000 * 30);
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW);
v2XMessageEntity.setContent(v2XPushMessageEntity);

View File

@@ -4,7 +4,6 @@ import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -24,7 +23,10 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
implements IV2XWindow<V2XPushMessageEntity> {
private CarZegoLiveVideoView mV2XCarLiveVideoView;
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;
private TextView tvCountDown;
private ImageView ivVideoPlayingSign;
private boolean isVideoPlay = false;
@@ -32,13 +34,9 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
// 处理道路事件30秒倒计时
private final 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) {
@@ -52,8 +50,10 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
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);
LayoutInflater.from(context).inflate(V2XServiceManager.getMoGoStatusManager().isVrMode()
? R.layout.window_see_carlive_video_vr
: R.layout.window_see_carlive_video, this);
CarZegoLiveVideoView mV2XCarLiveVideoView = findViewById(R.id.videoPlayer);
tvCountDown = findViewById(R.id.tvCountDown);
ivVideoPlayingSign = findViewById(R.id.ivVideoPlayingSign);
mV2XCarLiveVideoView.addOnVideoStatusChangeListener(videoPlaying -> {
@@ -86,13 +86,10 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
public void close() {
// 停止倒计时
stopCountDown();
if (V2XServiceManager
.getMogoTopViewManager().isViewAdded(this)) {
//移除窗体
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
//移除窗体
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
@Override
@@ -113,7 +110,6 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
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));
@@ -126,12 +122,10 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
} 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;

View File

@@ -1,7 +1,7 @@
package com.mogo.module.v2x.scenario.scene.livecar;
import android.view.View;
import android.widget.RelativeLayout;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
@@ -20,27 +20,26 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : unknown
* desc : 语音呼叫查看直播场景,包括车辆直播 或者 路口实况 window区分不同页面window逻辑实现
* desc : 语音呼叫查看直播场景,包括车辆直播 或者 路口实况 window区分不同页面window逻辑实现,前方直播车辆由AICloudSdk中实现上层仅传入SurfaceView和经纬度
*/
public class V2XVoiceCallLiveScenario extends AbsV2XScenario<V2XPushMessageEntity> implements IMogoTopViewStatusListener {
public V2XVoiceCallLiveScenario() {
setV2XWindow(new V2XVoiceCallLiveCarWindow());
}
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
if (v2XMessageEntity == null) {
TipToast.shortTip("附近没有可直播车机");
return;
}
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");
}
Logger.d(V2XConst.MODULE_NAME, "v2XMessageEntity : " + v2XMessageEntity);
show();
} else {
setV2XMessageEntity(v2XMessageEntity);
Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
@@ -64,11 +63,7 @@ public class V2XVoiceCallLiveScenario extends AbsV2XScenario<V2XPushMessageEntit
R.dimen.module_v2x_event_window_width_vr : R.dimen.module_v2x_event_window_width);
int height = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_see_live_window_height_vr : R.dimen.module_v2x_event_see_live_window_height);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height);
layoutParams.topMargin = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_window_top_margin_vr : R.dimen.module_v2x_event_window_top_margin);
layoutParams.rightMargin = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_window_right_margin_vr : R.dimen.module_v2x_event_window_right_margin);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height);
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()

View File

@@ -53,6 +53,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerRoadEvent;
private Button mBtnClearRoadEvent;
private Button mBtnTriggerPushEvent;
private Button mBtnTriggerWarningEvent;
private Button mBtnTriggerPushLiveCarEvent;
private Button mBtnTriggerAnimationEvent;
private Button mBtnbtnFrontCarLiveEvent;
@@ -67,6 +68,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private ToggleButton nBtnTriggerVR;
private Button mBtnAdasDataWarn;
private Button btnTriggerRearVIPCarTip,
btnTriggerVehicleBrakes,
btnTriggerRearDangerousVehicles,
@@ -114,6 +116,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi);
flTestPanelVR = findViewById(R.id.flTestPanelVR);
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent);
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent);
@@ -220,6 +223,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
});
//车路云—场景预警-V1.0 碰撞预警
mBtnTriggerWarningEvent.setOnClickListener(v -> {
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
});
mBtnTriggerPushEvent.setOnClickListener(v -> {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushEventData();

View File

@@ -8,21 +8,31 @@ import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
/**
* @author liujing
* @description 前方预警marker打点 绘制安全线和预警线
@@ -33,7 +43,7 @@ public class V2XWarningMarker implements IV2XMarker {
private V2XWarningEntity mMarkerEntity;
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
private Context mContext = V2XServiceManager.getContext();
private List fillPoints = new ArrayList();//停止线经纬度合集
private IMogoMarker optimalMarker = null;
@Override
public void drawPOI(Object entity) {
@@ -45,16 +55,19 @@ public class V2XWarningMarker implements IV2XMarker {
markerShowEntity.setMarkerLocation(location);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(mMarkerEntity.getLat())
.longitude(mMarkerEntity.getLon())
.anchor(0.5f, 0.5f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
pointsBetween();
//绘制停止线
// drawStopLines(fillPoints);
drawSafeLine();
WorkThreadHandler.getInstance().postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 6_000);
}
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
optimalMarker.showInfoWindow();
} catch (Exception e) {
@@ -62,61 +75,6 @@ public class V2XWarningMarker implements IV2XMarker {
}
//绘制安全距离
private void drawSafeLine() {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
//自车位置
MogoLatLng car = V2XServiceManager.getNavi().getCarLocation();
if (car != null) {
//根据到停止线的距离和方向角获取经纬度
MogoLatLng
stopLineLo = LocationUtils.getNewLocation(car, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
// if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
// drawLine(car, stopLineLo);
// }
} else {
Log.d(TAG, "自车位置没有拿到");
}
}, 0);
}
//补点后的停止线经纬度合集
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mMarkerEntity.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mMarkerEntity.getStopLines().get(0);
MogoLatLng y = mMarkerEntity.getStopLines().get(1);
//两点间的距离
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
float average = distance / 3;
//两点间的角度
double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
//根据距离和角度获取下个点的经纬度
fillPoints.add(x);
for (int i = 1; i < 3; i++) {
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
fillPoints.add(newLocation);
}
fillPoints.add(y);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//绘制停止线-通过打点的方式实现
private void drawStopLines(List points) {
clearPOI();
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = (MogoLatLng) points.get(i);
drawMarkerWithLocation(latLng, V2XConst.V2X_FRONT_STOP_LINE);
}
}
private void drawMarkerWithLocation(MogoLatLng latLng, String tag) {
MogoMarkerOptions options = new MogoMarkerOptions()
@@ -132,47 +90,10 @@ public class V2XWarningMarker implements IV2XMarker {
marker.setToTop();
}
//绘制并返回marker
public IMogoMarker drawMarkerAndReturn(MarkerShowEntity markerShowEntity) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(V2XConst.V2X_FRONT_WARNING_MARKER, options);
iMarkerView.setMarker(marker);
marker.setToTop();
return marker;
}
//绘制线
public void drawLine(MogoLatLng s, MogoLatLng e) {
DrawLineInfo drawLineInfo = new DrawLineInfo();
drawLineInfo.setStartLocation(s);
drawLineInfo.setEndLocation(e);
drawLineInfo.setWidth(60);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}
//平移
public void smooth(IMogoMarker marker) {
List<MogoLatLng> latLngs = new ArrayList<>();
MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
MogoLatLng endLocation = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon());
latLngs.add(sLocation);
latLngs.add(endLocation);
marker.startSmoothInMs(latLngs, 3000);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearLine();
}, 3_000);
}
@Override
public void clearPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER);
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
}
public void clearLine() {

View File

@@ -13,8 +13,6 @@ import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.cloud.trafficlive.api.ITrafficCarLiveCallBack;
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
import com.mogo.commons.AbsMogoApplication;
@@ -38,7 +36,6 @@ public class CarZegoLiveVideoView extends RoundLayout {
private SurfaceView mSurfaceView;
private ProgressBar mLoading;
private ConstraintLayout mClLoadError;
private TextView mTvRefreshButton;
private String liveSn;
// 重新刷新直播流
@@ -73,7 +70,7 @@ public class CarZegoLiveVideoView extends RoundLayout {
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);
TextView mTvRefreshButton = findViewById(R.id.tvRefreshButton);
mTvRefreshButton.setOnClickListener(v -> {
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);

View File

@@ -57,7 +57,6 @@ public class V2XCrossRoadVideoView extends RoundLayout {
private final GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private ProgressBar mLoading;
private ConstraintLayout mClLoadError;
private TextView mTvRefreshButton;
private boolean init = false;
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
@@ -83,6 +82,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
public V2XCrossRoadVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
Logger.d(TAG, "constructor invoke initView");
initView(context);
}
@@ -101,7 +101,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
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);
TextView mTvRefreshButton = findViewById(R.id.tvRefreshButton);
mTvRefreshButton.setOnClickListener(v -> {
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
@@ -152,7 +152,6 @@ public class V2XCrossRoadVideoView extends RoundLayout {
* @param carLiveInfo 要直播的设备信息,如果没有直播的地址需要重新获取最新的直播地址
*/
public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
initView(this.getContext());
// 进行直播播放
if (mTxcVideoView != null
&& carLiveInfo != null) {

View File

@@ -7,7 +7,6 @@ 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;
@@ -18,8 +17,6 @@ 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;
@@ -50,16 +47,14 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
private ProgressBar mLoading;
private TXLivePlayer mLivePlayer;
private ConstraintLayout mClLoadError;
private TextView mTvRefreshButton;
private MogoSkinCompatBackgroundHelperDelegate mBackgroundTintHelper;
private final MogoSkinCompatBackgroundHelperDelegate mBackgroundTintHelper;
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
// 重新刷新直播流
private V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
private final V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
//startHeartLive(mCarLiveInfo);
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
if (mCarLiveInfo != null) {
@@ -87,7 +82,7 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
private void initView(Context context) {
LayoutInflater.from(context)
.inflate(R.layout.view_video_layout_normal, this);
//mPlayerView 即 step1 中添加的界面 view
//mPlayerView 即 step1 中添加的界面 view
mTxcVideoView = findViewById(R.id.txcVideoView);
//创建 player 对象
mLivePlayer = new TXLivePlayer(context);
@@ -106,15 +101,12 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
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);
}
TextView mTvRefreshButton = findViewById(R.id.tvRefreshButton);
mTvRefreshButton.setOnClickListener(v -> {
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
if (mCarLiveInfo != null) {
startLive(mCarLiveInfo);
}
});
}
@@ -141,33 +133,33 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
}
// 根据SN重新获取直播流地址
else {
V2XServiceManager
.getV2XRefreshModel()
.livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
@Override
public void onSuccess(V2XLivePushVoRes result) {
Logger.e(MODULE_NAME, "从服务端获取最新直播信息:" + GsonUtil.jsonFromObject(result));
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);
mLoading.setVisibility(GONE);
mClLoadError.setVisibility(VISIBLE);
}
}, carLiveInfo.getVideoSn(), 0);
// V2XServiceManager
// .getV2XRefreshModel()
// .livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
// @Override
// public void onSuccess(V2XLivePushVoRes result) {
// Logger.e(MODULE_NAME, "从服务端获取最新直播信息:" + GsonUtil.jsonFromObject(result));
// 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);
// mLoading.setVisibility(GONE);
// mClLoadError.setVisibility(VISIBLE);
// }
// }, carLiveInfo.getVideoSn(), 0);
}
}
}
@@ -223,7 +215,7 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
/**
* 刷新直播心跳
*
* @param carLiveInfo
* @param carLiveInfo 直播info
*/
private void startHeartLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
try {
@@ -248,20 +240,25 @@ public class V2XLiveGSYVideoView extends RoundLayout implements IMogoSkinCompatS
// 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);
// if (carLiveInfo.getVideoUrl() != null) {
// return;
// }
// 停止推流
// 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();
}