增加限速监听
CallLimitingVelocityListenerManager.addListener(LimitingVelocityListener)

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-03-11 19:33:43 +08:00
parent 839df02f43
commit 90b2f095e4
8 changed files with 85 additions and 34 deletions

View File

@@ -3,9 +3,6 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.service.IMogoServiceApis
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.utilcode.util.SharedPrefs
@@ -19,14 +16,10 @@ class NoticeNormalBroadcastReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "NoticeNormalBroadcastReceiver"
private var mMogoServiceApis: IMogoServiceApis? = null
}
override fun onReceive(context: Context, intent: Intent) {
try {
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
// 分发场景
dispatchShowWaring("11", "官方公告", "测试普通云公告普通云公告普通云公告普通云公告普通云公告普通云公告普通云公告哈哈哈哈哈哈好好",
"https://dataservice-1255510688.cos.ap-beijing.myqcloud.com/carImg/yycp_NoticeDETAIL_location.png",

View File

@@ -3,17 +3,8 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.SharedPrefs
import com.mogo.service.IMogoServiceApis
/**
* 转向灯,刹车

View File

@@ -3,12 +3,9 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.service.IMogoServiceApis
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 控制限速标志
@@ -20,13 +17,10 @@ class V2XLimitingVelocityBroadcastReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "V2XLimitingVelocityBroadcastReceiver"
private var mMogoServiceApis: IMogoServiceApis? = null
}
override fun onReceive(context: Context, intent: Intent) {
try {
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
mContext = context
val limitingVelocityIsShow =

View File

@@ -3,12 +3,9 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.service.IMogoServiceApis
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 触发红绿灯场景
@@ -20,13 +17,10 @@ class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "V2XTrafficLightBroadcastReceiver"
private var mMogoServiceApis: IMogoServiceApis? = null
}
override fun onReceive(context: Context, intent: Intent) {
try {
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
mContext = context
val trafficLightIsShow =

View File

@@ -3,13 +3,10 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.service.IMogoServiceApis
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式弹出预警提示框
@@ -21,13 +18,10 @@ class V2XWarningBroadcastReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "V2XWarningBroadcastReceiver"
private var mMogoServiceApis: IMogoServiceApis? = null
}
override fun onReceive(context: Context, intent: Intent) {
try {
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
mContext = context
val v2xIsShow =
intent.getBooleanExtra(WaringConst.BROADCAST_V2X_IS_SHOW_EXTRA_KEY, false)

View File

@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.v2x.speedlimit;
import android.location.Location;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.v2x.CallLimitingVelocityListenerManager;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
@@ -39,6 +40,7 @@ public class SpeedLimitDataManager implements IMogoCarLocationChangedListener2 {
public void run() {
if (speedLimmit > 0) {
CallerHmiManager.INSTANCE.showLimitingVelocity(speedLimmit);
CallLimitingVelocityListenerManager.INSTANCE.invokeOnLimitingVelocityChange(speedLimmit);
}
}
});

View File

@@ -0,0 +1,8 @@
package com.mogo.eagle.core.function.api.v2x
/**
* 限速信息回掉
*/
interface LimitingVelocityListener {
fun onLimitingVelocityChange(limitingVelocity: Int)
}

View File

@@ -0,0 +1,75 @@
package com.mogo.eagle.core.function.call.v2x
import androidx.annotation.Nullable
import com.mogo.eagle.core.function.api.v2x.LimitingVelocityListener
import com.mogo.eagle.core.utilcode.util.LogUtils
import java.util.concurrent.ConcurrentHashMap
/**
* 限速信息监听
*/
object CallLimitingVelocityListenerManager {
private const val TAG = "CallLimitingVelocityListenerManager"
private val M_TRAFFIC_LIGHT_LISTENER: ConcurrentHashMap<String, LimitingVelocityListener> =
ConcurrentHashMap()
private var mCurrentLimitingVelocity = 0
/**
* 添加监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addListener(
@Nullable tag: String,
@Nullable listener: LimitingVelocityListener
) {
if (M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
return
}
listener.onLimitingVelocityChange(mCurrentLimitingVelocity)
M_TRAFFIC_LIGHT_LISTENER[tag] = listener
}
/**
* 删除监听
* @param tag 标记,用来注销监听使用
*/
fun removeListener(@Nullable tag: String) {
if (!M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
LogUtils.eTag(TAG, "Tag:$tag not exists")
return
}
M_TRAFFIC_LIGHT_LISTENER.remove(tag)
}
/**
* 删除监听
* @param listener 要删除的监听对象
*/
fun removeListener(@Nullable listener: LimitingVelocityListener) {
if (!M_TRAFFIC_LIGHT_LISTENER.containsValue(listener)) {
LogUtils.eTag(TAG, "listener:$listener not exists")
return
}
M_TRAFFIC_LIGHT_LISTENER.forEach {
if (it.value == listener) {
M_TRAFFIC_LIGHT_LISTENER.remove(it.key)
}
}
}
fun invokeOnLimitingVelocityChange(limitingVelocity: Int) {
this.mCurrentLimitingVelocity = limitingVelocity
M_TRAFFIC_LIGHT_LISTENER.forEach {
val tag = it.key
//LogUtils.dTag(TAG, "invokeOnLimitingVelocityChange tag is : $tag")
val listener = it.value
listener.onLimitingVelocityChange(limitingVelocity)
}
}
}