add mogoaction api
This commit is contained in:
@@ -29,6 +29,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
@@ -37,15 +38,21 @@ import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.MogoAction;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -93,6 +100,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private IMogoMapUIController mUiController;
|
||||
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
/**
|
||||
* 是否已计算出地图显示状态
|
||||
*/
|
||||
@@ -118,6 +127,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
private IMogoActionManager mFlipContentManager;
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
@@ -248,7 +258,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ADAS_UI, this );
|
||||
|
||||
//TODO 初始化地图地图绘制大而全的Marker
|
||||
MarkerServiceHandler.init( mContext );
|
||||
registerAIReceiver( context );
|
||||
|
||||
@@ -264,6 +273,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( Intent.ACTION_POWER_DISCONNECTED, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_NWD_ACC, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_UI, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
|
||||
initWorkThread();
|
||||
}
|
||||
@@ -679,6 +691,25 @@ public class MogoServices implements IMogoMapListener,
|
||||
} else if ( TextUtils.equals( val, MogoReceiver.VALUE_SHOW ) ) {
|
||||
mStatusManager.setVoiceUIShow( TAG, true );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_NEXT.equals( command ) ) {
|
||||
mFlipContentManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Next );
|
||||
} else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) {
|
||||
mFlipContentManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Prev );
|
||||
} else if ( ServiceConst.COMMAND_SWITCH_CARD.equals( command ) ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_SHARE_MUSIC, true );
|
||||
} else if ( TextUtils.equals( "探路", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_ROAD_CONDITION, true );
|
||||
} else if ( TextUtils.equals( "在线车辆", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_USER_DATA, true );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,4 +108,20 @@ public class ServiceConst {
|
||||
public static final int MSG_REQUEST_DATA = 0x201;
|
||||
|
||||
|
||||
/**
|
||||
* 切换上一张卡片
|
||||
*/
|
||||
public static final String COMMAND_PREVIOUS = "com.zhidao.desk.switchCard.previous";
|
||||
|
||||
/**
|
||||
* 切换下一张卡片
|
||||
*/
|
||||
public static final String COMMAND_NEXT = "com.zhidao.desk.switchCard.next";
|
||||
|
||||
/**
|
||||
* 查看多媒体卡片、探路卡片
|
||||
*/
|
||||
public static final String COMMAND_SWITCH_CARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.module.service.flipcontent;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.MogoAction;
|
||||
import com.mogo.service.module.IMogoActionListener;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-12
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_ACTION_APIS )
|
||||
public class MogoActionManager implements IMogoActionManager {
|
||||
|
||||
@Override
|
||||
public void registerActionListener( String biz, IMogoActionListener listener ) {
|
||||
MogoFlipContentHandler.getInstance().registerActionListener( biz, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterActionListener( String biz, IMogoActionListener listener ) {
|
||||
MogoFlipContentHandler.getInstance().unregisterActionListener( biz, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String biz, MogoAction action ) {
|
||||
MogoFlipContentHandler.getInstance().invoke( biz, action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
MogoFlipContentHandler.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.mogo.module.service.flipcontent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.service.module.MogoAction;
|
||||
import com.mogo.service.module.IMogoActionListener;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-12
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoFlipContentHandler implements IMogoActionManager {
|
||||
|
||||
private MogoFlipContentHandler() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final MogoFlipContentHandler INSTANCE = new MogoFlipContentHandler();
|
||||
}
|
||||
|
||||
public static MogoFlipContentHandler getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Map< String, List< IMogoActionListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerActionListener( String biz, IMogoActionListener listener ) {
|
||||
if ( TextUtils.isEmpty( biz ) || listener == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( biz ) ) {
|
||||
mListeners.put( biz, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( biz ).add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterActionListener( String biz, IMogoActionListener listener ) {
|
||||
if ( TextUtils.isEmpty( biz ) || listener == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mListeners.containsKey( biz ) ) {
|
||||
mListeners.get( biz ).remove( listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String biz, MogoAction action ) {
|
||||
if ( !mListeners.containsKey( biz ) ) {
|
||||
return;
|
||||
}
|
||||
List< IMogoActionListener > listeners = mListeners.get( biz );
|
||||
if ( listeners != null ) {
|
||||
Iterator< IMogoActionListener > iterator = listeners.iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoActionListener listener = iterator.next();
|
||||
if ( listener != null ) {
|
||||
listener.onActionDone( action );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -752,4 +752,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
ThreadPoolService.execute( runnable );
|
||||
}
|
||||
|
||||
public String getCurrentModuleName() {
|
||||
return mCurrentModuleName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user