调整左上角红绿灯展示,暂无车道数据
This commit is contained in:
@@ -88,6 +88,9 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb
|
||||
}
|
||||
}
|
||||
|
||||
private int[] lightArray = new int[4];
|
||||
private String[] surplusTimeArray = new String[4];
|
||||
|
||||
/**
|
||||
* 刷新红绿灯显示状态
|
||||
*
|
||||
@@ -95,10 +98,22 @@ public class VrModeNavInfoView extends BaseNaviInfoView implements Handler.Callb
|
||||
* @param surplusTime 固定数组长度为4的剩余时长数组,从0-3依次代表 掉头,左转,执行,右转
|
||||
*/
|
||||
public void refreshTrafficLightStatus(int[] laneLight, String[] surplusTime) {
|
||||
lightArray = laneLight;
|
||||
surplusTimeArray = surplusTime;
|
||||
|
||||
turnAroundLight.setTrafficLightStatus(laneLight[0], surplusTime[0]);
|
||||
turnLeftLight.setTrafficLightStatus(laneLight[1], surplusTime[1]);
|
||||
straightLight.setTrafficLightStatus(laneLight[2], surplusTime[2]);
|
||||
turnRightLight.setTrafficLightStatus(laneLight[3], surplusTime[3]);
|
||||
// todo 再根据当前所在车道,置灰不需关注的灯
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据所在车道,控制红绿灯展示
|
||||
*/
|
||||
public void refreshLaneStatus(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
@@ -33,9 +34,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
private static final String TAG = "AdasNoticeHelper";
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001;
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002;
|
||||
// private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002; 先去掉云端下发红绿灯信息
|
||||
private static final int MSG_HIDE_LIMIT_SPEED = 1003;
|
||||
private static final int MSG_REFRESH_CAR_STRATEGY = 1004;
|
||||
// private static final int MSG_REFRESH_CAR_STRATEGY = 1004;
|
||||
|
||||
private static final long HIDE_TRAFFIC_LIGHT_DELAY = 2_000L;
|
||||
private static final long HIDE_LIMIT_SPEED_DELAY = 10_000L;
|
||||
@@ -53,23 +54,14 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
|
||||
private VrModeNavInfoView vrModeNavInfoView;
|
||||
|
||||
private Handler handler = new Handler(this);
|
||||
|
||||
private boolean isObuLightData = false;
|
||||
|
||||
|
||||
private boolean lightCenter = true;
|
||||
private final Handler handler = new Handler(this);
|
||||
|
||||
public void init(Context context) {
|
||||
this.context = context;
|
||||
if (!lightCenter) {
|
||||
}
|
||||
Logger.d(TAG, "init====");
|
||||
}
|
||||
|
||||
public void initView(VrModeNavInfoView vrModeNavInfoView) {
|
||||
if (lightCenter) {
|
||||
}
|
||||
this.vrModeNavInfoView = vrModeNavInfoView;
|
||||
}
|
||||
|
||||
@@ -84,10 +76,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
context.registerReceiver(adasReceiver, filter);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
|
||||
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
|
||||
if (!lightCenter) {
|
||||
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
|
||||
}
|
||||
// 先不监听服务端下发消息
|
||||
// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,11 +87,9 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
if (isVrMode) {
|
||||
isVrMode = false;
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
|
||||
handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().removeAdasWarnMessageCallback(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
|
||||
|
||||
// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
|
||||
context.unregisterReceiver(adasReceiver);
|
||||
}
|
||||
}
|
||||
@@ -129,44 +118,15 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
return;
|
||||
}
|
||||
currentSpeed = (int) (location.getSpeed() * 3.6F);
|
||||
if (lightCenter) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_REFRESH_CAR_STRATEGY:
|
||||
// todo 暂时不采用此种渲染方式
|
||||
// 自车速度
|
||||
// todo 设置字体颜色、背景颜色、leftDrawable
|
||||
switch (lightStatus) {
|
||||
case "Y":
|
||||
// 黄灯
|
||||
break;
|
||||
case "R":
|
||||
// 红灯
|
||||
break;
|
||||
default:
|
||||
// 默认绿灯
|
||||
break;
|
||||
}
|
||||
|
||||
if (isVrMode) {
|
||||
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
|
||||
}
|
||||
return true;
|
||||
case MSG_HIDE_LIMIT_SPEED:
|
||||
limitSpeed = -1;
|
||||
return true;
|
||||
case MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD:
|
||||
if (!isObuLightData && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
|
||||
}
|
||||
return true;
|
||||
case MSG_HIDE_TRAFFIC_LIGHT_BY_OBU:
|
||||
isObuLightData = false;
|
||||
if (!handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD)) {
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -209,7 +169,17 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
String lightStatus = jsonObject.optString("lightStatus");
|
||||
String surplusTime = jsonObject.optString("surplusTime");
|
||||
if (!lightStatus.isEmpty() && !surplusTime.isEmpty()) {
|
||||
handleObuTrafficLightInfo(lightStatus, surplusTime);
|
||||
// String strArray = jsonObject.getString("lightArray");
|
||||
// Logger.d(TAG, "strArray: " + strArray);
|
||||
JSONArray lightJsonArray = jsonObject.getJSONArray("lightArray");
|
||||
JSONArray timeJsonArray = jsonObject.getJSONArray("surplusTimeArray");
|
||||
int[] lightArray = new int[4];
|
||||
String[] surplusTimeArray = new String[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
lightArray[i] = lightJsonArray.getInt(i);
|
||||
surplusTimeArray[i] = timeJsonArray.getString(i);
|
||||
}
|
||||
handleObuTrafficLightInfo(lightArray, surplusTimeArray);
|
||||
} else {
|
||||
Logger.d(TAG, "红绿灯必要信息都为空,不做展示");
|
||||
}
|
||||
@@ -224,22 +194,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
}
|
||||
}
|
||||
|
||||
private void handleObuTrafficLightInfo(String lightStatus, String surplusTime) {
|
||||
isObuLightData = true;
|
||||
}
|
||||
|
||||
private void handleCloudTrafficLight(CloudRoadData roadData) {
|
||||
if (isObuLightData) {
|
||||
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTrafficLight(String lightStatus, String surplusTime) {
|
||||
this.lightStatus = lightStatus;
|
||||
this.surplusTime = surplusTime;
|
||||
if (lightCenter) {
|
||||
}
|
||||
private void handleObuTrafficLightInfo(int[] lightArray,String[] surplusTimeArray) {
|
||||
vrModeNavInfoView.refreshTrafficLightStatus(lightArray, surplusTimeArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,14 +210,6 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData obj) {
|
||||
Logger.d(TAG, "收到大而全数据: " + obj);
|
||||
CloudRoadData roadData = obj.getTrafficLight();
|
||||
if (roadData != null) {
|
||||
Logger.d(TAG, "收到红绿灯数据");
|
||||
handleCloudTrafficLight(roadData);
|
||||
} else {
|
||||
handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,18 @@ import androidx.annotation.IntDef;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.module.common.constants.TrafficLightConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GRAY;
|
||||
import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_GREEN;
|
||||
import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_RED;
|
||||
import static com.mogo.module.common.constants.TrafficLightConst.TRAFFIC_LIGHT_COLOR_YELLOW;
|
||||
|
||||
/**
|
||||
* vr模式下的纵向显示的红绿灯封装
|
||||
*
|
||||
@@ -26,10 +32,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
public class VerticalTrafficLightView extends ConstraintLayout {
|
||||
private static final String TAG = "VerticalTrafficLightView";
|
||||
public static final int TRAFFIC_LIGHT_COLOR_GRAY = 0;
|
||||
public static final int TRAFFIC_LIGHT_COLOR_RED = 1;
|
||||
public static final int TRAFFIC_LIGHT_COLOR_YELLOW = 2;
|
||||
public static final int TRAFFIC_LIGHT_COLOR_GREEN = 3;
|
||||
|
||||
private ImageView ivTrafficLight, ivNoLeftTime;
|
||||
private TextView tvLeftTime, tvLeftTimeUnit;
|
||||
@@ -90,7 +92,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
|
||||
/**
|
||||
* 设置红绿灯的颜色,根据颜色来展示不同的效果
|
||||
*
|
||||
* @param color 红绿灯颜色{@link #TRAFFIC_LIGHT_COLOR_GRAY},{@link #TRAFFIC_LIGHT_COLOR_RED}等四个颜色
|
||||
* @param color 红绿灯颜色{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_GRAY},{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个颜色
|
||||
*/
|
||||
private void setTrafficLightColor(@TrafficLightColor int color) {
|
||||
if (iconRes == null) {
|
||||
@@ -123,7 +125,7 @@ public class VerticalTrafficLightView extends ConstraintLayout {
|
||||
/**
|
||||
* 设置红绿灯状态,需设置颜色及时长
|
||||
*
|
||||
* @param color 红绿灯颜色,使用{@link #TRAFFIC_LIGHT_COLOR_RED}等四个值
|
||||
* @param color 红绿灯颜色,使用{@link TrafficLightConst#TRAFFIC_LIGHT_COLOR_RED}等四个值
|
||||
* @param leftTime 剩余时长,null或者empty表示没有时长数据
|
||||
*/
|
||||
public void setTrafficLightStatus(@TrafficLightColor int color, String leftTime) {
|
||||
|
||||
Reference in New Issue
Block a user