[2.13.2] fix ui bug because of event type enum

This commit is contained in:
zhongchao
2023-01-16 15:47:10 +08:00
parent 6654df6cf5
commit 7b84d2a705
3 changed files with 123 additions and 77 deletions

View File

@@ -9,7 +9,6 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import com.mogo.eagle.core.data.enums.EventTypeEnum
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.msgbox.*
import com.mogo.eagle.core.data.report.ReportEntity
@@ -28,9 +27,10 @@ import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat
* @description 司机端消息盒子列表视图RecyclerView适配器
* @since: 2022/11/25
*/
class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Adapter<RecyclerView.ViewHolder>(){
class DriverMsgBoxListAdapter(private val activity: Activity) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var data: List<MsgBoxBean> ?= null
private var data: List<MsgBoxBean>? = null
private val operation: Int = 1
private val notice: Int = 2
@@ -44,7 +44,7 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
val RESULT_AUTOPILOT_SYSTEM_UNSTARTED = "RESULT_AUTOPILOT_SYSTEM_UNSTARTED"
val RESULT_REMOTEPILOT_DISABLE = "RESULT_REMOTEPILOT_DISABLE"
fun setData(data: List<MsgBoxBean>){
fun setData(data: List<MsgBoxBean>) {
this.data = data
notifyDataSetChanged()
}
@@ -52,27 +52,33 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
when (viewType) {
record -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_bad_case,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_bad_case, parent, false)
return BadCaseHolder(view)
}
report -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_box_ipc_report,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_msg_box_ipc_report, parent, false)
return MsgBoxIpcReportHolder(view)
}
operation -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_box_operation,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_msg_box_operation, parent, false)
return MsgBoxOperation(view)
}
notice -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_box_notice,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_msg_box_notice, parent, false)
return MsgBoxNotice(view)
}
summary -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_box_summary,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_msg_box_summary, parent, false)
return MsgBoxSummary(view)
}
else -> {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_box_v2x,parent,false)
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_msg_box_v2x, parent, false)
return MsgBoxV2X(view)
}
}
@@ -83,53 +89,68 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
when (holder) {
is BadCaseHolder -> {
data?.let {
holder.tvBagReceiveTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvBagRecordTime.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvBagReceiveTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
holder.tvBagRecordTime.text =
"时间:${TimeUtils.millis2String(it[position].timestamp)}"
val msgBoxBean = it[position]
holder.tvRecordCheck.setOnClickListener {
//打开被动录包弹窗
CallerDevaToolsManager.onReceiveBadCaseRecord(msgBoxBean,activity,false)
CallerDevaToolsManager.onReceiveBadCaseRecord(msgBoxBean, activity, false)
}
}
}
is MsgBoxIpcReportHolder -> {
data?.let { it ->
holder.tvReportTimeNormal.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTimeOpen.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTimeNormal.text =
"时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTimeOpen.text =
"时间:${TimeUtils.millis2String(it[position].timestamp)}"
val reportEntity = (it[position].bean as ReportEntity)
if(reportEntity.resultList.contains(RESULT_AUTOPILOT_DISABLE)
if (reportEntity.resultList.contains(RESULT_AUTOPILOT_DISABLE)
|| reportEntity.resultList.contains(RESULT_AUTOPILOT_SYSTEM_UNSTARTED)
|| reportEntity.resultList.contains(RESULT_REMOTEPILOT_DISABLE)){
|| reportEntity.resultList.contains(RESULT_REMOTEPILOT_DISABLE)
) {
//Error
holder.ivReportImageNormal.setImageDrawable(getDrawable(R.drawable.icon_report_error_normal))
holder.ivReportImageOpen.setImageDrawable(getDrawable(R.drawable.icon_report_error_open))
holder.tvReportLevelNormal.text = "Error"
holder.tvReportLevelOpen.text = "Error"
}else{
} else {
//Warning
holder.ivReportImageNormal.setImageDrawable(getDrawable(R.drawable.icon_report_warning_normal))
holder.ivReportImageOpen.setImageDrawable(getDrawable(R.drawable.icon_report_warning_open))
holder.tvReportLevelNormal.text = "Warning"
holder.tvReportLevelOpen.text = "Warning"
}
holder.tvReportTimeNormal.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTimeOpen.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTime.text =TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvReportTimeNormal.text =
"时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTimeOpen.text =
"时间:${TimeUtils.millis2String(it[position].timestamp)}"
holder.tvReportTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
var resultStr = "类型:"
for (result in reportEntity.resultList){
resultStr = "${resultStr}${CallerAutoPilotManager.getReportResultDesc(result)}"
for (result in reportEntity.resultList) {
resultStr =
"${resultStr}${CallerAutoPilotManager.getReportResultDesc(result)}"
}
holder.tvReportTypeNormal.text = resultStr
holder.tvReportTypeOpen.text = resultStr
holder.tvReportReasonOpen.text = "原因:${reportEntity.msg}"
var actionStr = ""
for (action in reportEntity.actionsList){
actionStr = "${actionStr}${CallerAutoPilotManager.getReportActionDesc(action)}"
for (action in reportEntity.actionsList) {
actionStr =
"${actionStr}${CallerAutoPilotManager.getReportActionDesc(action)}"
}
holder.tvReportActionOpen.text = "建议操作:$actionStr"
holder.tvStatusSelect.setOnClickListener {
if(holder.tvReportLevelNormal.isVisible){
holder.tvStatusSelect.setCompoundDrawablesWithIntrinsicBounds(getDrawable(R.drawable.icon_msg_close),null,null,null)
if (holder.tvReportLevelNormal.isVisible) {
holder.tvStatusSelect.setCompoundDrawablesWithIntrinsicBounds(
getDrawable(R.drawable.icon_msg_close),
null,
null,
null
)
holder.ivReportImageNormal.visibility = View.GONE
holder.tvReportLevelNormal.visibility = View.GONE
holder.tvReportTimeNormal.visibility = View.GONE
@@ -141,8 +162,13 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
holder.tvReportTypeOpen.visibility = View.VISIBLE
holder.tvReportReasonOpen.visibility = View.VISIBLE
holder.tvReportActionOpen.visibility = View.VISIBLE
}else{
holder.tvStatusSelect.setCompoundDrawablesWithIntrinsicBounds(getDrawable(R.drawable.icon_msg_open),null,null,null)
} else {
holder.tvStatusSelect.setCompoundDrawablesWithIntrinsicBounds(
getDrawable(R.drawable.icon_msg_open),
null,
null,
null
)
holder.ivReportImageNormal.visibility = View.VISIBLE
holder.tvReportLevelNormal.visibility = View.VISIBLE
holder.tvReportTimeNormal.visibility = View.VISIBLE
@@ -163,10 +189,16 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
val operationMsg = it[position].bean as OperationMsg
holder.tvOperationContentNormal.text = operationMsg.content
holder.tvOperationContentOpen.text = operationMsg.content
holder.tvOperationTime.text = TimeUtils.millis2String(operationMsg.timestamp,getHourMinFormat())
holder.tvOperationTime.text =
TimeUtils.millis2String(operationMsg.timestamp, getHourMinFormat())
holder.tvOperationStatusSelect.setOnClickListener {
if(holder.ivOperationImageNormal.isVisible){
holder.tvOperationStatusSelect.setCompoundDrawablesWithIntrinsicBounds(getDrawable(R.drawable.icon_msg_close),null,null,null)
if (holder.ivOperationImageNormal.isVisible) {
holder.tvOperationStatusSelect.setCompoundDrawablesWithIntrinsicBounds(
getDrawable(R.drawable.icon_msg_close),
null,
null,
null
)
holder.ivOperationImageNormal.visibility = View.GONE
holder.tvOperationTitleNormal.visibility = View.GONE
holder.tvOperationContentNormal.visibility = View.GONE
@@ -174,8 +206,13 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
holder.ivOperationImageOpen.visibility = View.VISIBLE
holder.tvOperationTitleOpen.visibility = View.VISIBLE
holder.tvOperationContentOpen.visibility = View.VISIBLE
}else{
holder.tvOperationStatusSelect.setCompoundDrawablesWithIntrinsicBounds(getDrawable(R.drawable.icon_msg_open),null,null,null)
} else {
holder.tvOperationStatusSelect.setCompoundDrawablesWithIntrinsicBounds(
getDrawable(R.drawable.icon_msg_open),
null,
null,
null
)
holder.ivOperationImageNormal.visibility = View.VISIBLE
holder.tvOperationTitleNormal.visibility = View.VISIBLE
holder.tvOperationContentNormal.visibility = View.VISIBLE
@@ -190,9 +227,10 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
is MsgBoxNotice -> {
data?.let {
val noticeFrCloudMsg = it[position].bean as NoticeFrCloudMsg
if(noticeFrCloudMsg.type == 0){
if (noticeFrCloudMsg.type == 0) {
val noticeNormalData = noticeFrCloudMsg.noticeNormalData
holder.tvNoticeTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvNoticeTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
holder.tvNoticeContent.text = noticeNormalData?.content
GlideApp.with(activity).load(noticeNormalData?.imageUrl).optionalTransform(
GlideRoundedCornersTransform(
@@ -204,19 +242,25 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
//云公告
noticeNormalData?.let { it1 -> CallerHmiManager.showNoticeNormalData(it1) }
}
}else if(noticeFrCloudMsg.type == 1){
} else if (noticeFrCloudMsg.type == 1) {
val noticeTrafficStylePushData = noticeFrCloudMsg.trafficPushData
holder.tvNoticeTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvNoticeTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
holder.tvNoticeContent.text = noticeTrafficStylePushData?.content
GlideApp.with(activity).load(noticeTrafficStylePushData?.poiImgUrl).optionalTransform(
GlideRoundedCornersTransform(
20f,
GlideRoundedCornersTransform.CornerType.ALL
)
).into(holder.ivNoticeImage)
GlideApp.with(activity).load(noticeTrafficStylePushData?.poiImgUrl)
.optionalTransform(
GlideRoundedCornersTransform(
20f,
GlideRoundedCornersTransform.CornerType.ALL
)
).into(holder.ivNoticeImage)
holder.tvNoticeCheck.setOnClickListener {
//云公告
noticeTrafficStylePushData?.let { it1 -> CallerHmiManager.showTrafficBanner(it1) }
noticeTrafficStylePushData?.let { it1 ->
CallerHmiManager.showTrafficBanner(
it1
)
}
}
}
@@ -226,21 +270,19 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
data?.let {
val msgBoxBean = it[position]
val v2XMsg = msgBoxBean.bean as V2XMsg
holder.tvV2XTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvV2XTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
holder.tvV2XContent.text = v2XMsg.content
if(msgBoxBean.type == MsgBoxType.OBU){
holder.ivV2XImage.setImageDrawable(activity.resources.getDrawable(
EventTypeEnumNew.getUpdateIconRes(v2XMsg.type)))
}else{
holder.ivV2XImage.setImageDrawable(activity.resources.getDrawable(
EventTypeEnum.getUpdateIconRes(v2XMsg.type)))
}
holder.ivV2XImage.setImageDrawable(activity.resources.getDrawable(
EventTypeEnumNew.getUpdateIconRes(v2XMsg.type))
)
}
}
is MsgBoxSummary -> {
data?.let {
val summaryMsg = it[position].bean as V2XMsg
holder.tvSummaryTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat())
holder.tvSummaryTime.text =
TimeUtils.millis2String(it[position].timestamp, getHourMinFormat())
holder.tvSummaryContent.text = summaryMsg.content
}
}
@@ -251,30 +293,30 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
override fun getItemViewType(position: Int): Int {
return if(data!![position].type == MsgBoxType.OPERATION){
return if (data!![position].type == MsgBoxType.OPERATION) {
operation
}else if(data!![position].type == MsgBoxType.NOTICE){
} else if (data!![position].type == MsgBoxType.NOTICE) {
notice
}else if(data!![position].type == MsgBoxType.V2X && data!![position].sourceType == DataSourceType.SUMMARY){
} else if (data!![position].type == MsgBoxType.V2X && data!![position].sourceType == DataSourceType.SUMMARY) {
summary
}else if(data!![position].type == MsgBoxType.REPORT){
} else if (data!![position].type == MsgBoxType.REPORT) {
report
}else if(data!![position].type == MsgBoxType.RECORD){
} else if (data!![position].type == MsgBoxType.RECORD) {
record
}else{
} else {
v2x
}
}
//录包实体
class BadCaseHolder(itemView: View): RecyclerView.ViewHolder(itemView){
var tvBagRecordTime: TextView= itemView.findViewById(R.id.tvBagRecordTime)
class BadCaseHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvBagRecordTime: TextView = itemView.findViewById(R.id.tvBagRecordTime)
var tvBagReceiveTime: TextView = itemView.findViewById(R.id.tvBagReceiveTime)
var tvRecordCheck: TextView = itemView.findViewById(R.id.tvRecordCheck)
}
//车辆系统信息
class MsgBoxIpcReportHolder(itemView: View): RecyclerView.ViewHolder(itemView){
class MsgBoxIpcReportHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var ivReportImageNormal: ImageView = itemView.findViewById(R.id.ivReportImageNormal)
var tvReportLevelNormal: TextView = itemView.findViewById(R.id.tvReportLevelNormal)
var tvReportTimeNormal: TextView = itemView.findViewById(R.id.tvReportTimeNormal)
@@ -290,10 +332,11 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
}
//运营平台
class MsgBoxOperation(itemView: View): RecyclerView.ViewHolder(itemView){
class MsgBoxOperation(itemView: View) : RecyclerView.ViewHolder(itemView) {
var ivOperationImageNormal: ImageView = itemView.findViewById(R.id.ivOperationImageNormal)
var tvOperationTitleNormal: TextView = itemView.findViewById(R.id.tvOperationTitleNormal)
var tvOperationContentNormal: TextView = itemView.findViewById(R.id.tvOperationContentNormal)
var tvOperationContentNormal: TextView =
itemView.findViewById(R.id.tvOperationContentNormal)
var tvOperationStatusSelect: TextView = itemView.findViewById(R.id.tvOperationStatusSelect)
var tvOperationTime: TextView = itemView.findViewById(R.id.tvOperationTime)
var ivOperationImageOpen: ImageView = itemView.findViewById(R.id.ivOperationImageOpen)
@@ -302,7 +345,7 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
}
//Notice
class MsgBoxNotice(itemView: View): RecyclerView.ViewHolder(itemView){
class MsgBoxNotice(itemView: View) : RecyclerView.ViewHolder(itemView) {
var ivNoticeImage: ImageView = itemView.findViewById(R.id.ivNoticeImage)
var tvNoticeTitle: TextView = itemView.findViewById(R.id.tvNoticeTitle)
var tvNoticeTime: TextView = itemView.findViewById(R.id.tvNoticeTime)
@@ -311,14 +354,14 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : RecyclerView.Ada
}
//V2X,OBU
class MsgBoxV2X(itemView: View): RecyclerView.ViewHolder(itemView){
class MsgBoxV2X(itemView: View) : RecyclerView.ViewHolder(itemView) {
var ivV2XImage: ImageView = itemView.findViewById(R.id.ivV2XImage)
var tvV2XTime: TextView = itemView.findViewById(R.id.tvV2XTime)
var tvV2XContent: TextView = itemView.findViewById(R.id.tvV2XContent)
}
//汇总消息
class MsgBoxSummary(itemView: View): RecyclerView.ViewHolder(itemView){
class MsgBoxSummary(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvSummaryContent: TextView = itemView.findViewById(R.id.tvSummaryContent)
var tvSummaryTime: TextView = itemView.findViewById(R.id.tvSummaryTime)
}

View File

@@ -9,6 +9,8 @@ import android.text.style.ForegroundColorSpan;
import android.util.Log;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
import com.mogo.eagle.core.data.enums.WarningDirectionEnum;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
@@ -19,10 +21,11 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.function.v2x.events.scenario.impl.AbsV2XScenario;
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import java.math.BigDecimal;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@@ -62,9 +65,9 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
CallerLogger.INSTANCE.d(M_V2X + TAG, "----- show --- 1 --:\n" + (mMarkerEntity == null ? "null" : mMarkerEntity.toString()));
if (mMarkerEntity != null) {
CallerLogger.INSTANCE.d(M_V2X + TAG, "----- show --- 2 --:\n" + mMarkerEntity);
int v2xType = getV2XTypeForFrontWarning(mMarkerEntity);
String v2xType = getV2XTypeForFrontWarning(mMarkerEntity);
V2XMessageEntity entity = getV2XMessageEntity();
if (v2xType != 0) {
if (!v2xType.equals("0")) {
if (getAlertContentForFrontWarning(mMarkerEntity).toString() == null
|| getAlertContentForFrontWarning(mMarkerEntity).toString().isEmpty()
|| mMarkerEntity.getTts() == null || mMarkerEntity.getTts().isEmpty()) {
@@ -86,19 +89,19 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
}
}
private int getV2XTypeForFrontWarning(V2XWarningTarget entity) {
private String getV2XTypeForFrontWarning(V2XWarningTarget entity) {
switch (entity.getType()) {
case 1:
case 11:
entity.setTts("注意行人");
return 0X2B0201;
return EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.getPoiType();
case 2:
entity.setTts("注意自行车");
case 4:
entity.setTts("注意摩托车");
return 0X2B0202;
return EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.getPoiType();
}
return 0;
return "0";
}
private CharSequence getAlertContentForFrontWarning(V2XWarningTarget entity) {