opt
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.mogo.service.impl.voice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.zhidao.auto.platform.voice.VoiceClient;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_VOICE_MANAGER )
|
||||
public class MogoVoiceManager implements IMogoVoiceManager {
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String action, IMogoVoiceListener listener ) {
|
||||
VoiceManager.getInstance().registerIntentListener( action, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterIntentListener( String action ) {
|
||||
VoiceManager.getInstance().unregisterIntentListener( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String action, Intent intent ) {
|
||||
VoiceManager.getInstance().invoke( action, intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
VoiceManager.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.service.impl.voice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class VoiceManager implements IMogoVoiceManager {
|
||||
|
||||
private static volatile VoiceManager sInstance;
|
||||
|
||||
private VoiceManager() {
|
||||
}
|
||||
|
||||
public static VoiceManager getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( VoiceManager.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new VoiceManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
private Map< String, List< IMogoVoiceListener > > mListeners = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String action, IMogoVoiceListener listener ) {
|
||||
if ( listener == null || action == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( action ) ) {
|
||||
mListeners.put( action, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( action ).add( listener );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterIntentListener( String action ) {
|
||||
mListeners.remove( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String action, Intent intent ) {
|
||||
List< IMogoVoiceListener > listeners = mListeners.get( action );
|
||||
if ( listeners != null && !listeners.isEmpty() ) {
|
||||
for ( IMogoVoiceListener listener : listeners ) {
|
||||
listener.onIntentReceived( action, intent );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class WindowViewHandler {
|
||||
try {
|
||||
sWindowManager = ( WindowManager ) view.getContext().getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, "error. ", e );
|
||||
Logger.e( TAG, e, "error. " );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user