opt
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user