changed the traffic light style
This commit is contained in:
@@ -23,6 +23,8 @@ public class WaringConst {
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_IS_SHOW__EXTRA_KEY = "trafficLightIsShow";
|
||||
// 选中的交通等类型,red、yellow、green
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY = "trafficLightCheckType";
|
||||
// 倒计时
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_COUNT_DOWN_TYPE_EXTRA_KEY = "trafficLightCountDown";
|
||||
|
||||
// 限速标志
|
||||
// 是否展示:true-展示,false-关闭
|
||||
|
||||
@@ -32,10 +32,15 @@ class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
val trafficLightCountDown =
|
||||
intent.getIntExtra(
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_COUNT_DOWN_TYPE_EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
|
||||
if (trafficLightIsShow) {
|
||||
// 分发场景
|
||||
dispatchShowWaring(trafficLightCheckType)
|
||||
dispatchShowWaring(trafficLightCheckType, trafficLightCountDown)
|
||||
} else {
|
||||
dispatchCloseWaring()
|
||||
}
|
||||
@@ -44,14 +49,22 @@ class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示交通灯
|
||||
*
|
||||
* @param trafficLightCheckType 选中的交通的灯 0-都是默认,1-红,2-黄,3-绿
|
||||
* @param trafficLightCountDown 对应交通灯倒计时,如果倒计时为0,则disable
|
||||
*/
|
||||
private fun dispatchShowWaring(trafficLightCheckType: Int) {
|
||||
private fun dispatchShowWaring(trafficLightCheckType: Int, trafficLightCountDown: Int) {
|
||||
CallerHmiManager.showWarningTrafficLight(trafficLightCheckType)
|
||||
if(trafficLightCountDown == 0 ){
|
||||
CallerHmiManager.disableWarningTrafficLightCountDown()
|
||||
}
|
||||
when(trafficLightCheckType){
|
||||
1 -> CallerHmiManager.changeCountdownRed(trafficLightCountDown)
|
||||
2 -> CallerHmiManager.changeCountdownYellow(trafficLightCountDown)
|
||||
3 -> CallerHmiManager.changeCountdownGreen(trafficLightCountDown)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -541,6 +541,13 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
mViewTrafficLight?.disableWarningTrafficLight()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯倒计时
|
||||
*/
|
||||
override fun disableWarningTrafficLightCountDown() {
|
||||
mViewTrafficLight?.disableCountdown()
|
||||
}
|
||||
|
||||
override fun changeCountdownRed(redNum: Int) {
|
||||
mViewTrafficLight?.changeCountdownRed(redNum)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import java.lang.RuntimeException
|
||||
|
||||
class GradientTextView @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet? = null
|
||||
) : AppCompatTextView(context!!, attrs) {
|
||||
private var mLinearGradient: LinearGradient? = null
|
||||
private var mPaint: Paint? = null
|
||||
private var mViewWidth = 0 //文字的宽度
|
||||
private var mViewHeight = 0 //文字的高度
|
||||
private val mTextBound = Rect()
|
||||
private var mColorList : IntArray?//存放颜色的数组
|
||||
private var isVertical = false//默认是横向
|
||||
|
||||
private var mRadius = 0f
|
||||
private var mdx = 0f
|
||||
private var mdy = 0f
|
||||
private var mColor = 0
|
||||
|
||||
init {
|
||||
//设置默认的颜色
|
||||
mColorList = intArrayOf(-0x1, 0xFFFFFFF)
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
if (isVertical) {
|
||||
mViewHeight = measuredHeight
|
||||
} else {
|
||||
mViewWidth = measuredWidth
|
||||
}
|
||||
mPaint = paint
|
||||
val mTipText = text.toString()
|
||||
setStyle()
|
||||
mPaint!!.getTextBounds(mTipText, 0, mTipText.length, mTextBound)
|
||||
mPaint!!.setShadowLayer(mRadius, mdx, mdy, mColor)
|
||||
|
||||
//画出文字
|
||||
canvas.drawText(
|
||||
mTipText,
|
||||
(measuredWidth / 2 - mTextBound.width() / 2).toFloat(),
|
||||
(measuredHeight / 2 + mTextBound.height() / 2).toFloat(),
|
||||
mPaint!!
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* true表示纵向渐变,false变身横向渐变
|
||||
*
|
||||
* @param vertical 纵向
|
||||
*/
|
||||
fun setVertical(vertical: Boolean) {
|
||||
isVertical = vertical
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置渐变的颜色
|
||||
*
|
||||
* @param mColorList
|
||||
*/
|
||||
fun setColorList(mColorList: IntArray?) {
|
||||
if (mColorList != null && mColorList.size < 2) {
|
||||
throw RuntimeException("ColorList's length must be > 2")
|
||||
} else {
|
||||
this.mColorList = mColorList
|
||||
}
|
||||
}
|
||||
|
||||
private fun setStyle() {
|
||||
mPaint!!.isAntiAlias = true
|
||||
mPaint!!.isDither = true
|
||||
mPaint!!.isFilterBitmap = true
|
||||
//前面4个参数分别表示渐变的开始x轴,开始y轴,结束的x轴,结束的y轴,mColorList表示渐变的颜色数组
|
||||
mLinearGradient = LinearGradient(0f,0f,mViewWidth.toFloat(),mViewHeight.toFloat(),mColorList!!,null,Shader.TileMode.CLAMP)
|
||||
mPaint!!.shader = mLinearGradient
|
||||
mPaint!!.strokeJoin = Paint.Join.ROUND
|
||||
mPaint!!.strokeCap = Paint.Cap.ROUND
|
||||
mPaint!!.style = Paint.Style.FILL_AND_STROKE
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置投影层
|
||||
* @param radius
|
||||
* @param dx
|
||||
* @param dy
|
||||
* @param color
|
||||
*/
|
||||
fun setShadowLayerCustom(radius: Float, dx: Float, dy: Float, color: Int) {
|
||||
mRadius = radius
|
||||
mdx = dx
|
||||
mdy = dy
|
||||
mColor = color
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.marginLeft
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
|
||||
/**
|
||||
* 新版红绿灯view
|
||||
*/
|
||||
class SingleTrafficLightView @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : IViewTrafficLight(context, attrs, defStyleAttr) {
|
||||
private var mLightIconIV: ImageView? = null
|
||||
private var mLightIconBG: ImageView? = null
|
||||
private var mLightTimeTV: GradientTextView? = null
|
||||
private var mCurrentLightId = 0
|
||||
|
||||
init {
|
||||
init(context)
|
||||
}
|
||||
|
||||
private fun init(context: Context?) {
|
||||
LayoutInflater.from(context).inflate(R.layout.hmi_view_traffic_light, this, true)
|
||||
mLightIconIV = findViewById(R.id.hmi_traffic_light_iv)
|
||||
mLightIconBG = findViewById(R.id.hmi_traffic_light_bg)
|
||||
mLightTimeTV = findViewById(R.id.hmi_traffic_light_time_tv)
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示红绿灯预警
|
||||
*
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
override fun showWarningTrafficLight(checkLightId: Int) {
|
||||
super.showWarningTrafficLight(checkLightId)
|
||||
mCurrentLightId = checkLightId
|
||||
updateTrafficLightIcon(checkLightId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
override fun disableWarningTrafficLight() {
|
||||
super.disableWarningTrafficLight()
|
||||
UiThreadHandler.post {
|
||||
mCurrentLightId = 0
|
||||
this@SingleTrafficLightView.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun disableCountdown() {
|
||||
super.disableCountdown()
|
||||
UiThreadHandler.post {
|
||||
val lp = this.layoutParams as MarginLayoutParams
|
||||
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_icon_size).toInt()
|
||||
this.layoutParams = lp
|
||||
mLightTimeTV!!.visibility = GONE
|
||||
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.dp_124).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param redNum 红灯倒计时
|
||||
* @param yellowNum 黄灯倒计时
|
||||
* @param greenNum 绿灯倒计时
|
||||
*/
|
||||
override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) {
|
||||
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum)
|
||||
UiThreadHandler.post {
|
||||
resetView()
|
||||
when (mCurrentLightId) {
|
||||
1 -> changeCountdownRed(redNum)
|
||||
2 -> changeCountdownYellow(yellowNum)
|
||||
3 -> changeCountdownGreen(greenNum)
|
||||
else -> UiThreadHandler.post { mLightTimeTV!!.text = "" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownRed(redNum: Int) {
|
||||
super.changeCountdownRed(redNum)
|
||||
UiThreadHandler.post {
|
||||
if (redNum > 0) {
|
||||
resetView()
|
||||
mLightTimeTV!!.setVertical(true)
|
||||
mLightTimeTV!!.setColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.hmi_traffic_light_red_color_up),
|
||||
resources.getColor(R.color.hmi_traffic_light_red_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = redNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownGreen(greenNum: Int) {
|
||||
super.changeCountdownGreen(greenNum)
|
||||
UiThreadHandler.post {
|
||||
if (greenNum > 0) {
|
||||
resetView()
|
||||
mLightTimeTV!!.setVertical(true)
|
||||
mLightTimeTV!!.setColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.hmi_traffic_light_green_color_up),
|
||||
resources.getColor(R.color.hmi_traffic_light_green_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = greenNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownYellow(yellowNum: Int) {
|
||||
super.changeCountdownYellow(yellowNum)
|
||||
UiThreadHandler.post {
|
||||
if (yellowNum > 0) {
|
||||
resetView()
|
||||
mLightTimeTV!!.setVertical(true)
|
||||
mLightTimeTV!!.setColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.hmi_traffic_light_yellow_color_up),
|
||||
resources.getColor(R.color.hmi_traffic_light_yellow_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = yellowNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红绿灯icon
|
||||
*
|
||||
* @param lightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
private fun updateTrafficLightIcon(lightId: Int) {
|
||||
UiThreadHandler.post {
|
||||
when (lightId) {
|
||||
1 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.hmi_light_red_nor)
|
||||
this@SingleTrafficLightView.visibility = VISIBLE
|
||||
}
|
||||
2 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.hmi_lightyellow_nor)
|
||||
this@SingleTrafficLightView.visibility = VISIBLE
|
||||
}
|
||||
3 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.hmi_light_green_nor)
|
||||
this@SingleTrafficLightView.visibility = VISIBLE
|
||||
}
|
||||
else -> this@SingleTrafficLightView.visibility = GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetView(){
|
||||
val lp = this.layoutParams as MarginLayoutParams
|
||||
lp.width = context.resources.getDimension(R.dimen.hmi_traffic_light_layout_width).toInt()
|
||||
this.layoutParams = lp
|
||||
mLightTimeTV!!.visibility = View.VISIBLE
|
||||
mLightIconBG!!.layoutParams.width = context.resources.getDimension(R.dimen.hmi_traffic_light_bg_width).toInt()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
* 时延验证相关接口
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public interface DelayCheckApiServices {
|
||||
|
||||
/**
|
||||
* 空接口
|
||||
* @return 什么都不返回
|
||||
*/
|
||||
@GET("/yycp-test-service/net/delay/heartbeat")
|
||||
Observable<BaseData> emptyInterface();
|
||||
|
||||
/**
|
||||
* 时延上报接口 接口文档如下
|
||||
* http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48967034
|
||||
* @param params 相关参数,详见文档
|
||||
* @return 相关返回值,详见文档
|
||||
*/
|
||||
@POST("/yycp-test-service/net/delay/log")
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
Observable<DelayCheckResponse> uploadDelayCheckData(@Body RequestBody params);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
|
||||
/**
|
||||
* dzt base url
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckHttpConstant {
|
||||
public static final String HOST_DEV = "http://dzt-test.zhidaozhixing.com";
|
||||
public static final String HOST_TEST = "http://dzt-test.zhidaozhixing.com";
|
||||
public static final String HOST_DEMO = "http://dzt-show.zhidaozhixing.com";
|
||||
public static final String HOST_PRODUCT = "http://dzt.zhidaozhixing.com";
|
||||
|
||||
public static String getBaseUrl(){
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_TEST;
|
||||
case DebugConfig.NET_MODE_DEMO:
|
||||
return HOST_DEMO;
|
||||
default:
|
||||
return HOST_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
/**
|
||||
* 延迟检测response
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckResponse extends BaseData {
|
||||
private DelayCheckResult result;
|
||||
|
||||
public DelayCheckResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(DelayCheckResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DelayCheckResponse{" +
|
||||
"result=" + result +
|
||||
", code=" + code +
|
||||
", msg='" + msg + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
/**
|
||||
* 延迟检查返回结果
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckResult {
|
||||
/**
|
||||
* 是否保持心跳
|
||||
*/
|
||||
private boolean necessary;
|
||||
/**
|
||||
* 心跳间隔,单位 s
|
||||
*/
|
||||
private int beatSeconds;
|
||||
|
||||
public boolean isNecessary() {
|
||||
return necessary;
|
||||
}
|
||||
|
||||
public void setNecessary(boolean necessary) {
|
||||
this.necessary = necessary;
|
||||
}
|
||||
|
||||
public int getBeatSeconds() {
|
||||
return beatSeconds;
|
||||
}
|
||||
|
||||
public void setBeatSeconds(int beatSeconds) {
|
||||
this.beatSeconds = beatSeconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DelayCheckResult{" +
|
||||
"necessary=" + necessary +
|
||||
", beatSeconds=" + beatSeconds +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
/**
|
||||
* 时延检测上报请求参数
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckUploadRequest {
|
||||
private String sn;
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
/**
|
||||
* 请求时长
|
||||
*/
|
||||
private long burning;
|
||||
/**
|
||||
* 信号强度
|
||||
*/
|
||||
private int netState;
|
||||
private String place;
|
||||
private String cityCode;
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public long getBurning() {
|
||||
return burning;
|
||||
}
|
||||
|
||||
public void setBurning(long burning) {
|
||||
this.burning = burning;
|
||||
}
|
||||
|
||||
public int getNetState() {
|
||||
return netState;
|
||||
}
|
||||
|
||||
public void setNetState(int netState) {
|
||||
this.netState = netState;
|
||||
}
|
||||
|
||||
public String getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
public void setPlace(String place) {
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DelayCheckUploadRequest{" +
|
||||
"sn='" + sn + '\'' +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", burning=" + burning +
|
||||
", netState=" + netState +
|
||||
", place='" + place + '\'' +
|
||||
", cityCode='" + cityCode + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package com.mogo.eagle.core.function.main.delaycheck;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* 延时验证工具类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class DelayCheckUtil implements Handler.Callback {
|
||||
private final Handler handler = new Handler(this);
|
||||
|
||||
private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
|
||||
/**
|
||||
* 首次延时检测时间间隔,暂定10分钟,等待机器稳定后再做打算
|
||||
*/
|
||||
private static final long FIRST_CHECK_NET_CONNECT_STATUS_DELAY = 10 * 60 * 1000;
|
||||
private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
|
||||
|
||||
private static final int MSG_START_DELAY_CHECK = 1002;
|
||||
/**
|
||||
* 默认检测时间间隔,若服务端正确返回,以服务端返回为主
|
||||
*/
|
||||
private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
|
||||
|
||||
private final Context context;
|
||||
|
||||
public DelayCheckUtil(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每5s检查一下网络状态,网络状态为连接状态时,开始空接口请求以及后续的参数上报
|
||||
*/
|
||||
public void waitingForCheck() {
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, FIRST_CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
|
||||
private long requestTime, netDelay, requestStartSystemTime, requestEndSystem;
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_CHECK_NET_CONNECT_STATUS:
|
||||
if (NetworkUtils.isConnected(context)) {
|
||||
handler.sendEmptyMessage(MSG_START_DELAY_CHECK);
|
||||
} else {
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
return true;
|
||||
case MSG_START_DELAY_CHECK:
|
||||
// 请求空接口
|
||||
startEmptyRequest();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void startEmptyRequest() {
|
||||
requestTime = SystemClock.elapsedRealtime();
|
||||
requestStartSystemTime = System.currentTimeMillis();
|
||||
MoGoRetrofitFactory.getInstance(DelayCheckHttpConstant.getBaseUrl()).create(DelayCheckApiServices.class)
|
||||
.emptyInterface().subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
requestEndSystem = System.currentTimeMillis();
|
||||
netDelay = SystemClock.elapsedRealtime() - requestTime;
|
||||
startUpload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startUpload() {
|
||||
IMogoLocationClient locationClient = CallerMapUIServiceManager.INSTANCE.getSingletonLocationClient(AbsMogoApplication.getApp());
|
||||
MogoLocation lastLocation = null;
|
||||
if (locationClient != null) {
|
||||
lastLocation = locationClient.getLastKnowLocation();
|
||||
}
|
||||
if (lastLocation == null) {
|
||||
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
|
||||
return;
|
||||
}
|
||||
DelayCheckUploadRequest request = new DelayCheckUploadRequest();
|
||||
request.setSn(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
request.setStartTime(requestStartSystemTime);
|
||||
request.setEndTime(requestEndSystem);
|
||||
request.setNetState(NetworkUtils.netStrengthLevel);
|
||||
request.setPlace(lastLocation.getAddress());
|
||||
request.setCityCode(lastLocation.getCityCode());
|
||||
request.setLat(lastLocation.getLatitude());
|
||||
request.setLon(lastLocation.getLongitude());
|
||||
request.setBurning(netDelay);
|
||||
|
||||
RequestBody params = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(request));
|
||||
|
||||
MoGoRetrofitFactory.getInstance(DelayCheckHttpConstant.getBaseUrl()).create(DelayCheckApiServices.class)
|
||||
.uploadDelayCheckData(params).observeOn(Schedulers.io()).subscribeOn(Schedulers.io())
|
||||
.subscribe(new SubscribeImpl<DelayCheckResponse>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(DelayCheckResponse o) {
|
||||
super.onSuccess(o);
|
||||
DelayCheckResult result = o.getResult();
|
||||
if (result.isNecessary()) {
|
||||
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, result.getBeatSeconds() * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.function.main.EventDispatchCenter;
|
||||
import com.mogo.eagle.core.function.main.cards.MogoModulesManager;
|
||||
import com.mogo.eagle.core.function.main.delaycheck.DelayCheckUtil;
|
||||
import com.mogo.eagle.core.function.main.monitoring.VehicleMonitoring;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -55,9 +54,6 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
HdMapBuildConfig.isMapLoaded = true;
|
||||
}, 5_000L
|
||||
);
|
||||
// 开启延时检测
|
||||
DelayCheckUtil delayCheckUtil = new DelayCheckUtil(this);
|
||||
delayCheckUtil.waitingForCheck();
|
||||
// 车辆检测
|
||||
VehicleMonitoring monitoring = new VehicleMonitoring(this);
|
||||
monitoring.vehicleCheck();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#ff000000"/>
|
||||
<corners android:radius="@dimen/hmi_traffic_light_layout_corner"/>
|
||||
</shape>
|
||||
@@ -65,22 +65,19 @@
|
||||
android:layout_marginTop="45px"
|
||||
android:layout_marginEnd="40px"
|
||||
android:background="@drawable/icon_camera_nor"
|
||||
app:layout_constraintEnd_toStartOf="@id/viewTrafficLightVr"
|
||||
app:layout_constraintRight_toLeftOf="@id/viewTrafficLightVr"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--红绿灯-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TrafficLightView
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.SingleTrafficLightView
|
||||
android:id="@+id/viewTrafficLightVr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40px"
|
||||
android:layout_marginEnd="40px"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
android:layout_marginTop="@dimen/hmi_traffic_light_layout_margin_top"
|
||||
android:layout_marginRight="@dimen/hmi_traffic_light_layout_margin_right"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<!--地图视角切换-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.PerspectiveSwitchView
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/hmi_traffic_light_layout_width"
|
||||
android:layout_height="@dimen/hmi_traffic_light_layout_height"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hmi_traffic_light_bg"
|
||||
android:layout_width="@dimen/hmi_traffic_light_bg_width"
|
||||
android:layout_height="@dimen/hmi_traffic_light_bg_height"
|
||||
android:layout_marginStart="@dimen/hmi_traffic_light_bg_margin_left"
|
||||
android:layout_marginTop="@dimen/hmi_traffic_light_bg_margin_top"
|
||||
android:background="@drawable/traffic_light_bg"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hmi_traffic_light_iv"
|
||||
android:layout_width="@dimen/hmi_traffic_light_icon_size"
|
||||
android:layout_height="@dimen/hmi_traffic_light_icon_size"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.GradientTextView
|
||||
android:id="@+id/hmi_traffic_light_time_tv"
|
||||
android:layout_width="@dimen/hmi_traffic_light_time_view_width"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/hmi_traffic_light_time_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -37,4 +37,17 @@
|
||||
<dimen name="dp_580">580px</dimen>
|
||||
<dimen name="dp_588">588px</dimen>
|
||||
<dimen name="dp_1066">1066px</dimen>
|
||||
|
||||
<dimen name="hmi_traffic_light_layout_width">225px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_height">154px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_corner">60px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_margin_right">40px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_margin_top">23px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_width">210px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_height">120px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_margin_left">15px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_margin_top">17px</dimen>
|
||||
<dimen name="hmi_traffic_light_icon_size">154px</dimen>
|
||||
<dimen name="hmi_traffic_light_time_view_width">130px</dimen>
|
||||
<dimen name="hmi_traffic_light_time_size">60px</dimen>
|
||||
</resources>
|
||||
@@ -46,4 +46,11 @@
|
||||
<color name="dialog_bg_color">#3B4577</color>
|
||||
|
||||
<color name="turnlight_bg_color">#000000</color>
|
||||
|
||||
<color name="hmi_traffic_light_red_color_up">#FFFFA28B</color>
|
||||
<color name="hmi_traffic_light_red_color_down">#FFDA1100</color>
|
||||
<color name="hmi_traffic_light_green_color_up">#FF60FFD3</color>
|
||||
<color name="hmi_traffic_light_green_color_down">#FF006D43</color>
|
||||
<color name="hmi_traffic_light_yellow_color_up">#FFFFE198</color>
|
||||
<color name="hmi_traffic_light_yellow_color_down">#FFFF9B00</color>
|
||||
</resources>
|
||||
@@ -42,4 +42,16 @@
|
||||
<dimen name="brakelight_width">460px</dimen>
|
||||
<dimen name="brakelight_height">120px</dimen>
|
||||
|
||||
<dimen name="hmi_traffic_light_layout_width">225px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_height">154px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_corner">60px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_margin_right">40px</dimen>
|
||||
<dimen name="hmi_traffic_light_layout_margin_top">23px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_width">210px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_height">120px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_margin_left">15px</dimen>
|
||||
<dimen name="hmi_traffic_light_bg_margin_top">17px</dimen>
|
||||
<dimen name="hmi_traffic_light_icon_size">154px</dimen>
|
||||
<dimen name="hmi_traffic_light_time_view_width">130px</dimen>
|
||||
<dimen name="hmi_traffic_light_time_size">60px</dimen>
|
||||
</resources>
|
||||
@@ -441,7 +441,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
* V2XEvent事件回调
|
||||
*/
|
||||
override fun onAck(event: V2XEvent) {
|
||||
CallerLogger.d("$M_V2X$TAG", "OK->:$event")
|
||||
CallerLogger.d("$M_V2X$TAG", "OK->: ${event.javaClass.name}")
|
||||
when (event) {
|
||||
is V2XEvent.ForwardsWarning -> {
|
||||
handleAdvanceWarningEvent(event)
|
||||
|
||||
@@ -48,11 +48,11 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
.registerCenterApi.registerCarLocationChangedListener(TAG, this)
|
||||
mThreadHandler =
|
||||
TrafficLightThreadHandler(Looper.getMainLooper(), {
|
||||
//查询路口时,如果红绿灯显示,则隐藏掉
|
||||
if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
}
|
||||
//TODO emArrow 查询路口时,如果红绿灯显示,则隐藏掉
|
||||
// if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
// TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
// CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
// }
|
||||
mLocation?.let { it ->
|
||||
val tileId = CallerMapUIServiceManager.getMapUIController()?.getTileId(it.longitude, it.latitude) ?: 0
|
||||
trafficLightNetWorkModel.requestRoadID(
|
||||
@@ -78,7 +78,7 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
trafficLightNetWorkModel.requestTrafficLight(
|
||||
it.latitude, it.longitude, it.bearing.toDouble(), road, { result ->
|
||||
trafficLightResult = result
|
||||
// TrafficLightHMIManager.INSTANCE.updateTrafficLight(result)
|
||||
TrafficLightHMIManager.INSTANCE.updateTrafficLight(result)
|
||||
CallTrafficLightListenerManager.invokeTrafficLightStatus(result)
|
||||
},
|
||||
{ errorMsg ->
|
||||
|
||||
Reference in New Issue
Block a user