dev
This commit is contained in:
@@ -20,13 +20,13 @@ public class MogoApplication extends AbsMogoApplication {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
MogoModulePaths.addModule( DemoConstants.TAG );
|
||||||
|
MogoModulePaths.addModule( Demo2Constants.TAG );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext( Context base ) {
|
protected void attachBaseContext( Context base ) {
|
||||||
super.attachBaseContext( base );
|
super.attachBaseContext( base );
|
||||||
MultiDex.install( base );
|
MultiDex.install( base );
|
||||||
MogoModulePaths.addModule( DemoConstants.TAG );
|
|
||||||
MogoModulePaths.addModule( Demo2Constants.TAG );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,5 +77,11 @@ ext {
|
|||||||
mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
|
mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
|
||||||
mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
|
mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
|
||||||
moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",
|
moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",
|
||||||
|
mogoconnection : "com.mogo.connection:mogo-connection:${MOGO_CONNECTION_VERSION}",
|
||||||
|
|
||||||
|
// 长链
|
||||||
|
socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.0',
|
||||||
|
socketsdkconnsvrprotoco : 'com.zhidao.ptech:connsvr-protoco:0.1.23',
|
||||||
|
socketsdkprotobufjava : 'com.google.protobuf:protobuf-java:3.5.1',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.mogo.commons.mvp.IView;
|
import com.mogo.commons.mvp.IView;
|
||||||
import com.mogo.commons.mvp.MvpFragment;
|
import com.mogo.commons.mvp.MvpFragment;
|
||||||
import com.mogo.commons.mvp.Presenter;
|
import com.mogo.commons.mvp.Presenter;
|
||||||
@@ -27,6 +28,10 @@ import com.mogo.map.search.geo.MogoPoiItem;
|
|||||||
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||||
import com.mogo.map.search.poisearch.MogoPoiResult;
|
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
|
import com.mogo.service.MogoServicePaths;
|
||||||
|
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||||
|
import com.mogo.service.connection.IMogoSocketManager;
|
||||||
|
import com.mogo.service.connection.MsgBody;
|
||||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
import com.mogo.utils.TipToast;
|
import com.mogo.utils.TipToast;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -66,6 +71,8 @@ public class Demo2CardViewFragment extends MvpFragment< IView, Presenter< IView
|
|||||||
private Demo2InfoWindowAdapter mDemoInfoWindowAdapter;
|
private Demo2InfoWindowAdapter mDemoInfoWindowAdapter;
|
||||||
private MogoLocation mLocation;
|
private MogoLocation mLocation;
|
||||||
|
|
||||||
|
private IMogoSocketManager mMogoSocketManager;
|
||||||
|
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -244,6 +251,19 @@ public class Demo2CardViewFragment extends MvpFragment< IView, Presenter< IView
|
|||||||
Logger.d( TAG, "demo模块定位,定位间隔4s" );
|
Logger.d( TAG, "demo模块定位,定位间隔4s" );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
mMogoSocketManager = ( IMogoSocketManager ) ARouter.getInstance().build( MogoServicePaths.PATH_SOCKET_MANAGER ).navigation();
|
||||||
|
mMogoSocketManager.registerOnMessageListener( 123, new IMogoOnMessageListener() {
|
||||||
|
@Override
|
||||||
|
public Class target() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMsgReceived( Object obj ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -36,6 +36,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="清空覆盖物" />
|
android:text="清空覆盖物" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_send_msg"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="发送长连接消息" />
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
||||||
|
|||||||
@@ -31,13 +31,19 @@ public abstract class MvpFragment< V extends IView, P extends Presenter< V > > e
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) {
|
public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) {
|
||||||
return inflater.inflate( getLayoutId(), container, false );
|
if ( mRootView == null ) {
|
||||||
|
mRootView = inflater.inflate( getLayoutId(), container, false );
|
||||||
|
} else {
|
||||||
|
ViewGroup viewGroup = ( ViewGroup ) mRootView.getParent();
|
||||||
|
if ( viewGroup != null )
|
||||||
|
viewGroup.removeView( mRootView );
|
||||||
|
}
|
||||||
|
return mRootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated( @NonNull View view, @Nullable Bundle savedInstanceState ) {
|
public void onViewCreated( @NonNull View view, @Nullable Bundle savedInstanceState ) {
|
||||||
super.onViewCreated( view, savedInstanceState );
|
super.onViewCreated( view, savedInstanceState );
|
||||||
mRootView = view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1
foudations/mogo-connection/.gitignore
vendored
Normal file
1
foudations/mogo-connection/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
47
foudations/mogo-connection/build.gradle
Normal file
47
foudations/mogo-connection/build.gradle
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'com.alibaba.arouter'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
|
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
api rootProject.ext.dependencies.socketsdk
|
||||||
|
api rootProject.ext.dependencies.socketsdkconnsvrprotoco
|
||||||
|
api rootProject.ext.dependencies.socketsdkprotobufjava
|
||||||
|
implementation rootProject.ext.dependencies.arouter
|
||||||
|
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
} else {
|
||||||
|
implementation project(":foudations:mogo-utils")
|
||||||
|
implementation project(":services:mogo-service-api")
|
||||||
|
}
|
||||||
|
}
|
||||||
0
foudations/mogo-connection/consumer-rules.pro
Normal file
0
foudations/mogo-connection/consumer-rules.pro
Normal file
3
foudations/mogo-connection/gradle.properties
Normal file
3
foudations/mogo-connection/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.connection
|
||||||
|
POM_ARTIFACT_ID=mogo-connection
|
||||||
|
VERSION_CODE=1
|
||||||
21
foudations/mogo-connection/proguard-rules.pro
vendored
Normal file
21
foudations/mogo-connection/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.mogo.demo.module.map2;
|
package com.mogo.connection;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ public class ExampleInstrumentedTest {
|
|||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
assertEquals( "com.mogo.demo.module.map2.test", appContext.getPackageName() );
|
assertEquals( "com.mogo.connection.test", appContext.getPackageName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2
foudations/mogo-connection/src/main/AndroidManifest.xml
Normal file
2
foudations/mogo-connection/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.mogo.connection" />
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.mogo.connection.socket;
|
||||||
|
|
||||||
|
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||||
|
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class MsgBody {
|
||||||
|
|
||||||
|
private int mMsgType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务端分发,业务线
|
||||||
|
*/
|
||||||
|
private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否回执
|
||||||
|
*/
|
||||||
|
private boolean mAck = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息ID
|
||||||
|
*/
|
||||||
|
private final long mMsgId = System.currentTimeMillis();
|
||||||
|
|
||||||
|
private Object mContent;
|
||||||
|
|
||||||
|
public MsgBody msgType( int msgType ) {
|
||||||
|
this.mMsgType = msgType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MsgBody ack( boolean ack ) {
|
||||||
|
this.mAck = ack;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MsgBody content( Object content ) {
|
||||||
|
this.mContent = content;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMsgType() {
|
||||||
|
return mMsgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProductLine() {
|
||||||
|
return mProductLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeaderType() {
|
||||||
|
return mHeaderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ismAck() {
|
||||||
|
return mAck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMsgId() {
|
||||||
|
return mMsgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getContent() {
|
||||||
|
return mContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
package com.mogo.connection.socket;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString;
|
||||||
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
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 com.mogo.utils.network.utils.GsonUtil;
|
||||||
|
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||||
|
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||||
|
import com.zhidao.socketsdk.manager.OnSocketAckCallback;
|
||||||
|
import com.zhidao.socketsdk.manager.OnSocketReceiveCallback;
|
||||||
|
import com.zhidao.socketsdk.manager.SocketConnManager;
|
||||||
|
import com.zhidao.socketsdk.manager.SocketConnManagerImpl;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 长链实现:基于 netty
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SocketManager implements IMogoSocketManager, OnSocketReceiveCallback, OnSocketAckCallback {
|
||||||
|
|
||||||
|
private static final String TAG = "SocketManager";
|
||||||
|
|
||||||
|
|
||||||
|
public static final int MSG_PRODUCT_LINE = MogoCommon.Product.mogoBussiness_VALUE;
|
||||||
|
private static final int MSG_HEADER_TYPE = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||||
|
|
||||||
|
private static volatile SocketManager sInstance;
|
||||||
|
|
||||||
|
private SocketManager( Context context ) {
|
||||||
|
mSocketConnManager = SocketConnManagerImpl.getInstance( context );
|
||||||
|
mSocketConnManager.addSocketMessageCallback( this );
|
||||||
|
mSocketConnManager.addSocketAckCallback( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SocketManager getInstance( Context context ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
synchronized ( SocketManager.class ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
sInstance = new SocketManager( context );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理消息分发
|
||||||
|
* <p>
|
||||||
|
* key - msgType
|
||||||
|
*/
|
||||||
|
private Map< Integer, IMogoOnMessageListener > mListeners = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理消息回执
|
||||||
|
* <p>
|
||||||
|
* key - msgId
|
||||||
|
*/
|
||||||
|
private Map< Long, IMogoMsgAckListener > mAckListeners = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
private SocketConnManager mSocketConnManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context, String appId ) {
|
||||||
|
if ( mSocketConnManager != null ) {
|
||||||
|
mSocketConnManager.init( appId );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessageReceived( byte[] content ) {
|
||||||
|
try {
|
||||||
|
MogoConnsvr.Payload payload = MogoConnsvr.Payload.parseFrom( content );
|
||||||
|
int msgType = payload.getMsgType();
|
||||||
|
Logger.d( TAG, "received msg type = %d", msgType );
|
||||||
|
IMogoOnMessageListener listener = mListeners.get( msgType );
|
||||||
|
if ( listener != null ) {
|
||||||
|
listener.onMsgReceived( GsonUtil.objectFromJson( payload.getPayload().toString(), listener.target() ) );
|
||||||
|
}
|
||||||
|
} catch ( InvalidProtocolBufferException e ) {
|
||||||
|
Logger.e( TAG, "parse msg error.", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAck( byte[] headerBytes, byte[] payloadBytes ) {
|
||||||
|
try {
|
||||||
|
MogoConnsvr.Header header = MogoConnsvr.Header.parseFrom( headerBytes );
|
||||||
|
int msgType = header.getMsgType();
|
||||||
|
String appId = header.getAppId();
|
||||||
|
int productLine = header.getProductLine();
|
||||||
|
long msgId = header.getMsgId();
|
||||||
|
IMogoMsgAckListener listener = mAckListeners.remove( msgId );
|
||||||
|
if ( listener != null ) {
|
||||||
|
listener.onAck( msgId );
|
||||||
|
}
|
||||||
|
Logger.d( TAG, "send message success: msgType = %d, appId = %s, productLine = %d", msgType, appId, productLine );
|
||||||
|
} catch ( InvalidProtocolBufferException e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||||
|
if ( mListeners.containsKey( msgType ) ) {
|
||||||
|
Logger.w( TAG, "msgType %d is exist.", msgType );
|
||||||
|
}
|
||||||
|
mListeners.put( msgType, listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterOnMessageListener( int msgType ) {
|
||||||
|
mListeners.remove( msgType );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMsg( MsgBody body, IMogoMsgAckListener listener ) {
|
||||||
|
Logger.d( TAG, "sendMsg." );
|
||||||
|
if ( mSocketConnManager != null ) {
|
||||||
|
if ( mSocketConnManager.isConnected() ) {
|
||||||
|
Logger.d( TAG, "isConnected." );
|
||||||
|
final byte[] pb = convertToPBBytes( body.getMsgType(), objectToBytes( body.getContent() ) );
|
||||||
|
mSocketConnManager.sendPayload(
|
||||||
|
MSG_PRODUCT_LINE,
|
||||||
|
pb,
|
||||||
|
MSG_HEADER_TYPE,
|
||||||
|
body.isAck(),
|
||||||
|
body.getMsgId()
|
||||||
|
);
|
||||||
|
mAckListeners.put( body.getMsgId(), listener );
|
||||||
|
} else {
|
||||||
|
Logger.e( TAG, "sendMsg error, connect is lost." );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.e( TAG, "sendMsg error, client is null." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] objectToBytes( Object obj ) {
|
||||||
|
String jsonStr = GsonUtil.jsonFromObject( obj );
|
||||||
|
return jsonStr.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] convertToPBBytes( int msgType, byte[] payloadBytes ) {
|
||||||
|
MogoConnsvr.Payload payloadData = MogoConnsvr.Payload.newBuilder()
|
||||||
|
.setMsgType( msgType )
|
||||||
|
.setPayload( ByteString.copyFrom( payloadBytes ) ).build();
|
||||||
|
return payloadData.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void release() {
|
||||||
|
mListeners.clear();
|
||||||
|
mListeners = null;
|
||||||
|
sInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">mogo-connection</string>
|
||||||
|
</resources>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.mogo.demo.module.map2;
|
package com.mogo.connection;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -37,4 +37,5 @@ MOGO_MODULE_MAP_VERSION=1.0.0-SNAPSHOT
|
|||||||
MOGO_SERVICE_VERSION=1.0.0-SNAPSHOT
|
MOGO_SERVICE_VERSION=1.0.0-SNAPSHOT
|
||||||
MOGO_SERVICE_API_VERSION=1.0.0-SNAPSHOT
|
MOGO_SERVICE_API_VERSION=1.0.0-SNAPSHOT
|
||||||
MOGO_MODULE_APPS_VERSION=1.0.0-SNAPSHOT
|
MOGO_MODULE_APPS_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_CONNECTION_VERSION=1.0.0-SNAPSHOT
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public interface IMogoMarkerManager {
|
|||||||
List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter );
|
List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除某一个类、某个模块的markers
|
* 移除某一个类型、某个模块的 markers
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param tag
|
||||||
*/
|
*/
|
||||||
@@ -40,4 +40,12 @@ public interface IMogoMarkerManager {
|
|||||||
* 移除地图上所有markers
|
* 移除地图上所有markers
|
||||||
*/
|
*/
|
||||||
void removeMarkers();
|
void removeMarkers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某种类型的全部marker。
|
||||||
|
*
|
||||||
|
* @param tag 业务类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List< IMogoMarker > getMarkers( String tag );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized List< IMogoMarker > getMarkers( String tag ) {
|
||||||
|
return mServicesMarkers.get( tag );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized void add( String tag, IMogoMarker marker ) {
|
public synchronized void add( String tag, IMogoMarker marker ) {
|
||||||
if ( marker == null ) {
|
if ( marker == null ) {
|
||||||
|
|||||||
@@ -72,4 +72,8 @@ public class MogoMarkerManager implements IMogoMarkerManager {
|
|||||||
MogoMarkersHandler.getInstance().removeAll();
|
MogoMarkersHandler.getInstance().removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List< IMogoMarker > getMarkers( String tag ) {
|
||||||
|
return MogoMarkersHandler.getInstance().getMarkers( tag );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.mogo.module.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 模块描述信息
|
||||||
|
*/
|
||||||
|
public class MogoModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块加载路径
|
||||||
|
*/
|
||||||
|
private String mPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称
|
||||||
|
*/
|
||||||
|
private String mName;
|
||||||
|
|
||||||
|
public MogoModule( String path, String name ) {
|
||||||
|
this.mPath = path;
|
||||||
|
this.mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath( String path ) {
|
||||||
|
this.mPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName( String name ) {
|
||||||
|
this.mName = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ import java.util.Vector;
|
|||||||
*/
|
*/
|
||||||
public class MogoModulePaths {
|
public class MogoModulePaths {
|
||||||
|
|
||||||
private static List< String > mModulesPath = new ArrayList<>();
|
private static List< MogoModule > mMogoModules = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地图模块 fragment 路径
|
* 地图模块 fragment 路径
|
||||||
@@ -33,10 +33,17 @@ public class MogoModulePaths {
|
|||||||
if ( TextUtils.isEmpty( path.replace( " ", "" ) ) ) {
|
if ( TextUtils.isEmpty( path.replace( " ", "" ) ) ) {
|
||||||
throw new IllegalArgumentException( "module path can't be empty or null or blank" );
|
throw new IllegalArgumentException( "module path can't be empty or null or blank" );
|
||||||
}
|
}
|
||||||
mModulesPath.add( path );
|
mMogoModules.add( new MogoModule( path, "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List< String > getModulesPath() {
|
public static void addModule( MogoModule module ) {
|
||||||
return mModulesPath;
|
if ( module == null || TextUtils.isEmpty( module.getPath().replace( " ", "" ) ) ) {
|
||||||
|
throw new IllegalArgumentException( "module path can't be empty or null or blank" );
|
||||||
|
}
|
||||||
|
mMogoModules.add( module );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List< MogoModule > getModules() {
|
||||||
|
return mMogoModules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
implementation rootProject.ext.dependencies.mogoservice
|
implementation rootProject.ext.dependencies.mogoservice
|
||||||
implementation rootProject.ext.dependencies.moduleapps
|
implementation rootProject.ext.dependencies.moduleapps
|
||||||
|
implementation rootProject.ext.dependencies.mogoconnection
|
||||||
} else {
|
} else {
|
||||||
implementation project(":foudations:mogo-utils")
|
implementation project(":foudations:mogo-utils")
|
||||||
implementation project(":foudations:mogo-commons")
|
implementation project(":foudations:mogo-commons")
|
||||||
@@ -51,6 +52,7 @@ dependencies {
|
|||||||
implementation project(':services:mogo-service-api')
|
implementation project(':services:mogo-service-api')
|
||||||
implementation project(':services:mogo-service')
|
implementation project(':services:mogo-service')
|
||||||
implementation project(':modules:mogo-module-apps')
|
implementation project(':modules:mogo-module-apps')
|
||||||
|
implementation project(':foudations:mogo-connection')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.mogo.module.main;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2020-01-01
|
||||||
|
* <p>
|
||||||
|
* 常量
|
||||||
|
*/
|
||||||
|
public class AppConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长链 appId
|
||||||
|
*/
|
||||||
|
public static final String SOCKET_APP_ID = "com.mogo.launcher";
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mogo.module.main;
|
package com.mogo.module.main;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -20,6 +19,7 @@ import com.mogo.module.main.cards.MogoModulesManager;
|
|||||||
import com.mogo.module.main.cards.OrientedViewPager;
|
import com.mogo.module.main.cards.OrientedViewPager;
|
||||||
import com.mogo.module.main.cards.VerticalStackTransformer;
|
import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||||
import com.mogo.service.MogoServicePaths;
|
import com.mogo.service.MogoServicePaths;
|
||||||
|
import com.mogo.service.connection.IMogoSocketManager;
|
||||||
import com.mogo.service.map.IMogoMapService;
|
import com.mogo.service.map.IMogoMapService;
|
||||||
import com.mogo.service.module.IMogoModuleProvider;
|
import com.mogo.service.module.IMogoModuleProvider;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -41,6 +41,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
private IMogoMapService mMogoMapService;
|
private IMogoMapService mMogoMapService;
|
||||||
private MogoModulesHandler mMogoModuleHandler;
|
private MogoModulesHandler mMogoModuleHandler;
|
||||||
|
|
||||||
|
private IMogoSocketManager mMogoSocketManager;
|
||||||
|
|
||||||
private OrientedViewPager mCardsContainer;
|
private OrientedViewPager mCardsContainer;
|
||||||
private CardModulesAdapter mCardModulesAdapter;
|
private CardModulesAdapter mCardModulesAdapter;
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
*/
|
*/
|
||||||
private IMogoLocationClient mLocationClient;
|
private IMogoLocationClient mLocationClient;
|
||||||
|
|
||||||
private int mCurrentPosition = 1;
|
private int mCurrentPosition = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
@@ -63,17 +65,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
|
|
||||||
mCardsContainer.setOnPageChangeListener( new ViewPager.OnPageChangeListener() {
|
mCardsContainer.setOnPageChangeListener( new ViewPager.OnPageChangeListener() {
|
||||||
|
|
||||||
private int mLastPosition = -1;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||||
Logger.i( TAG, "position = " + position );
|
Logger.i( TAG, "position = " + position );
|
||||||
if ( mLastPosition != position ) {
|
|
||||||
if ( mCardModulesAdapter != null ) {
|
|
||||||
mCardModulesAdapter.render( position );
|
|
||||||
}
|
|
||||||
mLastPosition = position;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,31 +83,27 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
@Override
|
@Override
|
||||||
public void onPageScrollStateChanged( int state ) {
|
public void onPageScrollStateChanged( int state ) {
|
||||||
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||||
if ( mCurrentPosition == 0 ) {
|
// if ( mCurrentPosition == 0 ) {
|
||||||
mCurrentPosition = mCardModulesAdapter.getCount() - 3;
|
// mCurrentPosition = mCardModulesAdapter.getCount() - 3;
|
||||||
mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
// mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||||
} else if ( mCurrentPosition == mCardModulesAdapter.getCount() - 2 ) {
|
// } else if ( mCurrentPosition == mCardModulesAdapter.getCount() - 2 ) {
|
||||||
mCurrentPosition = 1;
|
// mCurrentPosition = 1;
|
||||||
mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
// mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentPosition() {
|
|
||||||
return mCurrentPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrientedViewPager getCardsContainer() {
|
|
||||||
return mCardsContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||||
super.onCreate( savedInstanceState );
|
super.onCreate( savedInstanceState );
|
||||||
|
|
||||||
mMogoModuleHandler = new MogoModulesManager( this );
|
mMogoModuleHandler = new MogoModulesManager( this );
|
||||||
|
|
||||||
|
mMogoSocketManager = ( IMogoSocketManager ) ARouter.getInstance().build( MogoServicePaths.PATH_SOCKET_MANAGER ).navigation();
|
||||||
|
mMogoSocketManager.init( getApplicationContext(), AppConstants.SOCKET_APP_ID );
|
||||||
|
|
||||||
mMogoModuleHandler.onMapLoadedCallback( new Runnable() {
|
mMogoModuleHandler.onMapLoadedCallback( new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -140,9 +130,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
|
|
||||||
private void loadModules() {
|
private void loadModules() {
|
||||||
|
|
||||||
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCardsModule();
|
||||||
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||||
mCardsContainer.setOffscreenPageLimit( providers.size() + 2 );
|
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||||
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
||||||
mCardsContainer.setAdapter( mCardModulesAdapter );
|
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||||
mCardsContainer.setCurrentItem( mCurrentPosition );
|
mCardsContainer.setCurrentItem( mCurrentPosition );
|
||||||
@@ -182,5 +172,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
mMogoModuleHandler.destroy();
|
mMogoModuleHandler.destroy();
|
||||||
mMogoModuleHandler = null;
|
mMogoModuleHandler = null;
|
||||||
}
|
}
|
||||||
|
mMogoSocketManager = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.mogo.module.main.cards;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -30,18 +28,10 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
|||||||
private final MainActivity mActivity;
|
private final MainActivity mActivity;
|
||||||
private List< IMogoModuleProvider > mProviders;
|
private List< IMogoModuleProvider > mProviders;
|
||||||
|
|
||||||
private PlaceholderFragmentProvider mLastPH;
|
|
||||||
private PlaceholderFragmentProvider mFirstPH;
|
|
||||||
private PlaceholderFragmentProvider mPH;
|
|
||||||
|
|
||||||
|
|
||||||
public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
||||||
super( fragmentActivity.getSupportFragmentManager() );
|
super( fragmentActivity.getSupportFragmentManager() );
|
||||||
mActivity = fragmentActivity;
|
mActivity = fragmentActivity;
|
||||||
this.mProviders = new ArrayList<>( providers );
|
this.mProviders = new ArrayList<>( providers );
|
||||||
this.mProviders.add( 0, mLastPH = new PlaceholderFragmentProvider() );
|
|
||||||
this.mProviders.add( mFirstPH = new PlaceholderFragmentProvider() );
|
|
||||||
this.mProviders.add( mPH = new PlaceholderFragmentProvider() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -52,11 +42,6 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
|||||||
bundle.putInt( "position", factPosition );
|
bundle.putInt( "position", factPosition );
|
||||||
Logger.d( TAG, "here" );
|
Logger.d( TAG, "here" );
|
||||||
final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
|
final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
|
||||||
if ( position == 0 ) {
|
|
||||||
mLastPH.setCopyTarget( f );
|
|
||||||
} else if ( position == getCount() - 2 ) {
|
|
||||||
mFirstPH.setCopyTarget( f );
|
|
||||||
}
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,23 +91,8 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
|||||||
return currentPosition + offset;
|
return currentPosition + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroyItem( @NonNull ViewGroup container, int position, @NonNull Object object ) {
|
|
||||||
// super.destroyItem( container, position, object );
|
|
||||||
// Logger.d( TAG, "destroy " + object );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishUpdate( @NonNull ViewGroup container ) {
|
public void finishUpdate( @NonNull ViewGroup container ) {
|
||||||
super.finishUpdate( container );
|
super.finishUpdate( container );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render( int position ) {
|
|
||||||
if ( position == 1 ) {
|
|
||||||
mLastPH.renderTargetUI();
|
|
||||||
} else if ( position == getCount() - 2 ) {
|
|
||||||
mFirstPH.renderTargetUI();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public interface MogoModulesHandler extends IMogoMapListener,
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List< IMogoModuleProvider > loadCards();
|
List< IMogoModuleProvider > loadCardsModule();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载小智语音
|
* 加载小智语音
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.mogo.map.model.MogoPoi;
|
|||||||
import com.mogo.map.navi.IMogoNaviListener;
|
import com.mogo.map.navi.IMogoNaviListener;
|
||||||
import com.mogo.map.navi.MogoNaviInfo;
|
import com.mogo.map.navi.MogoNaviInfo;
|
||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
|
import com.mogo.module.common.MogoModule;
|
||||||
import com.mogo.module.common.MogoModulePaths;
|
import com.mogo.module.common.MogoModulePaths;
|
||||||
import com.mogo.module.main.MainActivity;
|
import com.mogo.module.main.MainActivity;
|
||||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
@@ -69,12 +70,12 @@ public class MogoModulesManager implements MogoModulesHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List< IMogoModuleProvider > loadCards() {
|
public List< IMogoModuleProvider > loadCardsModule() {
|
||||||
final List< String > modulePaths = MogoModulePaths.getModulesPath();
|
final List< MogoModule > modules = MogoModulePaths.getModules();
|
||||||
final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
|
final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
|
||||||
if ( modulePaths != null && !modulePaths.isEmpty() ) {
|
if ( modules != null && !modules.isEmpty() ) {
|
||||||
for ( String modulePath : modulePaths ) {
|
for ( MogoModule module : modules ) {
|
||||||
IMogoModuleProvider provider = load( modulePath );
|
IMogoModuleProvider provider = load( module.getPath() );
|
||||||
providers.add( provider );
|
providers.add( provider );
|
||||||
mCardProviders.put( provider.getModuleName(), provider );
|
mCardProviders.put( provider.getModuleName(), provider );
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,47 +1,48 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- 小智语音-->
|
<!-- 小智语音-->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/module_main_id_ai_fragment_container"
|
android:id="@+id/module_main_id_ai_fragment_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="75dp"
|
||||||
|
android:background="#f00"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<!-- 卡片-->
|
<LinearLayout
|
||||||
<FrameLayout
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/module_main_id_fragment_container"
|
android:layout_height="match_parent">
|
||||||
android:layout_width="300dp"
|
<!-- 卡片-->
|
||||||
android:layout_height="match_parent"
|
<FrameLayout
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
android:id="@+id/module_main_id_fragment_container"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
android:layout_width="0dp"
|
||||||
|
|
||||||
|
|
||||||
<com.mogo.module.main.cards.OrientedViewPager
|
|
||||||
android:id="@+id/module_main_id_cards_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_weight="1"
|
||||||
android:layout_marginBottom="50dp"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
android:padding="10dp" />
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<!-- <androidx.viewpager2.widget.ViewPager2-->
|
<com.mogo.module.main.cards.OrientedViewPager
|
||||||
<!-- android:id="@+id/module_main_id_cards_container"-->
|
android:id="@+id/module_main_id_cards_container"
|
||||||
<!-- android:layout_width="match_parent"-->
|
android:layout_width="match_parent"
|
||||||
<!-- android:layout_height="match_parent"-->
|
android:layout_height="match_parent"
|
||||||
<!-- android:clipChildren="false" />-->
|
android:layout_marginBottom="50dp"
|
||||||
|
android:padding="10dp" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<!-- 地图-->
|
<!-- 地图-->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/module_main_id_map_fragment_container"
|
android:id="@+id/module_main_id_map_fragment_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintLeft_toRightOf="@+id/module_main_id_fragment_container"
|
android:layout_weight="2"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintLeft_toRightOf="@+id/module_main_id_fragment_container"
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="#f00">
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -40,4 +40,9 @@ public class MogoServicePaths {
|
|||||||
*/
|
*/
|
||||||
@Keep
|
@Keep
|
||||||
public static final String PATH_SERVICES_NETWORK = "/networkservices/api";
|
public static final String PATH_SERVICES_NETWORK = "/networkservices/api";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* netty 长链
|
||||||
|
*/
|
||||||
|
public static final String PATH_SOCKET_MANAGER = "/socket/manager";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.mogo.service.connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2020-01-01
|
||||||
|
* <p>
|
||||||
|
* 消息回执监听
|
||||||
|
*/
|
||||||
|
public interface IMogoMsgAckListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息回执
|
||||||
|
*/
|
||||||
|
void onAck( long msgId );
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.mogo.service.connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 消息回调
|
||||||
|
*/
|
||||||
|
public interface IMogoOnMessageListener< T > {
|
||||||
|
|
||||||
|
Class< T > target();
|
||||||
|
|
||||||
|
void onMsgReceived( T obj );
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.mogo.service.connection;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* socket 长链
|
||||||
|
*/
|
||||||
|
public interface IMogoSocketManager extends IProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化,各模块不用关心
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param appId 一般为包名
|
||||||
|
*/
|
||||||
|
void init( Context context, String appId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册消息监听
|
||||||
|
*
|
||||||
|
* @param msgType 消息类型
|
||||||
|
* @param listener 回调
|
||||||
|
*/
|
||||||
|
void registerOnMessageListener( int msgType, IMogoOnMessageListener listener );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销消息监听
|
||||||
|
*
|
||||||
|
* @param msgType 消息类型
|
||||||
|
*/
|
||||||
|
void unregisterOnMessageListener( int msgType );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
*
|
||||||
|
* @param body 消息体
|
||||||
|
* @param listener 回执监听
|
||||||
|
*/
|
||||||
|
void sendMsg( MsgBody body, IMogoMsgAckListener listener );
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.mogo.service.connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class MsgBody {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
*/
|
||||||
|
private int mMsgType;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 服务端分发,业务线
|
||||||
|
// */
|
||||||
|
// private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
// private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否回执
|
||||||
|
*/
|
||||||
|
private boolean mAck = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息ID
|
||||||
|
*/
|
||||||
|
private final long mMsgId = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private Object mContent;
|
||||||
|
|
||||||
|
public MsgBody msgType( int msgType ) {
|
||||||
|
this.mMsgType = msgType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MsgBody ack( boolean ack ) {
|
||||||
|
this.mAck = ack;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MsgBody content( Object object ) {
|
||||||
|
this.mContent = object;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMsgType() {
|
||||||
|
return mMsgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAck() {
|
||||||
|
return mAck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMsgId() {
|
||||||
|
return mMsgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getContent() {
|
||||||
|
return mContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,12 +46,14 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.mogoutils
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
implementation rootProject.ext.dependencies.mogocommons
|
implementation rootProject.ext.dependencies.mogocommons
|
||||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
implementation rootProject.ext.dependencies.mogoconnection
|
||||||
} else {
|
} else {
|
||||||
api project(":libraries:mogo-map")
|
api project(":libraries:mogo-map")
|
||||||
implementation project(":libraries:mogo-map-api")
|
implementation project(":libraries:mogo-map-api")
|
||||||
implementation project(":foudations:mogo-utils")
|
implementation project(":foudations:mogo-utils")
|
||||||
implementation project(":foudations:mogo-commons")
|
implementation project(":foudations:mogo-commons")
|
||||||
implementation project(':services:mogo-service-api')
|
implementation project(":services:mogo-service-api")
|
||||||
|
implementation project(":foudations:mogo-connection")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-31
|
||||||
|
* <p>
|
||||||
|
* 长链操作管理
|
||||||
|
*/
|
||||||
|
@Route( path = MogoServicePaths.PATH_SOCKET_MANAGER )
|
||||||
|
public class MogoSocketManager implements IMogoSocketManager {
|
||||||
|
|
||||||
|
private IMogoSocketManager mDelegate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context, String appId ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.init( context, appId );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.registerOnMessageListener( msgType, listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterOnMessageListener( int msgType ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.unregisterOnMessageListener( msgType );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMsg( MsgBody body, IMogoMsgAckListener listener ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.sendMsg( body, listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context ) {
|
||||||
|
mDelegate = SocketManager.getInstance( context );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,3 +14,4 @@ include ':libraries:map-amap'
|
|||||||
//include ':libraries:map-baidu'
|
//include ':libraries:map-baidu'
|
||||||
include ':libraries:mogo-map-api'
|
include ':libraries:mogo-map-api'
|
||||||
include ':modules:mogo-module-apps'
|
include ':modules:mogo-module-apps'
|
||||||
|
include ':foudations:mogo-connection'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
./gradlew :foudations:mogo-commons:clean :foudations:mogo-commons:uploadArchives
|
./gradlew :foudations:mogo-commons:clean :foudations:mogo-commons:uploadArchives
|
||||||
./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives
|
./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives
|
||||||
./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives
|
./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives
|
||||||
|
./gradlew :foudations:mogo-connection:clean :foudations:mogo-connection:uploadArchives
|
||||||
./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives
|
./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives
|
||||||
./gradlew :libraries:mogo-map:clean :libraries:mogo-map:uploadArchives
|
./gradlew :libraries:mogo-map:clean :libraries:mogo-map:uploadArchives
|
||||||
./gradlew :services:mogo-service:clean :services:mogo-service:uploadArchives
|
./gradlew :services:mogo-service:clean :services:mogo-service:uploadArchives
|
||||||
|
|||||||
Reference in New Issue
Block a user