优化显示逻辑

This commit is contained in:
wangcongtao
2021-03-17 14:03:34 +08:00
parent 610e7d56cf
commit 16145c5586
8 changed files with 173 additions and 93 deletions

View File

@@ -557,10 +557,12 @@ public class MockIntentHandler implements IntentHandler {
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 4000L );
// mLocationMockHandler1.sendEmptyMessageDelayed( 1, 4000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
mTimeTickHandler.sendEmptyMessageDelayed( 1, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 31, 2000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
break;
@@ -569,16 +571,16 @@ public class MockIntentHandler implements IntentHandler {
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.position( new MogoLatLng( 39.981971055705,116.41150648393 ) )
.position( new MogoLatLng( 39.981971055705, 116.41150648393 ) )
.gps( true )
.controlAngle( true )
.icon3DRes( R.raw.othercar )
.rotate( ( float ) 358.526123 );
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
List<MogoLatLng> latLngs = new ArrayList<>( );
latLngs.add( new MogoLatLng( 39.981971055705,116.41150648393 ) );
latLngs.add( new MogoLatLng( 39.981990561932,116.412893641626 ) );
marker.startSmoothInMs(latLngs, 20_000L );
List< MogoLatLng > latLngs = new ArrayList<>();
latLngs.add( new MogoLatLng( 39.981971055705, 116.41150648393 ) );
latLngs.add( new MogoLatLng( 39.981990561932, 116.412893641626 ) );
marker.startSmoothInMs( latLngs, 20_000L );
break;
case 49:
// 39.96741320378243, 116.41045709250723
@@ -590,27 +592,27 @@ public class MockIntentHandler implements IntentHandler {
.position( new MogoLatLng( 39.96741320378243, 116.41045709250723 ) )
.gps( true )
.controlAngle( false )
.icon(BitmapFactory.decodeResource( context.getResources(), R.drawable.sy ) )
.icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.sy ) )
.rotate( ( float ) 358.526123 );
IMogoMarker marker1 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options1 );
MogoMarkerOptions options2 = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( false )
.position( new MogoLatLng( 39.98232698552779,116.41879656379113 ) )
.position( new MogoLatLng( 39.98232698552779, 116.41879656379113 ) )
.gps( true )
.controlAngle( false )
.icon(BitmapFactory.decodeResource( context.getResources(), R.drawable.sr ) )
.icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.sr ) )
.rotate( ( float ) 358.526123 );
IMogoMarker marker2 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options2 );
MogoMarkerOptions options3 = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( false )
.position( new MogoLatLng( 39.97631642243,116.418249382739 ) )
.position( new MogoLatLng( 39.97631642243, 116.418249382739 ) )
.gps( true )
.controlAngle( false )
.icon(BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) )
.icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) )
.rotate( ( float ) 358.526123 );
IMogoMarker marker3 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options3 );
break;
@@ -627,7 +629,7 @@ public class MockIntentHandler implements IntentHandler {
private BufferedReader roadSizeBr;
private JSONObject locJo = null;
private void handleMockSingleLocDataIntent() throws Exception{
private void handleMockSingleLocDataIntent() throws Exception {
if ( locJo == null ) {
String locLine = "{\"systemTime\":1615529718585,\"satelliteTime\":1615529718585,\"lon\":116.73573385415098,\"lat\":40.19907712731953,\"alt\":34.4018669128417,\"heading\":0.342695406938048,\"speed\":0.003303937}";
locJo = new JSONObject( locLine );
@@ -638,13 +640,13 @@ public class MockIntentHandler implements IntentHandler {
mLocationMockHandler.sendEmptyMessageDelayed( 100, 50L );
}
private void handleRoadSideMockDataIntent() throws Exception{
private void handleRoadSideMockDataIntent() throws Exception {
if ( roadSizeBr == null ) {
roadSizeBr = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "roadSide.txt" ) ) );
}
String carsLine = roadSizeBr.readLine();
MogoSnapshotSetData data = new MogoSnapshotSetData();
List<CloudRoadData> allList = GsonUtil.arrayFromJson( carsLine, CloudRoadData.class );
List< CloudRoadData > allList = GsonUtil.arrayFromJson( carsLine, CloudRoadData.class );
for ( CloudRoadData cloudRoadData : allList ) {
cloudRoadData.setWgslat( cloudRoadData.getLat() );
cloudRoadData.setWgslon( cloudRoadData.getLon() );
@@ -734,7 +736,7 @@ public class MockIntentHandler implements IntentHandler {
br33 = null;
br34 = null;
}
} else if( msg.what == 31 ){
} else if ( msg.what == 31 ) {
try {
handleMockAdasIntent3();
} catch ( Exception e ) {
@@ -745,7 +747,7 @@ public class MockIntentHandler implements IntentHandler {
}
br31 = null;
}
}else if ( msg.what == 48 ) {
} else if ( msg.what == 48 ) {
try {
handleMockLocationIntent48();
} catch ( Exception e ) {
@@ -756,13 +758,13 @@ public class MockIntentHandler implements IntentHandler {
}
br48 = null;
}
}else if ( msg.what == 100 ) {
} else if ( msg.what == 100 ) {
try {
handleMockSingleLocDataIntent();
} catch ( Exception e ) {
e.printStackTrace();
}
}else if ( msg.what == 101 ) {
} else if ( msg.what == 101 ) {
try {
handleRoadSideMockDataIntent();
} catch ( Exception e ) {
@@ -776,6 +778,42 @@ public class MockIntentHandler implements IntentHandler {
}
}
};
private Handler mLocationMockHandler1 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread1" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 1 ) {
try {
if ( !handleMockLocationIntent() ) {
br.close();
br = null;
}
} catch ( Exception e ) {
try {
br.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br = null;
}
}
}
};
private long mLocDelay = 0;
private Handler mTimeTickHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread2" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
mLocDelay += 50;
if ( mLocDelay > 4_000L ) {
mLocationMockHandler1.sendEmptyMessageDelayed( 1, 0L );
}
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
mTimeTickHandler.sendEmptyMessageDelayed( 0, 50L );
}
};
private BufferedReader br;
@@ -795,7 +833,6 @@ public class MockIntentHandler implements IntentHandler {
Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
SnapshotLocationController.getInstance().syncAdasLocationInfo( jo );
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 50L );
return true;
}
@@ -813,7 +850,7 @@ public class MockIntentHandler implements IntentHandler {
}
JSONObject jo = new JSONObject( line );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Logger.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms: count=%s", ++count );
Logger.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms: count=%s", ++count );
mLocationMockHandler.sendEmptyMessageDelayed( 48, 100L );
return true;
}
@@ -845,7 +882,7 @@ public class MockIntentHandler implements IntentHandler {
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if (last != 0){
if ( last != 0 ) {
delay = cloudRoadData.getSystemTime() - last;
}
last = cloudRoadData.getSystemTime();
@@ -884,6 +921,7 @@ public class MockIntentHandler implements IntentHandler {
private BufferedReader br31;
private boolean handleMockAdasIntent() throws Exception {
final long start = System.currentTimeMillis();
if ( br3 == null ) {
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas2.txt" ) ) );
}
@@ -910,33 +948,31 @@ public class MockIntentHandler implements IntentHandler {
}
allList.add( adasRecognizedResult );
ADASRecognizedResult next = handleMockAdasIntent3();
if(next != null){
allList.add(next);
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent4();
if(next != null){
allList.add(next);
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent5();
if(next != null){
allList.add(next);
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent6();
if(next != null){
allList.add(next);
if ( next != null ) {
allList.add( next );
}
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if (last != 0){
if ( last != 0 ) {
delay = adasRecognizedResult.satelliteTime - last;
}
last = adasRecognizedResult.satelliteTime;
Log.d("send-delay", "delay: " + delay);
mLocationMockHandler.sendEmptyMessageDelayed( 3, 50L );
Log.d( "send-delay", "delay: " + delay );
return true;
}
@@ -959,6 +995,7 @@ public class MockIntentHandler implements IntentHandler {
}
private BufferedReader br32;
private ADASRecognizedResult handleMockAdasIntent4() {
String line = null;
try {
@@ -978,6 +1015,7 @@ public class MockIntentHandler implements IntentHandler {
}
private BufferedReader br33;
private ADASRecognizedResult handleMockAdasIntent5() {
String line = null;
try {
@@ -997,6 +1035,7 @@ public class MockIntentHandler implements IntentHandler {
}
private BufferedReader br34;
private ADASRecognizedResult handleMockAdasIntent6() {
String line = null;
try {