Merge remote-tracking branch 'origin/feature/v1.0.0' into feature/v1.0.0

This commit is contained in:
zhangyuanzhen
2020-02-20 20:21:35 +08:00
9 changed files with 69 additions and 11 deletions

View File

@@ -112,7 +112,7 @@ ext {
//统一返回键
mogomoduleback : "com.mogo.module:module-back:${MOGO_MODULE_BACK_VERSION}",
// 长链
socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.0',
socketsdk : 'com.zhidao.socketsdk:socketsdk:2.1.1',
socketsdkconnsvrprotoco : 'com.zhidao.ptech:connsvr-protoco:0.1.23',
socketsdkprotobufjava : 'com.google.protobuf:protobuf-java:3.5.1',

View File

@@ -0,0 +1,17 @@
package com.mogo.connection.socket;
/**
* @author congtaowang
* @since 2020-02-20
* <p>
* 长链接口数据接口
*/
public interface IMessageResponse {
/**
* 设置消息id
*
* @param msgId
*/
void setMsgId( long msgId );
}

View File

@@ -82,7 +82,7 @@ public class SocketManager implements IMogoSocketManager, OnSocketReceiveCallbac
}
@Override
public void onMessageReceived( byte[] content ) {
public void onMessageReceived( byte[] content, long msgId ) {
try {
MogoConnsvr.Payload payload = MogoConnsvr.Payload.parseFrom( content );
int msgType = payload.getMsgType();
@@ -93,8 +93,12 @@ public class SocketManager implements IMogoSocketManager, OnSocketReceiveCallbac
while ( iterator.hasNext() ) {
IMogoOnMessageListener listener = iterator.next();
if ( listener != null ) {
Logger.d(TAG, "received msg ==" + payload.getPayload().toStringUtf8());
listener.onMsgReceived( GsonUtil.objectFromJson( payload.getPayload().toStringUtf8(), listener.target() ) );
Object obj = GsonUtil.objectFromJson( payload.getPayload().toStringUtf8(), listener.target() );
if ( obj instanceof IMessageResponse ) {
( ( IMessageResponse ) obj ).setMsgId( msgId );
}
Logger.d(TAG, "received msg == %s, msgId = %s", payload.getPayload().toStringUtf8(), msgId);
listener.onMsgReceived( obj );
}
}
}

View File

@@ -431,7 +431,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
style.strokeWidth(0);
style.radiusFillColor( Color.TRANSPARENT );
style.myLocationIcon(
BitmapDescriptorFactory.fromResource(R.drawable.map_api_ic_current_location));
BitmapDescriptorFactory.fromResource(R.drawable.map_api_ic_current_location2));
mMapView.getMap().setMyLocationStyle(style);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 918 B

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -113,6 +113,18 @@ public class MogoServiceProvider implements IMogoModuleProvider,
*/
private boolean mIsCameraInited = true;
/**
* 是否针对第一次请求失败的情况(开机请求、地库长时间没网络)
* <p>
* 说明第一次地位成功因为网络问题导致请求失败则在其他策略请求之前尝试10s请求一次。
*/
private boolean mLoopRequest = false;
/**
* 刷新补偿间隔
*/
private long mLoopInterval = 10_000L;
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( @NonNull Message msg ) {
@@ -127,7 +139,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
if ( mRefreshRemainingTime == 0 ) {
Logger.d( TAG, "move to center and refresh data." );
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
mUiController.moveToCenter( mLastAutoRefreshLocation );
mUiController.recoverLockMode();
mStatusManager.setUserInteractionStatus( TAG, true, false );
mUiController.changeZoom( 16.0f );
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
@@ -135,6 +147,12 @@ public class MogoServiceProvider implements IMogoModuleProvider,
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
}
break;
case ServiceConst.MSG_LOOP_REQUEST:
if ( mLoopRequest ) {
Logger.d( TAG, "补偿刷新触发" );
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
}
break;
}
}
};
@@ -156,6 +174,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
private RefreshCallback mCustomRefreshCallback = new RefreshCallback() {
@Override
public void onSuccess() {
mLoopRequest = false;
mRefreshRemainingTimeStatus = false;
// 用户手动操作地图刷新成功后,设置状态为 true引发延时策略
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, true );
@@ -173,12 +192,17 @@ public class MogoServiceProvider implements IMogoModuleProvider,
private RefreshCallback mAutoRefreshCallback = new RefreshCallback() {
@Override
public void onSuccess() {
mLoopRequest = false;
invokeAutoRefreshStrategy();
}
@Override
public void onFail() {
invokeAutoRefreshStrategy();
if ( mLoopRequest ) {
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_LOOP_REQUEST, ServiceConst.LOOP_INTERVAL );
} else {
invokeAutoRefreshStrategy();
}
}
private void invokeAutoRefreshStrategy() {
@@ -480,14 +504,17 @@ public class MogoServiceProvider implements IMogoModuleProvider,
final MogoLatLng point = new MogoLatLng( location.getLatitude(), location.getLongitude() );
if ( mLastAutoRefreshLocation == null ) {
mLastAutoRefreshLocation = point;
mLoopRequest = true;
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
return;
}
mLastAutoRefreshLocation = point;
float distance = Utils.calculateLineDistance( mLastAutoRefreshLocation, new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
float distance = Utils.calculateLineDistance( mLastAutoRefreshLocation, point );
if ( distance > mAutoRefreshStrategy.getDistance() ) {
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, true );
mUiController.moveToCenter( mLastAutoRefreshLocation );
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
mUiController.recoverLockMode();
mStatusManager.setUserInteractionStatus( TAG, true, false );
mUiController.changeZoom( 16.0f );
mLastAutoRefreshLocation = point;
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
}
}

View File

@@ -27,6 +27,16 @@ public class ServiceConst {
*/
public static final int DECREASE_INTERVAL = 1_000;
/**
* 刷新失败补偿消息
*/
public static final int MSG_LOOP_REQUEST = 10_000;
/**
* 刷新失败补偿时间间隔
*/
public static final int LOOP_INTERVAL = 10_000;
/**
* 卡片 车聊聊
*/