[2.13.2]V2N事件播报语音提示策略调整

This commit is contained in:
renwj
2023-01-14 16:51:47 +08:00
parent 648adae504
commit 1cb3711386

View File

@@ -111,6 +111,7 @@ import me.jessyan.autosize.utils.AutoSizeUtils
import mogo_msg.MogoReportMsg
import record_cache.RecordPanelOuterClass
import java.util.*
import java.util.concurrent.atomic.AtomicReference
/**
@@ -171,7 +172,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
private var adUpgradeDialog: AdUpgradeDialog? = null
private var lastSpeakJob: Job? = null
private val lastSpeakJob by lazy { AtomicReference<Job>() }
private var lastShowV2XJob: Job? = null
@@ -901,7 +902,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
override fun onShow(reminder: IReminder) {
listener?.onShow()
lastShowV2XJob?.safeCancel()
lastSpeakJob?.safeCancel()
lastSpeakJob.get()?.safeCancel()
showingV2XTip = reminder
lifecycleScope.launch {
delay(expireTime)
@@ -914,7 +915,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
lifecycleScope.launch {
speak(it, ttsContent)
}.also { itx ->
lastSpeakJob = itx
lastSpeakJob.set(itx)
}
}
}
@@ -970,10 +971,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
"$M_HMI$TAG",
"--- show v2x dialog 1 ---: info -> v2x-type: $v2xType : expireTime: $expireTime"
)
lastShowV2XJob?.safeCancel()
lastSpeakJob?.safeCancel()
lifecycleScope.launch {
delay(expireTime)
}.also { itx ->
@@ -984,10 +982,18 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
}
if (ttsContent != null && !TextUtils.isEmpty(ttsContent) && playTTS) {
lifecycleScope.launch {
val last = lastSpeakJob.get()
Log.d("CODE", "---- 0 ------: last: $last")
if (last != null && !last.isCompleted) {
Log.d("CODE", "---- 1 ------")
return
}
lifecycleScope.launch(Dispatchers.Default) {
Log.d("CODE", "---- 2 ------")
speak(it, ttsContent)
Log.d("CODE", "---- 3 ------")
}.also { itx ->
lastSpeakJob = itx
lastSpeakJob.set(itx)
}
}
}