add mogoaction api
This commit is contained in:
@@ -12,6 +12,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
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;
|
||||
@@ -138,4 +139,11 @@ public interface IMogoServiceApis extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoADASController getAdasControllerApi();
|
||||
|
||||
/**
|
||||
* 内容翻页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoActionManager getFlipContentManager();
|
||||
}
|
||||
|
||||
@@ -142,4 +142,10 @@ public class MogoServicePaths {
|
||||
* 接口集合
|
||||
*/
|
||||
public static final String PATH_SERVICE_APIS = "/mogoservice/apis";
|
||||
|
||||
/**
|
||||
* 动作指令
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_ACTION_APIS = "/mogoaction/api";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-12
|
||||
* <p>
|
||||
* 翻页回调
|
||||
*/
|
||||
public interface IMogoActionListener {
|
||||
|
||||
/**
|
||||
* 执行动作
|
||||
*
|
||||
* @param action
|
||||
*/
|
||||
void onActionDone( MogoAction action );
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-12
|
||||
* <p>
|
||||
* 基础动作指令控制
|
||||
*/
|
||||
public interface IMogoActionManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 注册动作监听回调
|
||||
*
|
||||
* @param biz 具体业务
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerActionListener( String biz, IMogoActionListener listener );
|
||||
|
||||
/**
|
||||
* 取消动作翻页回调
|
||||
*
|
||||
* @param biz 具体业务
|
||||
* @param listener 回调
|
||||
*/
|
||||
void unregisterActionListener( String biz, IMogoActionListener listener );
|
||||
|
||||
/**
|
||||
* 回调
|
||||
*
|
||||
* @param biz 业务
|
||||
* @param action 动作
|
||||
*/
|
||||
void invoke( String biz, MogoAction action );
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-12
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public enum MogoAction {
|
||||
|
||||
/**
|
||||
* 上一个
|
||||
*/
|
||||
Prev,
|
||||
|
||||
/**
|
||||
* 下一个
|
||||
*/
|
||||
Next
|
||||
}
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user