implementation base service: location, socket, passport
This commit is contained in:
@@ -14,6 +14,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -23,6 +24,7 @@ import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.obu.IMogoObuManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
@@ -188,31 +190,50 @@ public interface IMogoServiceApis extends IProvider {
|
||||
|
||||
/**
|
||||
* 获取顶部1/2屏界面管理类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoTopViewManager getTopViewManager();
|
||||
|
||||
/**
|
||||
* 其他模块调用公共的marker打点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerService getMarkerService();
|
||||
|
||||
/**
|
||||
* 其他模块调用分享框的显示和隐藏
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoShareManager getShareManager();
|
||||
|
||||
/**
|
||||
* 获取obuManager
|
||||
*
|
||||
* @return obuManager
|
||||
*/
|
||||
IMogoObuManager getObuManager();
|
||||
|
||||
/**
|
||||
* 获取事件面板manager
|
||||
*
|
||||
* @return eventPanelProvider
|
||||
*/
|
||||
IEventPanelProvider getEventPanelManager();
|
||||
|
||||
/**
|
||||
* 获取位置上报服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoLocationInfoService getLocationInfoApi();
|
||||
|
||||
/**
|
||||
* 获取位置上报服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoPassportManager getPassportManagerApi();
|
||||
}
|
||||
|
||||
@@ -208,4 +208,16 @@ public class MogoServicePaths {
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_SPLASH = "/splash/api";
|
||||
|
||||
/**
|
||||
* 位置上报
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_LOCATION_INFO = "/locationinfo/api";
|
||||
|
||||
/**
|
||||
* passport
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_PASSPORT = "/passport/api";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mogo.service.locationinfo;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 位置服务:上报位置信息和车机状态
|
||||
*/
|
||||
interface IMogoLocationInfoService extends IProvider {
|
||||
|
||||
/**
|
||||
* 提供位置信息
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
void provideLocation( MogoLocation location );
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.passport;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoPassportManager extends IProvider {
|
||||
|
||||
void requestTicket( IMogoTicketCallback callback );
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.passport;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
* <p>
|
||||
* ticket 回调
|
||||
*/
|
||||
interface IMogoTicketCallback {
|
||||
|
||||
void onSuccess( String ticket );
|
||||
|
||||
void onError( int code, String msg );
|
||||
}
|
||||
@@ -47,7 +47,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.mogoconnection
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
} else {
|
||||
api project(":libraries:mogo-map")
|
||||
@@ -55,7 +54,6 @@ dependencies {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":services:mogo-service-api")
|
||||
implementation project(":foudations:mogo-connection")
|
||||
implementation project(":modules:mogo-module-common")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.connection.socket.SocketManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
@@ -23,6 +22,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.launcher.IMogoLauncher;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -32,6 +32,7 @@ import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.obu.IMogoObuManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
@@ -61,7 +62,7 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
|
||||
@Override
|
||||
public IMogoSocketManager getSocketManagerApi( Context context ) {
|
||||
return SocketManager.getInstance( context );
|
||||
return getApiInstance( IMogoSocketManager.class, MogoServicePaths.PATH_SOCKET_MANAGER );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,20 +177,30 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
|
||||
@Override
|
||||
public IMogoShareManager getShareManager() {
|
||||
return getApiInstance(IMogoShareManager.class,MogoServicePaths.PATH_SHARE);
|
||||
return getApiInstance( IMogoShareManager.class, MogoServicePaths.PATH_SHARE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoObuManager getObuManager() {
|
||||
return getApiInstance(IMogoObuManager.class, MogoServicePaths.PATH_OBU);
|
||||
return getApiInstance( IMogoObuManager.class, MogoServicePaths.PATH_OBU );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventPanelProvider getEventPanelManager() {
|
||||
return getApiInstance(IEventPanelProvider.class, MogoServicePaths.PATH_EVENT_PANEL);
|
||||
return getApiInstance( IEventPanelProvider.class, MogoServicePaths.PATH_EVENT_PANEL );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance(Class< T > clazz, String path ) {
|
||||
@Override
|
||||
public IMogoLocationInfoService getLocationInfoApi() {
|
||||
return getApiInstance( IMogoLocationInfoService.class, MogoServicePaths.PATH_LOCATION_INFO );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPassportManager getPassportManagerApi() {
|
||||
return getApiInstance( IMogoPassportManager.class, MogoServicePaths.PATH_PASSPORT );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
|
||||
T inst = SingletonsHolder.get( clazz );
|
||||
if ( inst == null ) {
|
||||
synchronized ( sLock ) {
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.mogo.service.impl.connection;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.connection.socket.SocketManager;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.connection.MsgBody;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,6 +21,7 @@ import com.mogo.service.connection.MsgBody;
|
||||
@Route( path = MogoServicePaths.PATH_SOCKET_MANAGER )
|
||||
public class MogoSocketManager implements IMogoSocketManager {
|
||||
|
||||
private static final String TAG = "MogoSocketManager";
|
||||
private IMogoSocketManager mDelegate;
|
||||
|
||||
@Override
|
||||
@@ -58,6 +61,14 @@ public class MogoSocketManager implements IMogoSocketManager {
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
mDelegate = SocketManager.getInstance( context );
|
||||
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.socket.SocketManager" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance", Context.class );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoSocketManager ) getInstanceMethod.invoke( null, context );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.service.impl.locationinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_LOCATION_INFO )
|
||||
class MogoLocationInfoService implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoService";
|
||||
|
||||
private IMogoLocationInfoService mDelegate;
|
||||
|
||||
@Override
|
||||
public void provideLocation( MogoLocation location ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.provideLocation( location );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.locationinfo.MogoLocationInfoServices" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance" );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoLocationInfoService ) getInstanceMethod.invoke( null );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.init( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mogo.service.impl.passport;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_PASSPORT )
|
||||
class MogoPassportManager implements IMogoPassportManager {
|
||||
|
||||
private static final String TAG = "MogoPassportManager";
|
||||
|
||||
private IMogoPassportManager mDelegate;
|
||||
|
||||
@Override
|
||||
public void requestTicket( IMogoTicketCallback callback ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.requestTicket( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.passport.PassportManager" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance" );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoPassportManager ) getInstanceMethod.invoke( null );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.init( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user