diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 6fe7f68168..ab50d5c7b2 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -781,6 +781,7 @@ class MogoPrivateObuNewManager private constructor() { CallerTrafficLightListenerManager.disableTrafficLight() isShowGreenWave = false isShowRunRedLight = false + CallerTrafficLightListenerManager.invokeTrafficLightDisapper() } } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index 06eb44312b..da18deaa54 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -125,6 +125,13 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerTrafficLightListenerManager.resetTrafficLightStatus(!hasObuLightStatus) } + /** + * obu数据消失 + */ + override fun onObuTrafficLightDisapper() { + hasObuLightStatus = false + } + /** * obu 红绿灯数据 */ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarManager.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarManager.kt index 5807bf4e57..45badb5762 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarManager.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarManager.kt @@ -101,7 +101,7 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener { } fun modifyCarInfo(callBack: (ModifyBindingcarInfo) -> Unit) { - BindingCarNetWorkManager.instance.modifyBindingcar(mAddress, mWidevineIDWithMd5, callBack, screenType) + BindingCarNetWorkManager.instance.modifyBindingcar(mContext!!, mAddress, mWidevineIDWithMd5, callBack, screenType) } private fun driverScreen(macAddress: String, widevineIDWithMd5: String) { diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarNetWorkManager.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarNetWorkManager.kt index 2ce95132d3..3d14d1bd7a 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarNetWorkManager.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/binding/BindingCarNetWorkManager.kt @@ -75,11 +75,11 @@ class BindingCarNetWorkManager private constructor() { override fun onNext(info: BindingCarInfo) { if (info != null && info.getData() != null) { d(SceneConstant.M_BINDING + TAG, "getBindingcarInfo data =" + info.getData().toString()) + //根据车辆类型切换不同的车辆模型,只针对红旗做处理,当mac地址不一致,切换模型 if (!SharedPrefsMgr.getInstance(context).getString(SharedPrefsConstants.MAC_ADDRESS).equals(macAddress) && DebugConfig.isCarModelChange()) { - updateCarVrIconRes(info.getData().brandId); + updateCarVrIconRes(info.getData().brandId) } - //根据车辆类型切换不同的车辆模型,只针对红旗做处理 - updateCarVrIconRes(info.getData().brandId) + when (info.getData().compare) { "0" -> showBindingCarDialog() "3" -> showModifyBindingCarDialog() @@ -106,6 +106,7 @@ class BindingCarNetWorkManager private constructor() { * mac: 48:b0:2d:3a:9c:19 */ fun modifyBindingcar( + context: Context, macAddress: String?, widevineIDWithMd5: String?, callBack: (ModifyBindingcarInfo) -> Unit, @@ -134,7 +135,11 @@ class BindingCarNetWorkManager private constructor() { SceneConstant.M_BINDING + TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString() ) - updateCarVrIconRes(info.data.brandId) + if (!SharedPrefsMgr.getInstance(context).getString(SharedPrefsConstants.MAC_ADDRESS).equals(macAddress) && DebugConfig.isCarModelChange()) { + updateCarVrIconRes(info.data.brandId) + } + + SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.MAC_ADDRESS, macAddress) } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt new file mode 100644 index 0000000000..61fd81fb64 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt @@ -0,0 +1,79 @@ +package com.mogo.eagle.core.function.hmi.ui.msgbox + +import android.app.Activity +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.recyclerview.widget.LinearLayoutManager +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType +import com.mogo.eagle.core.data.msgbox.MsgCategory +import com.mogo.eagle.core.function.api.msgbox.IMsgBoxListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.ui.msgbox.adapter.MBoxBubbleAdapter +import com.mogo.eagle.core.function.msgbox.MsgBoxConfig +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import kotlinx.android.synthetic.main.layout_m_box_bubble.view.* + +class MBoxBubbleView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener { + + private val TAG = "PassengerMsgBoxBubbleView" + private val dataList :ArrayList = ArrayList() + private var mBoxBubbleAdapter: MBoxBubbleAdapter?= null + private var isShowData = true + + init { + LayoutInflater.from(context).inflate(R.layout.layout_m_box_bubble, this, true) + initView() + } + + private fun initView(){ + val linearLayoutManager = LinearLayoutManager(context) + linearLayoutManager.orientation = LinearLayoutManager.VERTICAL + mBoxBubbleAdapter = MBoxBubbleAdapter(context as Activity) + rvMBoxBubbleList.adapter = mBoxBubbleAdapter + rvMBoxBubbleList.layoutManager = linearLayoutManager + } + + /** + * 是否展示接收消息,消息盒子打开状态下不再展示气泡消息 + * @param show true 展示;false 不展示 + */ + fun isShowData(show: Boolean){ + isShowData = show + } + + override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) { + UiThreadHandler.post { + if(category == MsgCategory.NOTICE){ + if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X + || msgBoxList.type == MsgBoxType.OBU){ + MsgBoxConfig.noticeList.add(msgBoxList) + if(isShowData){ + CallerMsgBoxEventListenerManager.invokeUpdateTipListener(true) + dataList.add(msgBoxList) + mBoxBubbleAdapter?.setData(dataList) + } + } + } + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerMsgBoxListenerManager.addListener(TAG,this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerMsgBoxListenerManager.removeListener(TAG) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt new file mode 100644 index 0000000000..343289ebcd --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt @@ -0,0 +1,119 @@ +package com.mogo.eagle.core.function.hmi.ui.msgbox.adapter + +import android.app.Activity +import android.os.CountDownTimer +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.data.enums.EventTypeEnumNew +import com.mogo.eagle.core.data.msgbox.* +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.util.TimeUtils +import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat + +class MBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter(){ + + private var data: ArrayList ?= null + + private val notice: Int = 1 + private val v2x: Int = 2 + + var countDownTimer: CountDownTimer?=null + + fun setData(data: ArrayList){ + this.data = data + if(data.size>3){ + data.removeAt(0) + } + notifyDataSetChanged() + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + return when (viewType) { + notice -> { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_m_box_notice,parent,false) + BubbleNoticeHolder(view) + } + else -> { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_m_box_v2x,parent,false) + BubbleV2XHolder(view) + } + } + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + when (holder) { + is BubbleNoticeHolder -> { + data?.let { + val noticeFrCloudMsg = it[position].bean as NoticeFrCloudMsg + if(noticeFrCloudMsg.type == 0){ + val noticeNormalData = noticeFrCloudMsg.noticeNormalData + holder.tvMNoticeTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) + holder.tvMNoticeContent.text = noticeNormalData?.content + }else { + val noticeTrafficStylePushData = noticeFrCloudMsg.trafficPushData + holder.tvMNoticeTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) + holder.tvMNoticeContent.text = noticeTrafficStylePushData?.content + } + + } + } + is BubbleV2XHolder -> { + data?.let { + val msgBoxBean = it[position] + val v2XMsg = msgBoxBean.bean as V2XMsg + holder.tvMV2XTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) + holder.tvMV2XContent.text = v2XMsg.content + holder.ivMV2XImage.setImageDrawable(activity.resources.getDrawable( + EventTypeEnumNew.getUpdateIconRes(v2XMsg.type))) + } + } + } + + val msgBoxBean: MsgBoxBean = data!![position] + countDownTimer =object: CountDownTimer(CallerMsgBoxManager.getDismissTime(),1000){ + override fun onTick(p0: Long) { + + } + + override fun onFinish() { + data?.remove(msgBoxBean) + notifyDataSetChanged() +// notifyItemRemoved(index) +// notifyItemRangeChanged(index,recordTypeEntity.size-index) + } + + } + countDownTimer?.start() + } + + override fun getItemCount() = data?.size ?: 0 + + override fun getItemViewType(position: Int): Int { + return if(data!![position].type == MsgBoxType.NOTICE){ + notice + }else{ + v2x + } + } + + //Notice + class BubbleNoticeHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var ivMNoticeImage: ImageView = itemView.findViewById(R.id.ivMNoticeImage) + var tvMNoticeTitle: TextView = itemView.findViewById(R.id.tvMNoticeTitle) + var tvMNoticeContent: TextView = itemView.findViewById(R.id.tvMNoticeContent) + var tvMNoticeTime: TextView = itemView.findViewById(R.id.tvMNoticeTime) + } + + //OBU、V2X + class BubbleV2XHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var ivMV2XImage: ImageView = itemView.findViewById(R.id.ivMV2XImage) + var tvMV2XTime: TextView = itemView.findViewById(R.id.tvMV2XTime) + var tvMV2XContent: TextView = itemView.findViewById(R.id.tvMV2XContent) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_notice.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_notice.xml new file mode 100644 index 0000000000..4f6a9e0465 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_notice.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml new file mode 100644 index 0000000000..60eab23068 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml @@ -0,0 +1,51 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_m_box_bubble.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_m_box_bubble.xml new file mode 100644 index 0000000000..f70a509ba8 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_m_box_bubble.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IMoGoTrafficLightListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IMoGoTrafficLightListener.kt index 58e247b9e3..216a936e78 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IMoGoTrafficLightListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IMoGoTrafficLightListener.kt @@ -30,6 +30,11 @@ interface IMoGoTrafficLightListener { */ fun onTrafficLightPlusSource(light: TrafficLightEnum, remain:Int = -1, lightSource: DataSourceType){} + /** + * obu 红绿灯消失 + */ + fun onObuTrafficLightDisapper(){} + /** * 展示红绿灯预警 * diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt index c903ddbc2a..60e4cd4e78 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/v2x/CallerTrafficLightListenerManager.kt @@ -45,6 +45,13 @@ object CallerTrafficLightListenerManager : CallerBase } } + fun invokeTrafficLightDisapper() { + M_LISTENERS.forEach { + val listener = it.value + listener.onObuTrafficLightDisapper() + } + } + /** * 重置红绿灯状态并隐藏 */