This commit is contained in:
wangcongtao
2020-02-19 18:55:16 +08:00
parent 199c07c1b3
commit e7a6252835
2203 changed files with 24 additions and 107805 deletions

View File

@@ -2,6 +2,7 @@ package com.mogo.commons.voice;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.zhidao.auto.platform.voice.VoiceClient;
@@ -20,6 +21,7 @@ import java.util.Map;
public class AIAssist implements VoiceClient.VoiceCmdCallBack {
private static volatile AIAssist sInstance;
private String mLastQAndAspeakText;
public static AIAssist getInstance( Context context ) {
if ( sInstance == null ) {
@@ -75,23 +77,28 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
@Override
public void onCmdAction( String speakText ) {
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( speakText );
if ( cmdCallBack != null ) {
cmdCallBack.onCmdAction( speakText );
if ( !TextUtils.isEmpty( mLastQAndAspeakText ) ) {
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( mLastQAndAspeakText );
if ( cmdCallBack != null ) {
cmdCallBack.onCmdAction( speakText );
}
}
}
@Override
public void onCmdCancel( String speakText ) {
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( speakText );
if ( cmdCallBack != null ) {
cmdCallBack.onCmdCancel( speakText );
if ( !TextUtils.isEmpty( mLastQAndAspeakText ) ) {
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( mLastQAndAspeakText );
if ( cmdCallBack != null ) {
cmdCallBack.onCmdCancel( speakText );
}
}
}
@Override
public void onSpeakEnd( String speakText ) {
if ( mQAndAMap.containsKey( speakText ) ) {
mLastQAndAspeakText = speakText;
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.get( speakText );
if ( cmdCallBack != null ) {
cmdCallBack.onSpeakEnd( speakText );
@@ -107,7 +114,10 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
@Override
public void onSpeakSelectTimeOut( String speakText ) {
if ( mQAndAMap.containsKey( speakText ) ) {
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.get( speakText );
if ( TextUtils.equals( speakText, mLastQAndAspeakText ) ) {
mLastQAndAspeakText = null;
}
IMogoVoiceCmdCallBack cmdCallBack = mQAndAMap.remove( speakText );
if ( cmdCallBack != null ) {
cmdCallBack.onSpeakSelectTimeOut( speakText );
return;