[feature]
[xiaozhi]
This commit is contained in:
@@ -3,6 +3,7 @@ package com.mogo.och.common.module.wigets
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.common.module.R
|
||||
@@ -22,21 +23,64 @@ class ZhiView @JvmOverloads constructor(
|
||||
const val TAG = "ZhiView"
|
||||
}
|
||||
|
||||
private var createProgressDialogAnim: FrameAnimatorContainer?=null
|
||||
private var normalAnim: FrameAnimatorContainer?=null
|
||||
private var listeningAnim: FrameAnimatorContainer?=null
|
||||
private var understandingAnim: FrameAnimatorContainer?=null
|
||||
private var speakingAnim: FrameAnimatorContainer?=null
|
||||
|
||||
@Volatile
|
||||
private var currentAni:FrameAnimatorContainer?=null
|
||||
|
||||
init {
|
||||
createProgressDialogAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this)
|
||||
createProgressDialogAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{
|
||||
normalAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this)
|
||||
normalAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{
|
||||
override fun AnimationStopped() {
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "动画暂停")
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "常态动画暂停")
|
||||
currentAni?.reStart()
|
||||
}
|
||||
})
|
||||
|
||||
listeningAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this)
|
||||
listeningAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{
|
||||
override fun AnimationStopped() {
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "侦听动画暂停")
|
||||
currentAni?.reStart()
|
||||
}
|
||||
})
|
||||
|
||||
understandingAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this)
|
||||
understandingAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{
|
||||
override fun AnimationStopped() {
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "理解中动画暂停")
|
||||
currentAni?.reStart()
|
||||
}
|
||||
})
|
||||
|
||||
speakingAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this)
|
||||
speakingAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{
|
||||
override fun AnimationStopped() {
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "说话动画暂停")
|
||||
currentAni?.reStart()
|
||||
}
|
||||
})
|
||||
|
||||
currentAni = normalAnim
|
||||
|
||||
onClick {
|
||||
AvatarManager.wakeupXiaoZhi()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasWindowFocus)
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "焦点与否:${hasWindowFocus}")
|
||||
AvatarManager.enableXiaoZhi(!hasWindowFocus)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
AvatarManager.addDistanceListener(TAG,this)
|
||||
createProgressDialogAnim?.start()
|
||||
normalAnim?.reStart()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -50,25 +94,67 @@ class ZhiView @JvmOverloads constructor(
|
||||
|
||||
override fun onStatusChange(status: ZhiRecordWinUi.RecordStatus?) {
|
||||
CallerLogger.d(TAG,"-----onStatusChange $status")
|
||||
|
||||
|
||||
when (status) {
|
||||
ZhiRecordWinUi.RecordStatus.STATUS_SILENCE -> {}
|
||||
ZhiRecordWinUi.RecordStatus.STATUS_LISTENING -> {
|
||||
// 正在听取
|
||||
currentAni?.stop()
|
||||
currentAni = listeningAnim
|
||||
}
|
||||
ZhiRecordWinUi.RecordStatus.STATUS_UNDERSTANDING -> {
|
||||
// 正在理解
|
||||
currentAni?.stop()
|
||||
currentAni = understandingAnim
|
||||
}
|
||||
ZhiRecordWinUi.RecordStatus.STATUS_UNDERSTAND_END -> {
|
||||
|
||||
}
|
||||
ZhiRecordWinUi.RecordStatus.STATUS_SPEAKING -> {
|
||||
// 正在说话
|
||||
currentAni?.stop()
|
||||
currentAni = speakingAnim
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun close(trigger: Boolean) {
|
||||
CallerLogger.d(TAG,"-----close $trigger")
|
||||
currentAni?.stop()
|
||||
currentAni = normalAnim
|
||||
}
|
||||
|
||||
|
||||
override fun onVolumeChange(volume: Int) {
|
||||
CallerLogger.d(TAG,"-----onVolumeChange $volume")
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户输入的
|
||||
*/
|
||||
override fun showInputText(asrTextBean: AsrTextBean?) {
|
||||
CallerLogger.d(TAG,"-----showInputText $asrTextBean")
|
||||
}
|
||||
|
||||
/**
|
||||
* 特定View
|
||||
*/
|
||||
override fun showOutPutWidget(callbackWidget: CallbackWidget?) {
|
||||
// todo 咱不支持定制显示 包括天气
|
||||
CallerLogger.d(TAG,"-----showOutPutWidget $callbackWidget")
|
||||
}
|
||||
|
||||
/**
|
||||
* 小智说的
|
||||
*/
|
||||
override fun showOutputText(outPutText: String?) {
|
||||
CallerLogger.d(TAG,"-----showOutputText $outPutText")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user