implementation base service: location, socket, passport
This commit is contained in:
@@ -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