代码优化
This commit is contained in:
@@ -29,9 +29,11 @@ import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
@@ -551,11 +553,12 @@ public class MockIntentHandler implements IntentHandler {
|
||||
break;
|
||||
case 46:
|
||||
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ), false );
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
|
||||
break;
|
||||
case 47:
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,6 +612,17 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
br2 = null;
|
||||
}
|
||||
} else if ( msg.what == 3 ) {
|
||||
try {
|
||||
handleMockAdasIntent();
|
||||
} catch ( Exception e ) {
|
||||
try {
|
||||
br3.close();
|
||||
} catch ( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
br3 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -624,7 +638,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
throw new Exception( "end of file." );
|
||||
}
|
||||
JSONObject jo = new JSONObject( line );
|
||||
final long start = System.currentTimeMillis();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
|
||||
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
return true;
|
||||
}
|
||||
@@ -655,10 +671,39 @@ public class MockIntentHandler implements IntentHandler {
|
||||
data.setAllList( allList );
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
|
||||
Log.i("mock-snapshot-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
|
||||
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
private BufferedReader br3;
|
||||
|
||||
private boolean handleMockAdasIntent() throws Exception {
|
||||
if ( br3 == null ) {
|
||||
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas.txt" ) ) );
|
||||
}
|
||||
String line = br3.readLine();
|
||||
if ( line == null ) {
|
||||
throw new Exception( "end of file 3." );
|
||||
}
|
||||
List< ADASRecognizedResult > allList = new ArrayList<>();
|
||||
if ( ++count % 300 != 0 ) {
|
||||
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
|
||||
if ( adasRecognizedResult == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
|
||||
adasRecognizedResult.lon = coor[0];
|
||||
adasRecognizedResult.lat = coor[1];
|
||||
allList.add( adasRecognizedResult );
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
|
||||
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
});
|
||||
}
|
||||
// 每隔一秒下发的数据
|
||||
// 下发的数据
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
@@ -143,17 +143,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
}
|
||||
});
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
double speed = 0.0;
|
||||
if (MogoServices.getInstance().getLastCarLocation() != null) {
|
||||
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
|
||||
// 绘制近景识别到的车辆
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,6 +248,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据点击 marker 更新用户信息面板内容
|
||||
* @param marker
|
||||
*/
|
||||
private void updateCarUserInfoWindow(IMogoMarker marker) {
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
try {
|
||||
@@ -299,6 +299,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特殊车辆类型
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
private int getCarVehicleType(IMogoMarker marker) {
|
||||
try {
|
||||
return ((MarkerOnlineCar)
|
||||
@@ -475,6 +480,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步绘制大而全的数据 marker
|
||||
* @param response
|
||||
*/
|
||||
public void onSyncMarkerResponse(MarkerResponse response) {
|
||||
if (ignoreDrawRequest()) {
|
||||
return;
|
||||
@@ -484,10 +493,19 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前地图中心点坐标
|
||||
* @param lon
|
||||
* @param lat
|
||||
*/
|
||||
public void syncLocation(double lon, double lat) {
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度请求数据
|
||||
* @param latlng
|
||||
*/
|
||||
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
@@ -516,6 +534,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 移除绘制
|
||||
*/
|
||||
public void stopAutoRefresh() {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
}
|
||||
@@ -622,11 +643,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
return ignoreDrawRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除在线车辆 marker
|
||||
*/
|
||||
private void removeCarMarkers() {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_USER_DATA);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以下条件,不绘制 marker
|
||||
* @return
|
||||
*/
|
||||
private boolean ignoreDrawRequest() {
|
||||
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()
|
||||
|| MarkerServiceHandler.getMogoStatusManager().isV2XShow()
|
||||
@@ -668,14 +695,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
switch (mapUI) {
|
||||
case Type_Light:
|
||||
case Type_Night:
|
||||
// if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
// return;
|
||||
// }
|
||||
redrawMarkerByStyleChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重绘内容
|
||||
*/
|
||||
public void redrawMarkerByStyleChanged() {
|
||||
if (mLastDataResult != null) {
|
||||
runOnTargetThread(() -> {
|
||||
@@ -686,6 +713,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭当前点击过的 marker
|
||||
*/
|
||||
public void onCloseCurrentSelectedMarker() {
|
||||
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
|
||||
closeMarker(mLastCheckMarker);
|
||||
|
||||
Reference in New Issue
Block a user