[add] 前方预警弹框数据结构

This commit is contained in:
liujing
2021-03-26 18:41:19 +08:00
parent dcbf5a66a2
commit 55d5e97f2a
7 changed files with 170 additions and 28 deletions

View File

@@ -19,6 +19,7 @@ import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
@@ -220,7 +221,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
//车路云—场景预警-V1.0 碰撞预警
mBtnTriggerWarningEvent.setOnClickListener(v->{
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);

View File

@@ -14,6 +14,7 @@ import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.MogoServices;
import com.mogo.module.service.receiver.MogoReceiver;
@@ -39,9 +40,7 @@ import java.util.List;
*/
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
private int type;
private IV2XListener mIV2XListener;
private List<V2XSpecialCarRes.V2XMarkerEntity> mMarkerEntity;
private V2XPushMessageEntity mV2XPushMessageEntity;
private V2XWarningEntity mMarkerEntity;
public V2XFrontWarningScenario() {
setV2XWindow(new V2XWarningWindow());
@@ -52,16 +51,13 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
type = v2XMessageEntity.getType();
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING);
try {
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
if (getV2XMessageEntity() != null &&
!V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
show();
}
if (v2XMessageEntity != null && V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
show();
}
} catch (Exception e) {
e.printStackTrace();
}
show();
}
@Override
@@ -71,7 +67,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void showWindow() {
// if (getV2XWindow() != null && mMarkerEntity != null) {
if (getV2XWindow() != null && mMarkerEntity != null) {
View view = getV2XWindow().getView();
//Logger.d(MODULE_NAME, "添加window= " + view);
ViewGroup.LayoutParams layoutParams =
@@ -81,8 +77,8 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
V2XServiceManager
.getMogoTopViewManager()
.addView(getV2XWindow().getView(), layoutParams, this);
getV2XWindow().show(mV2XPushMessageEntity);
// }
getV2XWindow().show(mMarkerEntity);
}
}
@Override

View File

@@ -8,6 +8,7 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
@@ -25,6 +26,7 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
private ImageView typeImage;
private TextView warningTextView;
private TextView distance;
private V2XWarningEntity mV2XWarningEntity;
//倒计时3s弹框取消
private static Handler handlerV2XEvent = new Handler();
@@ -56,7 +58,8 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
@Override
public void show(Object entity) {
if (entity != null) {
mV2XWarningEntity = (V2XWarningEntity) entity;
distance.setText(String.valueOf(mV2XWarningEntity.getDistance())+"");
}
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {

View File

@@ -5,6 +5,7 @@ import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.utils.network.utils.GsonUtil;
@@ -156,7 +157,7 @@ public class TestOnLineCarUtils {
return null;
}
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioPushFrontWarningEventData() {
public static V2XMessageEntity<V2XWarningEntity> getV2XScenarioPushFrontWarningEventData() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
@@ -170,13 +171,13 @@ public class TestOnLineCarUtils {
inputStream.close();
// 加载数据源
V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class);
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
V2XMessageEntity<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
V2XMessageEntity<V2XWarningEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity);
v2xMessageEntity.setContent(warningEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;