add mogoaction api

This commit is contained in:
wangcongtao
2020-03-12 22:35:51 +08:00
parent 89a9f33e4b
commit 325460b978
18 changed files with 285 additions and 305 deletions

View File

@@ -21,6 +21,7 @@ import com.mogo.service.impl.intent.IntentManager;
import com.mogo.service.impl.singleton.SingletonsHolder;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoActionManager;
import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.module.IMogoSearchManager;
import com.mogo.service.module.IMogoSettingManager;
@@ -129,6 +130,11 @@ public class MogoServiceApis implements IMogoServiceApis {
return getApiInstance( IMogoADASController.class, MogoServicePaths.PATH_ADAS_CONTROLLER );
}
@Override
public IMogoActionManager getFlipContentManager() {
return getApiInstance( IMogoActionManager.class, MogoServicePaths.PATH_ACTION_APIS );
}
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
T inst = SingletonsHolder.get( clazz );
if ( inst == null ) {

View File

@@ -12,6 +12,7 @@ import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,25 +27,6 @@ public class IntentManager implements IMogoIntentManager {
private static volatile IntentManager sInstance;
public static final int MSG_COMMAND_RECEIVED = 2000;
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( @NonNull Message msg ) {
super.handleMessage( msg );
if ( msg.what == MSG_COMMAND_RECEIVED ) {
MsgObject object = ( ( MsgObject ) msg.obj );
List< IMogoIntentListener > listeners = mListeners.get( object.getCommand() );
if ( listeners != null && !listeners.isEmpty() ) {
for ( IMogoIntentListener listener : listeners ) {
listener.onIntentReceived( object.getCommand(), object.getIntent() );
}
}
}
}
};
private IntentManager() {
}
@@ -63,7 +45,6 @@ public class IntentManager implements IMogoIntentManager {
sInstance = null;
}
private Map< String, List< IMogoIntentListener > > mListeners = new ConcurrentHashMap<>();
@Override
@@ -91,9 +72,15 @@ public class IntentManager implements IMogoIntentManager {
@Override
public void invoke( String command, Intent intent ) {
Message msg = Message.obtain();
msg.what = MSG_COMMAND_RECEIVED;
msg.obj = new MsgObject( command, intent );
mHandler.sendMessage( msg );
List< IMogoIntentListener > listeners = mListeners.get( command );
if ( listeners != null && !listeners.isEmpty() ) {
Iterator< IMogoIntentListener > iterator = listeners.iterator();
while ( iterator.hasNext() ) {
IMogoIntentListener listener = iterator.next();
if ( listener != null ) {
listener.onIntentReceived( command, intent );
}
}
}
}
}

View File

@@ -1,28 +0,0 @@
package com.mogo.service.impl.intent;
import android.content.Intent;
/**
* @author congtaowang
* @since 2020-01-13
* <p>
* 描述
*/
public class MsgObject {
private final String mCommand;
private final Intent mIntent;
public MsgObject( String command, Intent intent ) {
this.mCommand = command;
this.mIntent = intent;
}
public String getCommand() {
return mCommand;
}
public Intent getIntent() {
return mIntent;
}
}