[dev_robobus-d_230322_3.0.0]云调度和Bus乘客端消息盒子

This commit is contained in:
xuxinchao
2023-03-23 20:40:21 +08:00
parent bea5373226
commit 26f49ac7cc
17 changed files with 799 additions and 30 deletions

View File

@@ -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<MsgBoxCountDownBean> = 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)
}
}

View File

@@ -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<RecyclerView.ViewHolder>() {
private var data: ArrayList<MsgBoxCountDownBean> ?= null
private val notice: Int = 1
private val v2x: Int = 2
private val operation: Int = 3
fun setData(data: ArrayList<MsgBoxCountDownBean>){
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)
}
}

View File

@@ -21,6 +21,10 @@ public class DispatchCarsDialog extends DispatchBaseDialog {
private final TextView tvTimer;
private final TextView tvLoc;
private final TextView tvAdasDispatchTitle;
private final TextView tvAdasDispatchRemindContent;
private int dispatchType = 1;//调度类型1启动 2停止
private final Handler handler = new Handler() {
@Override
@@ -44,21 +48,40 @@ public class DispatchCarsDialog extends DispatchBaseDialog {
setCanceledOnTouchOutside(false);
tvTimer = findViewById(R.id.module_adas_dispatch_remind_timer);
tvLoc = findViewById(R.id.module_adas_dispatch_remind_loc);
Button btnAffirm = (Button) findViewById(R.id.module_adas_dispatch_remind_affirm);
Button btnCancel = (Button) findViewById(R.id.module_adas_dispatch_remind_cancel);
tvAdasDispatchTitle = findViewById(R.id.tv_adas_dispatch_title);
tvAdasDispatchRemindContent = findViewById(R.id.tv_adas_dispatch_remind_content);
Button btnAffirm = findViewById(R.id.module_adas_dispatch_remind_affirm);
Button btnCancel = findViewById(R.id.module_adas_dispatch_remind_cancel);
tvTimer.setText(String.valueOf(TIMER));
btnAffirm.setOnClickListener(v -> {
CallerFuncBizManager.getBizProvider().dispatchAffirm();
if(dispatchType == 1){
//开始调度确认
CallerFuncBizManager.getBizProvider().dispatchAffirm();
}else if(dispatchType == 2){
//停止调度确认
CallerFuncBizManager.getBizProvider().stopDispatchAffirm();
}
dismissDialog();
});
btnCancel.setOnClickListener(v -> {
CallerFuncBizManager.getBizProvider().dispatchCancel(true);
if(dispatchType == 1){
//开始调度手动取消
CallerFuncBizManager.getBizProvider().dispatchCancel(true);
}else if(dispatchType == 2){
//停止调度手动取消
CallerFuncBizManager.getBizProvider().stopDispatchCancel(true);
}
dismissDialog();
});
}
private void hideDialog() {
CallerFuncBizManager.getBizProvider().dispatchCancel(false);
if(dispatchType == 1){
//开始调度自动取消
CallerFuncBizManager.getBizProvider().dispatchCancel(false);
}else if(dispatchType == 2){
CallerFuncBizManager.getBizProvider().stopDispatchCancel(false);
}
dismissDialog();
}
@@ -74,6 +97,12 @@ public class DispatchCarsDialog extends DispatchBaseDialog {
return;
}
show();
if(dispatchContent.getType() == 2){
//取消调度
tvAdasDispatchTitle.setText("调度取消确认");
tvAdasDispatchRemindContent.setText("车辆将取消到以下位置的自动驾驶");
}
dispatchType = dispatchContent.getType();
handler.sendEmptyMessage(MSG_TYPE_TIMER);
tvLoc.setText(dispatchContent.getEndLocAddress());
}

View File

@@ -54,15 +54,17 @@ public class DispatchDialogManager {
}
private void dispatchHengYang(DispatchAdasAutoPilotLocReceiverBean msgData) {
if (msgData.getType() == DISPATCH_TYPE_START) { //衡阳只有开始调度
if (dialog != null && dialog.isShowing()) { //避免下发两次
return;
}
if (dialog == null) {
dialog = new DispatchCarsDialog(mContext);
}
dialog.showDialog(msgData);
// if (msgData.getType() == DISPATCH_TYPE_START) { //衡阳只有开始调度
// }
//开始、取消调度
if (dialog != null && dialog.isShowing()) { //避免下发两次
return;
}
if (dialog == null) {
dialog = new DispatchCarsDialog(mContext);
}
dialog.showDialog(msgData);
}
private void dispatchEZhou(DispatchAdasAutoPilotLocReceiverBean msgData) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -19,6 +19,7 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_adas_dispatch_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/module_services_dispatch_cars_dialog_title_margin_top"
@@ -30,6 +31,7 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_adas_dispatch_remind_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/module_services_dispatch_cars_dialog_content_margin_top"

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_637"
android:layout_height="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E3ECFE"
app:roundLayoutRadius="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_12"
>
<ImageView
android:id="@+id/ivBusPNoticeImage"
android:layout_width="@dimen/dp_107"
android:layout_height="@dimen/dp_107"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@drawable/icon_bus_passenger_logo"
android:layout_marginStart="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPNoticeTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#991A273F"
android:textSize="@dimen/dp_36"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPNoticeContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/ivBusPNoticeImage"
app:layout_constraintRight_toLeftOf="@id/tvBusPNoticeTime"
android:layout_marginStart="@dimen/dp_26"
android:layout_marginEnd="@dimen/dp_16"
android:textColor="#FF203555"
android:textSize="@dimen/dp_36"
android:gravity="start"
android:maxLines="3"
android:ellipsize="end"
/>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_637"
android:layout_height="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E3ECFE"
app:roundLayoutRadius="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_12"
>
<ImageView
android:id="@+id/ivBusPOperationImage"
android:layout_width="@dimen/dp_107"
android:layout_height="@dimen/dp_107"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@drawable/icon_bus_passenger_logo"
android:layout_marginStart="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPOperationTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#991A273F"
android:textSize="@dimen/dp_36"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPOperationContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/ivBusPOperationImage"
app:layout_constraintRight_toLeftOf="@id/tvBusPOperationTime"
android:layout_marginStart="@dimen/dp_26"
android:layout_marginEnd="@dimen/dp_16"
android:textColor="#FF203555"
android:textSize="@dimen/dp_36"
android:gravity="start"
android:maxLines="3"
android:ellipsize="end"
/>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_637"
android:layout_height="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E3ECFE"
app:roundLayoutRadius="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_12"
>
<ImageView
android:id="@+id/ivBusPV2XImage"
android:layout_width="@dimen/dp_107"
android:layout_height="@dimen/dp_107"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPV2XTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#991A273F"
android:textSize="@dimen/dp_36"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="@dimen/dp_26"
/>
<TextView
android:id="@+id/tvBusPV2XContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/ivBusPV2XImage"
app:layout_constraintRight_toLeftOf="@id/tvBusPV2XTime"
android:layout_marginStart="@dimen/dp_26"
android:layout_marginEnd="@dimen/dp_16"
android:textColor="#FF203555"
android:textSize="@dimen/dp_36"
android:gravity="start"
android:maxLines="1"
android:ellipsize="end"
/>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rvBusBoxBubbleList"
android:layout_width="@dimen/dp_637"
android:layout_height="wrap_content"
>
</androidx.recyclerview.widget.RecyclerView>