[6.2.0]Taxi乘客端消息盒子增加小智语音显示
This commit is contained in:
@@ -37,6 +37,9 @@ class MsgBoxConfig {
|
||||
//录包信息缓存列表
|
||||
@JvmField
|
||||
var recordBagList: ArrayList<MsgBoxBean> = ArrayList()
|
||||
//播放小智语音消息时的未播放消息缓存列表
|
||||
@JvmField
|
||||
var unPlayList: ArrayList<MsgBoxBean> = ArrayList()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,8 @@ 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.data.msgbox.VoiceMsg
|
||||
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
|
||||
@@ -31,13 +33,17 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener, IOrderListener {
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener, IOrderListener,
|
||||
IMsgBoxEventListener {
|
||||
|
||||
private val TAG = "PassengerMsgBoxBubbleView"
|
||||
private val dataList :ArrayList<MsgBoxCountDownBean> = ArrayList()
|
||||
private var passengerMsgBoxBubbleAdapter: PassengerMsgBoxBubbleAdapter ?= null
|
||||
private var isShowData = true
|
||||
private var isShowSummary = false //是否展示汇总消息
|
||||
private var isCacheMsg = false //是否缓存消息
|
||||
private var voiceIsShowing = false //小智语音消息是否正在展示
|
||||
private var voiceMsgBean: MsgBoxCountDownBean ?= null //小智语音消息封装
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_passenger_msg_box_bubble, this, true)
|
||||
@@ -65,20 +71,95 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
if(category == MsgCategory.NOTICE){
|
||||
if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X
|
||||
|| msgBoxList.type == MsgBoxType.OBU){
|
||||
if(msgBoxList.sourceType == DataSourceType.SUMMARY){
|
||||
//在一次订单中汇总消息只展示一次
|
||||
if(isShowSummary){
|
||||
operationalData(msgBoxList)
|
||||
isShowSummary = false
|
||||
}
|
||||
if(isCacheMsg){
|
||||
//将消息缓存到未播放列表等待小智语音播放完成后取出播放
|
||||
MsgBoxConfig.unPlayList.add(msgBoxList)
|
||||
}else{
|
||||
operationalData(msgBoxList)
|
||||
//实时播放消息
|
||||
notifyMsg(msgBoxList)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(category == MsgCategory.VOICE_INFO){
|
||||
if(msgBoxList.type == MsgBoxType.VOICE){
|
||||
executeVoiceInfo(msgBoxList)
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
/**
|
||||
* 小智语音消息执行
|
||||
*/
|
||||
private fun executeVoiceInfo(msgBoxList: MsgBoxBean){
|
||||
val voiceMsg = msgBoxList.bean as VoiceMsg
|
||||
if(voiceMsg.isWakeUp && !voiceMsg.isWakeUpEnd){
|
||||
//有其他消息时,将其他消息缓存进未播放列表
|
||||
voiceIsShowing = true
|
||||
isCacheMsg = true
|
||||
//开始展示消息
|
||||
if(voiceMsgBean == null){
|
||||
voiceMsgBean = MsgBoxCountDownBean(msgBoxList)
|
||||
dataList.add(voiceMsgBean!!)
|
||||
}else{
|
||||
dataList.remove(voiceMsgBean)
|
||||
voiceMsgBean!!.msgBoxBean = msgBoxList
|
||||
dataList.add(voiceMsgBean!!)
|
||||
}
|
||||
passengerMsgBoxBubbleAdapter?.setData(dataList)
|
||||
}
|
||||
if(!voiceMsg.isWakeUp && voiceMsg.isWakeUpEnd){
|
||||
//关闭消息展示
|
||||
dataList.remove(voiceMsgBean)
|
||||
passengerMsgBoxBubbleAdapter?.setData(dataList)
|
||||
//如果未播放列表中有未播放的消息则陆续展示消息,新来的消息继续放到未播放列表中,
|
||||
//如果未播放消息列表为空,则立刻改变状态,即使播放新消息
|
||||
voiceIsShowing = false
|
||||
handleCachedMsg()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放缓存消息
|
||||
*/
|
||||
private fun handleCachedMsg(){
|
||||
if(MsgBoxConfig.unPlayList.isEmpty()){
|
||||
isCacheMsg = false
|
||||
}else{
|
||||
//开始播放缓存未播放消息
|
||||
val iterator = MsgBoxConfig.unPlayList.iterator()
|
||||
while(iterator.hasNext()){
|
||||
val msg = iterator.next()
|
||||
if(passengerMsgBoxBubbleAdapter!!.getDataSize()<3){
|
||||
notifyMsg(msg)
|
||||
iterator.remove()
|
||||
}
|
||||
}
|
||||
if(MsgBoxConfig.unPlayList.isEmpty()){
|
||||
isCacheMsg = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知新消息展示
|
||||
*/
|
||||
private fun notifyMsg(msgBoxList: MsgBoxBean){
|
||||
if(msgBoxList.sourceType == DataSourceType.SUMMARY){
|
||||
//在一次订单中汇总消息只展示一次
|
||||
if(isShowSummary){
|
||||
operationalData(msgBoxList)
|
||||
isShowSummary = false
|
||||
}
|
||||
}else{
|
||||
operationalData(msgBoxList)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理播放消息
|
||||
*/
|
||||
private fun operationalData(msgBoxList: MsgBoxBean){
|
||||
MsgBoxConfig.noticeList.add(msgBoxList)
|
||||
if(isShowData){
|
||||
@@ -93,16 +174,28 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor(
|
||||
super.onAttachedToWindow()
|
||||
CallerMsgBoxListenerManager.addListener(TAG,this)
|
||||
CallerOrderListenerManager.addListener(TAG,this)
|
||||
CallerMsgBoxEventListenerManager.addListener(TAG,this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerMsgBoxListenerManager.removeListener(TAG)
|
||||
CallerOrderListenerManager.removeListener(TAG)
|
||||
CallerMsgBoxEventListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onUpdateOrderStatus(inOrder: Boolean) {
|
||||
isShowSummary = inOrder
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放缓存消息
|
||||
*/
|
||||
override fun onHandleCachedMsg() {
|
||||
if(voiceIsShowing){
|
||||
return
|
||||
}
|
||||
handleCachedMsg()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.msgbox.adapter
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.res.Resources
|
||||
import android.os.CountDownTimer
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -17,6 +19,7 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTransform
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat
|
||||
@@ -34,6 +37,7 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
private val notice: Int = 1
|
||||
private val v2x: Int = 2
|
||||
private val summary: Int = 3
|
||||
private val voice: Int = 4
|
||||
|
||||
fun setData(data: ArrayList<MsgBoxCountDownBean>){
|
||||
this.data = data
|
||||
@@ -43,6 +47,17 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表数据个数
|
||||
*/
|
||||
fun getDataSize(): Int{
|
||||
return if(data.isNullOrEmpty()){
|
||||
0
|
||||
}else{
|
||||
data!!.size
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return when (viewType) {
|
||||
notice -> {
|
||||
@@ -53,6 +68,11 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_passenger_msg_box_summary,parent,false)
|
||||
BubbleSummaryHolder(view)
|
||||
}
|
||||
//小智语音
|
||||
voice -> {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_passenger_msg_box_voice,parent,false)
|
||||
BubbleVoiceHolder(view)
|
||||
}
|
||||
else -> {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_passenger_msg_box_v2x,parent,false)
|
||||
BubbleV2XHolder(view)
|
||||
@@ -108,23 +128,41 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
}
|
||||
}
|
||||
}
|
||||
//小智语音消息
|
||||
is BubbleVoiceHolder -> {
|
||||
data?.let {
|
||||
val voiceMsg = it[position].msgBoxBean.bean as VoiceMsg
|
||||
holder.tvPassengerVoiceContent.text = voiceMsg.msg
|
||||
if(voiceMsg.isResp){
|
||||
//小智说的
|
||||
holder.tvPassengerVoiceContent.setTextColor(activity.resources.getColor(R.color.black))
|
||||
}else{
|
||||
//用户说的
|
||||
holder.tvPassengerVoiceContent.setTextColor(activity.resources.getColor(R.color.blue))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val msgBoxBean: MsgBoxCountDownBean = data!![position]
|
||||
msgBoxBean.countDownTimer =object: CountDownTimer(CallerMsgBoxManager.getDismissTime(),1000){
|
||||
override fun onTick(p0: Long) {
|
||||
if(msgBoxBean.msgBoxBean.type != MsgBoxType.VOICE){
|
||||
msgBoxBean.countDownTimer =object: CountDownTimer(CallerMsgBoxManager.getDismissTime(),CallerMsgBoxManager.getDismissTime()){
|
||||
override fun onTick(p0: Long) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
data?.remove(msgBoxBean)
|
||||
notifyDataSetChanged()
|
||||
override fun onFinish() {
|
||||
data?.remove(msgBoxBean)
|
||||
notifyDataSetChanged()
|
||||
// notifyItemRemoved(index)
|
||||
// notifyItemRangeChanged(index,recordTypeEntity.size-index)
|
||||
}
|
||||
//通知消息盒子可以展示新的缓存消息
|
||||
CallerMsgBoxEventListenerManager.invokeHandleCachedMsg()
|
||||
}
|
||||
|
||||
}
|
||||
msgBoxBean.countDownTimer?.start()
|
||||
}
|
||||
msgBoxBean.countDownTimer?.start()
|
||||
}
|
||||
|
||||
override fun getItemCount() = data?.size ?: 0
|
||||
@@ -134,7 +172,9 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
notice
|
||||
}else if(data!![position].msgBoxBean.type == MsgBoxType.V2X && data!![position].msgBoxBean.sourceType == DataSourceType.SUMMARY){
|
||||
summary
|
||||
} else{
|
||||
}else if(data!![position].msgBoxBean.type == MsgBoxType.VOICE){
|
||||
voice
|
||||
}else{
|
||||
v2x
|
||||
}
|
||||
}
|
||||
@@ -160,4 +200,9 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView
|
||||
var tvPassengerSummaryTime: TextView = itemView.findViewById(R.id.tvPassengerSummaryTime)
|
||||
}
|
||||
|
||||
//小智语音消息
|
||||
class BubbleVoiceHolder(itemView: View): RecyclerView.ViewHolder(itemView){
|
||||
var tvPassengerVoiceContent: TextView = itemView.findViewById(R.id.tvPassengerVoiceContent)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.eagle.core.widget.RoundCanClickConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="#FFCEDCF7"
|
||||
app:roundLayoutRadius="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:paddingStart="@dimen/dp_20"
|
||||
android:paddingEnd="@dimen/dp_20"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPassengerVoiceContent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_34"
|
||||
android:layout_margin="@dimen/dp_40"
|
||||
android:textColor="@color/black"
|
||||
android:gravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</com.mogo.eagle.core.widget.RoundCanClickConstraintLayout>
|
||||
@@ -2,6 +2,6 @@ package com.mogo.eagle.core.data.msgbox
|
||||
|
||||
import android.os.CountDownTimer
|
||||
|
||||
class MsgBoxCountDownBean(val msgBoxBean: MsgBoxBean){
|
||||
class MsgBoxCountDownBean(var msgBoxBean: MsgBoxBean){
|
||||
var countDownTimer: CountDownTimer ?= null
|
||||
}
|
||||
@@ -22,4 +22,7 @@ interface IMsgBoxEventListener {
|
||||
|
||||
//气泡态上报消息事件点击监听
|
||||
fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean){}
|
||||
|
||||
//通知播放缓存的未播放消息
|
||||
fun onHandleCachedMsg(){}
|
||||
}
|
||||
@@ -61,5 +61,15 @@ object CallerMsgBoxEventListenerManager: CallerBase<IMsgBoxEventListener>() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知播放缓存的未播放消息
|
||||
*/
|
||||
fun invokeHandleCachedMsg(){
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onHandleCachedMsg()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user