[6.7.0]去除司机端旧版消息盒子

This commit is contained in:
xuxinchao
2024-09-20 17:39:58 +08:00
parent 6db0ade534
commit 7b26c6a3a4
11 changed files with 338 additions and 249 deletions

View File

@@ -0,0 +1,338 @@
package com.mogo.eagle.core.function.hmi.bone.tab
import android.app.Activity
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgCategory
import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxEventListener
import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxListener
import com.mogo.eagle.core.function.api.order.IOrderListener
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.ui.msgbox.adapter.DriverMsgBoxListAdapter
import com.mogo.eagle.core.function.msgbox.MsgBoxConfig
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.layout_driver_msg_box_list.view.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
/**
* @author XuXinChao
* @description 司机端消息盒子打开列表视图
* @since: 2022/11/25
*/
class MsgBoxListTabView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) , IMsgBoxListener, IMsgBoxEventListener,
IOrderListener {
init {
LayoutInflater.from(context).inflate(R.layout.layout_driver_msg_box_list, this, true)
initView()
}
private val TAG = "DriverMsgBoxListView"
private var noticeList: ArrayList<MsgBoxBean> ?= null //通知消息列表
private var fmList: ArrayList<MsgBoxBean> ?= ArrayList() //FM信息消息列表
private var ipcReportList: ArrayList<MsgBoxBean> ?= null //车辆系统信息消息列表
private var badCaseList: ArrayList<MsgBoxBean> ?= null//录包消息列表
private var driverMsgBoxListAdapter: DriverMsgBoxListAdapter ?=null
private var linearLayoutManager: LinearLayoutManager ?= null
private var isShowSummary = false //是否展示汇总消息
private fun initView() {
driverMsgBoxListAdapter= DriverMsgBoxListAdapter(context as Activity)
rvMsgBoxList.adapter = driverMsgBoxListAdapter
linearLayoutManager = LinearLayoutManager(context)
rvMsgBoxList.layoutManager = linearLayoutManager
//获取通知消息列表
noticeList= CallerMsgBoxManager.getCachedNotifyData() as ArrayList<MsgBoxBean>?
noticeList = noticeList?.let { ArrayList(it.reversed()) }
//获取车辆系统信息列表
ipcReportList = CallerMsgBoxManager.getCachedSysInfoData() as ArrayList<MsgBoxBean>?
ipcReportList = ipcReportList?.let { ArrayList(it.reversed()) }
//获取录包信息列表
badCaseList = CallerMsgBoxManager.getCachedRecordBagData() as ArrayList<MsgBoxBean>?
badCaseList = badCaseList?.let { ArrayList(it.reversed()) }
//通知
tvMsgNotice.setOnClickListener {
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgFm.background = null
tvMsgIpcReport.background = null
tvMsgBadCase.background = null
MsgBoxConfig.setUserRecord(0)
if(noticeList==null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(noticeList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//FM信息
tvMsgFm.setOnClickListener {
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.background = null
tvMsgFm.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgIpcReport.background = null
tvMsgBadCase.background = null
MsgBoxConfig.setUserRecord(1)
if(fmList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(fmList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//车辆系统信息
tvMsgIpcReport.setOnClickListener {
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.background = null
tvMsgFm.background = null
tvMsgIpcReport.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgBadCase.background = null
MsgBoxConfig.setUserRecord(2)
if(ipcReportList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(ipcReportList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//录包
tvMsgBadCase.setOnClickListener {
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgNotice.background = null
tvMsgFm.background = null
tvMsgIpcReport.background = null
tvMsgBadCase.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
MsgBoxConfig.setUserRecord(3)
if(badCaseList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(badCaseList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
}
fun notifyData(){
//获取当前Tab选择
when(MsgBoxConfig.getUserRecord()){
//通知消息
0 ->{
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgFm.background = null
tvMsgIpcReport.background = null
tvMsgBadCase.background = null
if(noticeList==null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(noticeList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//FM消息
1->{
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.background = null
tvMsgFm.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgIpcReport.background = null
tvMsgBadCase.background = null
if(fmList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(fmList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//车辆系统信息消息
2 ->{
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgNotice.background = null
tvMsgFm.background = null
tvMsgIpcReport.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
tvMsgBadCase.background = null
if(ipcReportList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(ipcReportList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
//录包消息
3 ->{
tvMsgNotice.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgFm.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgIpcReport.setTextColor(ContextCompat.getColor(context, R.color.color_FFFFFF))
tvMsgBadCase.setTextColor(ContextCompat.getColor(context, R.color.msg_box_title_color))
tvMsgNotice.background = null
tvMsgFm.background = null
tvMsgIpcReport.background = null
tvMsgBadCase.setBackgroundResource(R.drawable.bg_msg_box_title_selected)
if(badCaseList == null){
rvMsgBoxList.visibility = View.GONE
}else{
driverMsgBoxListAdapter?.setData(badCaseList!!)
rvMsgBoxList.visibility = View.VISIBLE
rvMsgBoxList.scrollToPosition(0)
}
}
}
}
override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) {
UiThreadHandler.post({
when (category) {
//通知
MsgCategory.NOTICE -> {
if(msgBoxList.sourceType == DataSourceType.SUMMARY){
//在一次订单中汇总消息只展示一次
if(isShowSummary){
noticeList?.add(0,msgBoxList)
if(MsgBoxConfig.getUserRecord() == 0){
noticeList?.let { driverMsgBoxListAdapter?.setData(it) }
}
isShowSummary = false
}
}else{
noticeList?.add(0,msgBoxList)
if(MsgBoxConfig.getUserRecord() == 0){
noticeList?.let { driverMsgBoxListAdapter?.setData(it) }
}
}
}
//FM信息
MsgCategory.FM_INFO -> {
fmList?.add(0,msgBoxList)
if(MsgBoxConfig.getUserRecord() == 1){
fmList?.let { driverMsgBoxListAdapter?.setData(it) }
}
}
//系统信息
MsgCategory.SYS_INFO -> {
ipcReportList?.add(0,msgBoxList)
if(MsgBoxConfig.getUserRecord() == 2){
ipcReportList?.let { driverMsgBoxListAdapter?.setData(it) }
}
}
//录包
MsgCategory.RECORD_BAG -> {
badCaseList?.add(0,msgBoxList)
if(MsgBoxConfig.getUserRecord() == 3){
badCaseList?.let { driverMsgBoxListAdapter?.setData(it) }
}
}
else -> {}
}
},UiThreadHandler.MODE.QUEUE)
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerMsgBoxListenerManager.addListener(TAG,this)
CallerMsgBoxEventListenerManager.addListener(TAG,this)
CallerOrderListenerManager.addListener(TAG,this)
EventBus.getDefault().register(this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerMsgBoxListenerManager.removeListener(TAG)
CallerMsgBoxEventListenerManager.removeListener(TAG)
CallerOrderListenerManager.removeListener(TAG)
EventBus.getDefault().unregister(this)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun notifyList(msgBoxList: MsgBoxBean){
badCaseList?.let {
driverMsgBoxListAdapter?.notifyItemRemoved(it.indexOf(msgBoxList))
it.remove(msgBoxList)
}
}
override fun onSummaryClickEvent() {
}
override fun onUpdateTipEvent(isShow: Boolean) {
}
override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) {
MsgBoxConfig.setUserRecord(0)
notifyData()
noticeList?.let {
rvMsgBoxList?.scrollToPosition(it.indexOf(msgBoxBean))
}
}
override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) {
MsgBoxConfig.setUserRecord(0)
notifyData()
noticeList?.let {
rvMsgBoxList?.scrollToPosition(it.indexOf(msgBoxBean))
}
}
override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) {
MsgBoxConfig.setUserRecord(1)
notifyData()
ipcReportList?.let {
linearLayoutManager?.scrollToPositionWithOffset(it.indexOf(msgBoxBean),0)
driverMsgBoxListAdapter?.setReportShowData(msgBoxBean)
}
}
override fun onUpdateOrderStatus(inOrder: Boolean) {
isShowSummary = inOrder
}
}