diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml index 44bf9ec81d..f01a26e184 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml @@ -198,4 +198,13 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + \ 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/BusPassengerMsgBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/BusPassengerMsgBoxBubbleView.kt new file mode 100644 index 0000000000..f88d023f2d --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/BusPassengerMsgBoxBubbleView.kt @@ -0,0 +1,81 @@ +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.MsgBoxCountDownBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType +import com.mogo.eagle.core.data.msgbox.MsgCategory +import com.mogo.eagle.core.function.api.datacenter.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.BusPassengerMsgBoxBubbleAdapter +import com.mogo.eagle.core.function.msgbox.MsgBoxConfig +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import kotlinx.android.synthetic.main.layout_bus_passenegr_msg_box_bubble.view.* + +class BusPassengerMsgBoxBubbleView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener { + + private val TAG = "BusPassengerMsgBoxBubbleView" + private val dataList :ArrayList = ArrayList() + private var busPassengerMsgBoxBubbleAdapter: BusPassengerMsgBoxBubbleAdapter?= null + private var isShowData = true + + init { + LayoutInflater.from(context).inflate(R.layout.layout_bus_passenegr_msg_box_bubble, this, true) + initView() + } + + private fun initView(){ + val linearLayoutManager = LinearLayoutManager(context) + linearLayoutManager.orientation = LinearLayoutManager.VERTICAL + busPassengerMsgBoxBubbleAdapter = BusPassengerMsgBoxBubbleAdapter(context as Activity) + rvBusBoxBubbleList.adapter =busPassengerMsgBoxBubbleAdapter + rvBusBoxBubbleList.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 || msgBoxList.type == MsgBoxType.OPERATION){ + MsgBoxConfig.noticeList.add(msgBoxList) + if(isShowData){ + CallerMsgBoxEventListenerManager.invokeUpdateTipListener(true) + val msgBoxCountDownBean = MsgBoxCountDownBean(msgBoxList) + dataList.add(msgBoxCountDownBean) + busPassengerMsgBoxBubbleAdapter?.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/BusPassengerMsgBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/BusPassengerMsgBoxBubbleAdapter.kt new file mode 100644 index 0000000000..a64c894066 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/BusPassengerMsgBoxBubbleAdapter.kt @@ -0,0 +1,136 @@ +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 BusPassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter() { + + private var data: ArrayList ?= null + + private val notice: Int = 1 + private val v2x: Int = 2 + private val operation: Int = 3 + + 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_bus_box_notice,parent,false) + BusBubbleNoticeHolder(view) + } + operation ->{ + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_bus_box_operation,parent,false) + BusBubbleOperationHolder(view) + } + else ->{ + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_bus_box_v2x,parent,false) + BusBubbleV2XHolder(view) + } + } + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int){ + when (holder){ + is BusBubbleNoticeHolder -> { + data?.let{ + val noticeFrCloudMsg = it[position].msgBoxBean.bean as NoticeFrCloudMsg + if(noticeFrCloudMsg.type == 0){ + val noticeNormalData = noticeFrCloudMsg.noticeNormalData + holder.tvBusPNoticeTime.text = TimeUtils.millis2String(it[position].msgBoxBean.timestamp,getHourMinFormat()) + holder.tvBusPNoticeContent.text = noticeNormalData?.content + }else{ + val noticeTrafficStylePushData = noticeFrCloudMsg.trafficPushData + holder.tvBusPNoticeTime.text = TimeUtils.millis2String(it[position].msgBoxBean.timestamp,getHourMinFormat()) + holder.tvBusPNoticeContent.text = noticeTrafficStylePushData?.content + } + } + } + is BusBubbleOperationHolder -> { + //运营消息 + data?.let{ + val operationMsg = it[position].msgBoxBean.bean as OperationMsg + holder.tvBusPOperationTime.text = TimeUtils.millis2String(it[position].msgBoxBean.timestamp,getHourMinFormat()) + holder.tvBusPOperationContent.text = operationMsg.content + } + } + is BusBubbleV2XHolder -> { + data?.let{ + val msgBoxBean = it[position] + val v2XMsg = msgBoxBean.msgBoxBean.bean as V2XMsg + holder.tvBusPV2XTime.text = TimeUtils.millis2String(it[position].msgBoxBean.timestamp,getHourMinFormat()) + holder.tvBusPV2XContent.text = v2XMsg.content + holder.ivBusPV2XImage.setImageDrawable(activity.resources.getDrawable( + EventTypeEnumNew.getUpdateIconRes(v2XMsg.type))) + } + } + } + + val msgBoxBean: MsgBoxCountDownBean = data!![position] + msgBoxBean.countDownTimer =object: CountDownTimer(CallerMsgBoxManager.getDismissTime(),CallerMsgBoxManager.getDismissTime()){ + override fun onTick(p0: Long) { + + } + + override fun onFinish() { + data?.remove(msgBoxBean) + notifyDataSetChanged() +// notifyItemRemoved(index) +// notifyItemRangeChanged(index,recordTypeEntity.size-index) + } + + } + msgBoxBean.countDownTimer?.start() + + } + + override fun getItemCount() = data?.size ?: 0 + + override fun getItemViewType(position: Int): Int{ + return if(data!![position].msgBoxBean.type == MsgBoxType.NOTICE){ + notice + }else if(data!![position].msgBoxBean.type == MsgBoxType.OPERATION){ + operation + } else{ + v2x + } + } + + //Notice + class BusBubbleNoticeHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var tvBusPNoticeTime: TextView = itemView.findViewById(R.id.tvBusPNoticeTime) + var tvBusPNoticeContent: TextView = itemView.findViewById(R.id.tvBusPNoticeContent) + } + + //OBU、V2X + class BusBubbleV2XHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var ivBusPV2XImage: ImageView = itemView.findViewById(R.id.ivBusPV2XImage) + var tvBusPV2XTime: TextView = itemView.findViewById(R.id.tvBusPV2XTime) + var tvBusPV2XContent: TextView = itemView.findViewById(R.id.tvBusPV2XContent) + } + + //运营消息 + class BusBubbleOperationHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var tvBusPOperationTime: TextView = itemView.findViewById(R.id.tvBusPOperationTime) + var tvBusPOperationContent: TextView = itemView.findViewById(R.id.tvBusPOperationContent) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_bus_passenger_logo.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_bus_passenger_logo.png new file mode 100644 index 0000000000..f3b37355cc Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_bus_passenger_logo.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_notice.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_notice.xml new file mode 100644 index 0000000000..0646df15c7 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_notice.xml @@ -0,0 +1,52 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_operation.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_operation.xml new file mode 100644 index 0000000000..c73c5380ef --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_operation.xml @@ -0,0 +1,52 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_v2x.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_v2x.xml new file mode 100644 index 0000000000..1c4c09f901 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_bus_box_v2x.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_bus_passenegr_msg_box_bubble.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_bus_passenegr_msg_box_bubble.xml new file mode 100644 index 0000000000..72ab34e2f5 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/layout_bus_passenegr_msg_box_bubble.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file