add MoGoAiCloud sdk --> socket passport replace origin logic

This commit is contained in:
zhongchao
2021-02-23 11:20:39 +08:00
parent 024988b241
commit 632ececb99
45 changed files with 1285 additions and 873 deletions

View File

@@ -10,7 +10,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import com.mogo.commons.debug.DebugConfig;
@@ -49,6 +48,7 @@ import com.mogo.module.service.refresh.RefreshObject;
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
import com.mogo.module.service.ttsConfig.TtsConfigModleData;
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
import com.mogo.realtime.api.MoGoAiCloudRealTime;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.adas.IMogoAdasCarDataCallback;
import com.mogo.service.adas.entity.ADASCarStateInfo;
@@ -67,7 +67,6 @@ import com.mogo.utils.NetworkUtils;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
@@ -394,7 +393,7 @@ public class MogoServices implements IMogoMapListener,
mContext.sendBroadcast( intent );
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
SnapshotUploadInTime.getInstance().start( mContext );
MoGoAiCloudRealTime.startRealTime( mContext, DebugConfig.getSocketAppId() );
}
}
@@ -929,6 +928,7 @@ public class MogoServices implements IMogoMapListener,
@Override
public void destroy() {
Logger.d( TAG, "MogoServices do nothings." );
MoGoAiCloudRealTime.stopRealTime();
}
public Location getLastCarLocation() {

View File

@@ -27,7 +27,6 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.ADASCarStateInfo;
import com.mogo.service.entrance.ButtonIndex;

View File

@@ -13,7 +13,6 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.MarkerDrawer;
@@ -29,26 +28,24 @@ import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.utils.CloudPoiManager;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.MogoServices;
import com.mogo.module.service.R;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.network.RefreshCallback;
import com.mogo.module.service.network.RefreshModel;
import com.mogo.module.service.vrmode.VrModeController;
import com.mogo.realtime.api.MoGoAiCloudRealTime;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
import com.mogo.service.connection.WebSocketMsgType;
import com.mogo.service.module.IMogoBizActionDoneListener;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import com.zhidao.carchattingprovider.ICallChatResponse;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.ICallChatResponse;
import org.json.JSONArray;
import org.json.JSONException;
@@ -67,7 +64,7 @@ import java.util.Map;
* version: 1.0
*/
public class MapMarkerManager implements IMogoMarkerClickListener,
IMogoOnMessageListener< MarkerResponse >,
IMogoOnMessageListener<MarkerResponse>,
IMogoBizActionDoneListener,
IMogoADASControlStatusChangedListener {
private static final String TAG = "MapMarkerManager";
@@ -91,8 +88,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
public static synchronized MapMarkerManager getInstance() {
synchronized ( MapMarkerManager.class ) {
if ( mMarkerManager == null ) {
synchronized (MapMarkerManager.class) {
if (mMarkerManager == null) {
mMarkerManager = new MapMarkerManager();
}
}
@@ -103,86 +100,61 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
/**
* 初始化大而全的 Marker 管理
*
* @param context
* @param context 上下文对象
*/
public void init( Context context ) {
public void init(Context context) {
if ( mContext != null ) {
if (mContext != null) {
return;
}
mContext = context.getApplicationContext();
mRefreshModel = new RefreshModel( mContext );
CloudPoiManager.getInstance().updateFromConfig( context );
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener( TAG, this );
mRefreshModel = new RefreshModel(mContext);
CloudPoiManager.getInstance().updateFromConfig(context);
MarkerServiceHandler.getActionManager().registerBizActionDoneListener(this);
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener(TAG, this);
if ( CallChatApi.getInstance().getApiProvider() != null ) {
CallChatApi.getInstance().getApiProvider().registerUserWindowStatusListener( TAG, mContext, new ICallChatResponse() {
if (CallChatApi.getInstance().getApiProvider() != null) {
CallChatApi.getInstance().getApiProvider().registerUserWindowStatusListener(TAG, mContext, new ICallChatResponse() {
@Override
public void userWindowStatus( boolean show ) {
public void userWindowStatus(boolean show) {
try {
if ( mLastCheckMarker == null ) {
if (mLastCheckMarker == null) {
return;
}
if ( TextUtils.equals( mLastCheckMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA )
&& !show ) {
closeMarker( mLastCheckMarker );
if (TextUtils.equals(mLastCheckMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)
&& !show) {
closeMarker(mLastCheckMarker);
}
} catch ( Exception e ) {
} catch (Exception e) {
e.printStackTrace();
}
}
} );
});
// 每隔一秒下发的数据
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext )
.registerOnWebSocketMessageListener( new IMogoOnWebSocketMessageListener< MogoSnapshotSetData >() {
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
@Override
public void onMsgSend(long id) {
@Override
public WebSocketMsgType getUpLinkType() {
return null;
}
}
@Override
public WebSocketMsgType getDownLinkType() {
return WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
}
@Override
public Class< MogoSnapshotSetData > target() {
return MogoSnapshotSetData.class;
}
@Override
public void onMsgReceived( MogoSnapshotSetData data ) {
// if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
//// return;
// }
//
// if ( MogoServices.getInstance().getLastCarLocation() != null ) {
// data.curSpeed = MogoServices.getInstance().getLastCarLocation().getSpeed();
// }
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
// VrModeController.getInstance().renderMogoSnapshotSetData( data );
}
@Override
public void onError( String errorMsg ) {
}
} );
@Override
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
}
});
// adas 每隔一秒传递的数据
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> {
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
double speed = 0.0;
if ( MogoServices.getInstance().getLastCarLocation() != null ) {
if (MogoServices.getInstance().getLastCarLocation() != null) {
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
}
// 绘制近景识别到的车辆,每秒绘制一次
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList, false, speed );
} );
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
});
}
}
@@ -190,32 +162,32 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
* 地图上的Marker点击回调
*/
@Override
public boolean onMarkerClicked( IMogoMarker marker ) {
public boolean onMarkerClicked(IMogoMarker marker) {
try {
boolean result = switchMarkerOpenStatus( marker );
if ( !result ) {
updateCarUserInfoWindow( marker );
boolean result = switchMarkerOpenStatus(marker);
if (!result) {
updateCarUserInfoWindow(marker);
return false;
}
Map< String, Object > properties = new HashMap<>();
Map<String, Object> properties = new HashMap<>();
if ( marker.getObject() instanceof MarkerShowEntity ) {
final String sn = MarkerDrawer.getInstance().getCarSnFromMarker( marker );
if ( TextUtils.isEmpty( sn ) ) {
if (marker.getObject() instanceof MarkerShowEntity) {
final String sn = MarkerDrawer.getInstance().getCarSnFromMarker(marker);
if (TextUtils.isEmpty(sn)) {
return false;
}
properties.put( "sn", sn );
if ( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerExploreWay ) {
MarkerExploreWay exploreWay = ( MarkerExploreWay ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj();
properties.put( "dbid", exploreWay.getInfoId() );
properties.put( "type", exploreWay.getPoiType() );
} else if ( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerOnlineCar ) {
properties.put( "type", "10000" );
properties.put("sn", sn);
if (((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerExploreWay) {
MarkerExploreWay exploreWay = (MarkerExploreWay) ((MarkerShowEntity) marker.getObject()).getBindObj();
properties.put("dbid", exploreWay.getInfoId());
properties.put("type", exploreWay.getPoiType());
} else if (((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerOnlineCar) {
properties.put("type", "10000");
}
}
MarkerServiceHandler.getMogoAnalytics().track( "v2x_road_click", properties );
} catch ( Exception e ) {
MarkerServiceHandler.getMogoAnalytics().track("v2x_road_click", properties);
} catch (Exception e) {
e.printStackTrace();
}
return false;
@@ -224,144 +196,142 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
/**
* 切换当前选中marker和上一个选中的状态
*
* @param marker
* @return
* @param marker 地图marker抽象对象
* @return markerOpenStatus
*/
private boolean switchMarkerOpenStatus( IMogoMarker marker ) {
if ( mLastCheckMarker != null ) {
private boolean switchMarkerOpenStatus(IMogoMarker marker) {
if (mLastCheckMarker != null) {
// 判断点击的是否是同一个
if ( marker.equals( mLastCheckMarker ) ) {
if (marker.equals(mLastCheckMarker)) {
return false;
}
// 将上次选中 Marker 设置为未选中状态
closeMarker( mLastCheckMarker );
closeMarker(mLastCheckMarker);
}
// 将当前的Marker设置为选中
openMarker( marker );
openMarker(marker);
return true;
}
// 展开气泡
private void openMarker( IMogoMarker mogoMarker ) {
if ( mogoMarker == null ) {
private void openMarker(IMogoMarker mogoMarker) {
if (mogoMarker == null) {
return;
}
mLastCheckMarker = mogoMarker;
// 在线车辆点击使用infoWindow
if ( TextUtils.equals( mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
updateCarUserInfoWindow( mogoMarker );
if (TextUtils.equals(mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)) {
updateCarUserInfoWindow(mogoMarker);
} else {
Object object = mogoMarker.getObject();
if ( object instanceof MarkerShowEntity ) {
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
markerShowEntity.setChecked( true );
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
markerView.setMarker( mogoMarker );
if ( markerView instanceof OnlineCarMarkerView ) {
if (object instanceof MarkerShowEntity) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(true);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
markerView.setMarker(mogoMarker);
if (markerView instanceof OnlineCarMarkerView) {
try {
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
} catch ( Exception e ) {
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
mogoMarker.setIcon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
} catch (Exception e) {
mogoMarker.setIcon(markerView.getBitmap(0));
}
} else {
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
if (MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
mogoMarker.setToTop();
}
}
if ( !MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
MarkerServiceHandler.getMapUIController().moveToCenter( mogoMarker.getPosition(), DebugConfig.isRoadEventAnimated() );
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
MarkerServiceHandler.getMapUIController().moveToCenter(mogoMarker.getPosition(), DebugConfig.isRoadEventAnimated());
}
}
private void updateCarUserInfoWindow( IMogoMarker marker ) {
if ( marker != null && !marker.isDestroyed() ) {
private void updateCarUserInfoWindow(IMogoMarker marker) {
if (marker != null && !marker.isDestroyed()) {
try {
if ( !TextUtils.equals( marker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
if (!TextUtils.equals(marker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)) {
return;
}
marker.setIcon( OnlineCarMarkerView.getInstance().getSelectedBitmap( getCarVehicleType( marker ) ) );
MarkerOnlineCar onlineCar = ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj();
CallChatApi.getInstance().showUserWindow( mContext, onlineCar );
} catch ( Exception e ) {
marker.setIcon(OnlineCarMarkerView.getInstance().getSelectedBitmap(getCarVehicleType(marker)));
MarkerOnlineCar onlineCar = (MarkerOnlineCar) ((MarkerShowEntity) marker.getObject()).getBindObj();
CallChatApi.getInstance().showUserWindow(mContext, onlineCar);
} catch (Exception e) {
}
}
}
// 折叠气泡
private void closeMarker( IMogoMarker mogoMarker ) {
if ( mogoMarker == null ) {
private void closeMarker(IMogoMarker mogoMarker) {
if (mogoMarker == null) {
return;
}
// 在线车辆点击使用infoWindow
if ( TextUtils.equals( mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
mogoMarker.setIcon( OnlineCarMarkerView.getInstance().getBitmap( getCarVehicleType( mogoMarker ) ) );
if (TextUtils.equals(mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)) {
mogoMarker.setIcon(OnlineCarMarkerView.getInstance().getBitmap(getCarVehicleType(mogoMarker)));
} else {
Object object = mogoMarker.getObject();
if ( object != null ) {
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
markerShowEntity.setChecked( false );
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
markerView.setMarker( mogoMarker );
if ( markerView instanceof OnlineCarMarkerView ) {
if (object != null) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
markerView.setMarker(mogoMarker);
if (markerView instanceof OnlineCarMarkerView) {
try {
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
} catch ( Exception e ) {
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
mogoMarker.setIcon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
} catch (Exception e) {
mogoMarker.setIcon(markerView.getBitmap(0));
}
} else {
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
if (MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
}
}
}
private int getCarVehicleType( IMogoMarker marker ) {
private int getCarVehicleType(IMogoMarker marker) {
try {
return ( ( MarkerOnlineCar )
( ( MarkerShowEntity ) marker.getObject() ).getBindObj() )
return ((MarkerOnlineCar)
((MarkerShowEntity) marker.getObject()).getBindObj())
.getCarInfo()
.getVehicleType();
} catch ( Exception e ) {
} catch (Exception e) {
return 0;
}
}
// 绘制Marker
public synchronized void drawMapMarker( MarkerResponse response ) {
public synchronized void drawMapMarker(MarkerResponse response) {
if ( response == null || response.getResult() == null ) {
if (response == null || response.getResult() == null) {
return;
}
if ( MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ) {
if (MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()) {
return;
}
// 解析不同的Marker类型然后对应的进行绘制
mLastDataResult = response.getResult();
UiThreadHandler.post( () -> {
dispatchDataToBiz();
} );
UiThreadHandler.post(this::dispatchDataToBiz);
drawMarkerByCurrentType( mLastDataResult );
drawMarkerByCurrentType(mLastDataResult);
// 在首页时才埋点
if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
trackData( mLastDataResult );
if (MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume()) {
trackData(mLastDataResult);
}
}
@@ -370,17 +340,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
*
* @param markerCardResult
*/
private synchronized void drawMarkerByCurrentType( MarkerCardResult markerCardResult ) {
private synchronized void drawMarkerByCurrentType(MarkerCardResult markerCardResult) {
if ( markerCardResult == null ) {
if (markerCardResult == null) {
return;
}
if ( MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ) {
if (MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()) {
return;
}
drawAllMarker( markerCardResult );
drawAllMarker(markerCardResult);
}
/**
@@ -388,9 +358,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
*
* @param markerCardResult
*/
private void drawAllMarker( MarkerCardResult markerCardResult ) {
List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay();
RoadConditionDrawer.getInstance().drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL, this );
private void drawAllMarker(MarkerCardResult markerCardResult) {
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
RoadConditionDrawer.getInstance().drawRoadConditionMarker(exploreWayList, ServiceConst.MAX_AMOUNT_ALL, this);
}
/**
@@ -398,51 +368,51 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
*
* @param markerCardResult
*/
private void trackData( MarkerCardResult markerCardResult ) {
if ( markerCardResult == null ) {
private void trackData(MarkerCardResult markerCardResult) {
if (markerCardResult == null) {
return;
}
List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay();
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
JSONArray array = new JSONArray();
int size = 0;
size = exploreWayList == null ? 0 : exploreWayList.size();
final Map< String, Integer > typeCounterMap = new HashMap<>();
for ( int i = 0; i < size; i++ ) {
MarkerExploreWay exploreWay = exploreWayList.get( i );
final Map<String, Integer> typeCounterMap = new HashMap<>();
for (int i = 0; i < size; i++) {
MarkerExploreWay exploreWay = exploreWayList.get(i);
String poiType = exploreWay.getPoiType();
int counter = 0;
if ( !typeCounterMap.containsKey( poiType ) ) {
if (!typeCounterMap.containsKey(poiType)) {
counter = 0;
} else {
counter = typeCounterMap.get( poiType );
counter = typeCounterMap.get(poiType);
}
typeCounterMap.put( poiType, counter + 1 );
typeCounterMap.put(poiType, counter + 1);
}
if ( !typeCounterMap.isEmpty() ) {
for ( Map.Entry< String, Integer > entry : typeCounterMap.entrySet() ) {
if ( entry == null || entry.getKey() == null ) {
if (!typeCounterMap.isEmpty()) {
for (Map.Entry<String, Integer> entry : typeCounterMap.entrySet()) {
if (entry == null || entry.getKey() == null) {
continue;
}
JSONObject object = new JSONObject();
try {
object.put( "type", entry.getKey() );
object.put( "num", entry.getValue() );
array.put( object );
} catch ( JSONException e ) {
object.put("type", entry.getKey());
object.put("num", entry.getValue());
array.put(object);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
try {
if ( array.length() == 0 ) {
if (array.length() == 0) {
return;
}
final Map< String, Object > properties = new HashMap<>();
properties.put( "data", array.toString() );
MarkerServiceHandler.getMogoAnalytics().track( "v2x_data_get", properties );
} catch ( Exception e ) {
final Map<String, Object> properties = new HashMap<>();
properties.put("data", array.toString());
MarkerServiceHandler.getMogoAnalytics().track("v2x_data_get", properties);
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -453,11 +423,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
* 仅在数据刷新的时候分发
*/
private void dispatchDataToBiz() {
if ( mLastDataResult == null ) {
if (mLastDataResult == null) {
return;
}
List< MarkerExploreWay > exploreWayList = mLastDataResult.getExploreWay();
dispatchDataToBis( ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList == null ? new ArrayList<>() : exploreWayList );
List<MarkerExploreWay> exploreWayList = mLastDataResult.getExploreWay();
dispatchDataToBis(ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList == null ? new ArrayList<>() : exploreWayList);
}
/**
@@ -466,13 +436,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
* @param biz
* @param object
*/
private void dispatchDataToBis( String biz, Object object ) {
if ( TextUtils.isEmpty( biz ) ) {
private void dispatchDataToBis(String biz, Object object) {
if (TextUtils.isEmpty(biz)) {
return;
}
try {
MarkerServiceHandler.getDataManager().syncData( biz, object );
} catch ( Exception e ) {
MarkerServiceHandler.getDataManager().syncData(biz, object);
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -483,45 +453,45 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
* @param markerShowEntity marker 绘制数据实体
* @return 绘制的Marker
*/
public synchronized IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity, int zIndex ) {
public synchronized IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity, int zIndex) {
try {
return MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, zIndex, this );
} catch ( Exception e ) {
return MarkerDrawer.getInstance().drawMapMarkerImpl(markerShowEntity, zIndex, this);
} catch (Exception e) {
return null;
}
}
@Override
public Class< MarkerResponse > target() {
public Class<MarkerResponse> target() {
return MarkerResponse.class;
}
@Override
public void onMsgReceived( final MarkerResponse response ) {
if ( ignoreDrawRequest() ) {
public void onMsgReceived(final MarkerResponse response) {
if (ignoreDrawRequest()) {
return;
}
runOnTargetThread( () -> {
drawMapMarker( response );
} );
runOnTargetThread(() -> {
drawMapMarker(response);
});
}
public void onSyncMarkerResponse( MarkerResponse response ) {
if ( ignoreDrawRequest() ) {
public void onSyncMarkerResponse(MarkerResponse response) {
if (ignoreDrawRequest()) {
return;
}
runOnTargetThread( () -> {
drawMapMarker( response );
} );
runOnTargetThread(() -> {
drawMapMarker(response);
});
}
public void syncLocation( double lon, double lat ) {
mCarLatLng = new MogoLatLng( lat, lon );
public void syncLocation(double lon, double lat) {
mCarLatLng = new MogoLatLng(lat, lon);
}
public void getOnlineCarDataByAutoRefreshStrategy( MogoLatLng latlng ) {
UiThreadHandler.removeCallbacks( runnable );
getOnlineCarDataImpl( latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false );
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
UiThreadHandler.removeCallbacks(runnable);
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
}
/**
@@ -531,24 +501,24 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
* @param limit
* @param radius
*/
public void getOnlineCarDataByVoiceControl( MogoLatLng latLng,
boolean onlyFocus,
boolean onlySameCity,
int limit,
int radius ) {
UiThreadHandler.removeCallbacks( runnable );
getOnlineCarDataImpl( latLng, onlyFocus, onlySameCity, limit, radius, true );
public void getOnlineCarDataByVoiceControl(MogoLatLng latLng,
boolean onlyFocus,
boolean onlySameCity,
int limit,
int radius) {
UiThreadHandler.removeCallbacks(runnable);
getOnlineCarDataImpl(latLng, onlyFocus, onlySameCity, limit, radius, true);
}
private Runnable runnable = new Runnable() {
@Override
public void run() {
getOnlineCarDataImpl( mCarLatLng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false );
getOnlineCarDataImpl(mCarLatLng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
}
};
public void stopAutoRefresh() {
UiThreadHandler.removeCallbacks( runnable );
UiThreadHandler.removeCallbacks(runnable);
}
/**
@@ -567,82 +537,82 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
boolean onlySameCity,
int limit,
int radius,
boolean fitBounds ) {
boolean fitBounds) {
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
if (DebugConfig.isNeedUploadCoordinatesDurationInTime()) {
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
return;
}
if ( DebugConfig.isDebug() ) {
if ( !DebugConfig.isRequestOnlineCarData() ) {
if (DebugConfig.isDebug()) {
if (!DebugConfig.isRequestOnlineCarData()) {
return;
}
}
if ( mCarLatLng == null ) {
if (mCarLatLng == null) {
mCarLatLng = latLng;
}
if ( latLng == null ) {
if (latLng == null) {
return;
}
if ( ignoreOnlineCarRequest() ) {
if (ignoreOnlineCarRequest()) {
removeCarMarkers();
return;
}
mRefreshModel.queryOnLineCarWithRoute( latLng, onlyFocus, onlySameCity, radius, limit, false, new RefreshCallback() {
mRefreshModel.queryOnLineCarWithRoute(latLng, onlyFocus, onlySameCity, radius, limit, false, new RefreshCallback() {
@Override
public void onSuccess( Object o ) {
MarkerResponse data = ( MarkerResponse ) o;
public void onSuccess(Object o) {
MarkerResponse data = (MarkerResponse) o;
MarkerCardResult result = data.getResult();
if ( result == null ) {
if (result == null) {
return;
}
List< MarkerOnlineCar > onlineCarList = result.getOnlineCar();
if ( MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ) {
List<MarkerOnlineCar> onlineCarList = result.getOnlineCar();
if (MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()) {
return;
}
final int size = onlineCarList == null ? 0 : onlineCarList.size();
if ( mMarkerDisplayBounds == null ) {
if (mMarkerDisplayBounds == null) {
mMarkerDisplayBounds = new Rect(
ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_leftMargin ),
ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_topMargin ),
ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_rightMargin ),
ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_bottomMargin )
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_leftMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_topMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_rightMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_bottomMargin)
);
}
runOnTargetThread( () -> {
trackData( size );
OnlineCarDrawer.getInstance().drawOnlineCarMarkers( onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this );
UiThreadHandler.postDelayed( runnable, SMOOTH_DURATION * 1000 );
} );
runOnTargetThread(() -> {
trackData(size);
OnlineCarDrawer.getInstance().drawOnlineCarMarkers(onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this);
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
});
}
private void trackData( int size ) {
private void trackData(int size) {
JSONArray array = new JSONArray();
JSONObject object = new JSONObject();
try {
object.put( "type", "10000" );
object.put( "num", size );
array.put( object );
} catch ( JSONException e ) {
object.put("type", "10000");
object.put("num", size);
array.put(object);
} catch (JSONException e) {
e.printStackTrace();
}
if ( array.length() == 0 ) {
if (array.length() == 0) {
return;
}
final Map< String, Object > properties = new HashMap<>();
properties.put( "data", array.toString() );
MarkerServiceHandler.getMogoAnalytics().track( "v2x_data_get", properties );
final Map<String, Object> properties = new HashMap<>();
properties.put("data", array.toString());
MarkerServiceHandler.getMogoAnalytics().track("v2x_data_get", properties);
}
} );
});
}
/**
@@ -655,7 +625,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
private void removeCarMarkers() {
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_USER_DATA);
}
@@ -667,11 +637,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|| MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode();
}
private void runOnTargetThread( Runnable runnable ) {
if ( runnable == null ) {
private void runOnTargetThread(Runnable runnable) {
if (runnable == null) {
return;
}
ThreadPoolService.execute( runnable );
ThreadPoolService.execute(runnable);
}
public String getCurrentModuleName() {
@@ -679,25 +649,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
@Override
public void onBizActionDone( String biz, int position, Object data ) {
if ( data instanceof MarkerShowEntity && ( ( MarkerShowEntity ) data ).getMarker() != null ) {
switchMarkerOpenStatus( ( ( MarkerShowEntity ) data ).getMarker() );
public void onBizActionDone(String biz, int position, Object data) {
if (data instanceof MarkerShowEntity && ((MarkerShowEntity) data).getMarker() != null) {
switchMarkerOpenStatus(((MarkerShowEntity) data).getMarker());
} else {
IMogoMarkerManager markerManager = MarkerServiceHandler.getMarkerManager();
List< IMogoMarker > markers = markerManager.getMarkers( biz );
if ( markers != null ) {
List<IMogoMarker> markers = markerManager.getMarkers(biz);
if (markers != null) {
try {
IMogoMarker marker = markers.get( position );
switchMarkerOpenStatus( marker );
} catch ( Exception e ) {
IMogoMarker marker = markers.get(position);
switchMarkerOpenStatus(marker);
} catch (Exception e) {
}
}
}
}
@Override
public void onMapUiModeChanged( EnumMapUI mapUI ) {
switch ( mapUI ) {
public void onMapUiModeChanged(EnumMapUI mapUI) {
switch (mapUI) {
case Type_Light:
case Type_Night:
// if ( !AppUtils.isAppForeground( mContext ) ) {
@@ -709,18 +679,18 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
public void redrawMarkerByStyleChanged() {
if ( mLastDataResult != null ) {
runOnTargetThread( () -> {
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
drawMarkerByCurrentType( mLastDataResult );
if (mLastDataResult != null) {
runOnTargetThread(() -> {
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_ROAD_CONDITION);
drawMarkerByCurrentType(mLastDataResult);
mLastCheckMarker = null;
} );
});
}
}
public void onCloseCurrentSelectedMarker() {
if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed() ) {
closeMarker( mLastCheckMarker );
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
closeMarker(mLastCheckMarker);
mLastCheckMarker = null;
}
}

View File

@@ -0,0 +1,25 @@
package com.mogo.module.service.spi;
import com.elegant.spi.annotations.Service;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.realtime.api.IRealTimeProvider;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudLocationInfo;
import java.util.List;
@Service(value = IRealTimeProvider.class)
public class SPIRealTimeUpload implements IRealTimeProvider {
@Override
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
//todo 待200ms 数据联调结束后 代码合并 更换类 ---> ADASRecognizedResult
// return MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
return null;
}
@Override
public List<CloudLocationInfo> getLocationMsg() {
return null;
}
}

View File

@@ -5,15 +5,12 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.common.machinevision.IMachineVisionInterface;
import com.mogo.utils.logger.Logger;
public
/**
/*
* @author congtaowang
* @since 2020/10/27
*
@@ -24,7 +21,6 @@ class VrModeController {
private static final String TAG = "VrModeController";
private static volatile VrModeController sInstance;
private volatile IMachineVisionInterface mMachineVisionInterface;
private ServiceConnection mServiceConnection;
private VrModeController() {
@@ -70,22 +66,18 @@ class VrModeController {
AbsMogoApplication.getApp().bindService( intent, mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected( ComponentName name, IBinder service ) {
mMachineVisionInterface = IMachineVisionInterface.Stub.asInterface( service );
}
@Override
public void onServiceDisconnected( ComponentName name ) {
mMachineVisionInterface = null;
}
@Override
public void onBindingDied( ComponentName name ) {
mMachineVisionInterface = null;
}
@Override
public void onNullBinding( ComponentName name ) {
mMachineVisionInterface = null;
}
}, Context.BIND_AUTO_CREATE );
}
@@ -102,34 +94,8 @@ class VrModeController {
}
public void onMainPageResumeStatusChanged( boolean isResume ) {
if ( mMachineVisionInterface != null ) {
if ( isResume ) {
try {
mMachineVisionInterface.showViewIfExist();
} catch ( RemoteException e ) {
Logger.e( TAG, e, "onMainPageResumeStatusChanged" );
}
} else {
try {
mMachineVisionInterface.hideViewIfExist();
} catch ( RemoteException e ) {
Logger.e( TAG, e, "onMainPageResumeStatusChanged" );
}
}
}
}
public void renderMogoSnapshotSetData( MogoSnapshotSetData data ) {
if ( data == null ) {
return;
}
if ( mMachineVisionInterface == null ) {
return;
}
try {
mMachineVisionInterface.postData( data );
} catch ( Exception e ) {
Logger.e( TAG, e, "postData" );
}
}
}