优化显示逻辑
This commit is contained in:
@@ -5,6 +5,7 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -17,6 +18,7 @@ import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -60,9 +62,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if ( msg.obj instanceof MovingPoint ) {
|
||||
moveMarker( ( ( MovingPoint ) msg.obj ) );
|
||||
}
|
||||
} else if( msg.what == MSG_SET_SPEED ){
|
||||
} else if ( msg.what == MSG_SET_SPEED ) {
|
||||
if ( msg.obj instanceof SpeedData ) {
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +82,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
msg.obj = points.get( i );
|
||||
mPointSettingHandler.sendMessageDelayed( msg, ( i + 1 ) * 20 );
|
||||
mPointSettingHandler.sendMessageDelayed( msg, points.get( i ).delay );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
pointData.move();
|
||||
}
|
||||
|
||||
private void showSpeed(SpeedData data){
|
||||
private void showSpeed( SpeedData data ) {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +128,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
|
||||
// adas marker 缓存
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new HashMap<>();
|
||||
|
||||
public boolean hasCached( String uniqueKey ) {
|
||||
return mAdasRecognizedMarkersCaches.containsKey( uniqueKey );
|
||||
@@ -143,7 +145,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new HashMap<>();
|
||||
for ( ADASRecognizedResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
@@ -158,6 +160,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
*
|
||||
* @param recognizedListResult
|
||||
* @param newAdasRecognizedMarkersCaches
|
||||
*/
|
||||
@@ -172,6 +175,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.lon,
|
||||
recognizedListResult.lat,
|
||||
recognizedListResult.heading,
|
||||
@@ -212,17 +217,22 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if ( lastPosition != null ) {
|
||||
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
|
||||
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
interval -= cost;
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.lat, lastPosition.lon );
|
||||
lastPoint.setTime( lastPosition.satelliteTime );
|
||||
endLatLon.setTime( recognizedListResult.satelliteTime );
|
||||
MovingPoint endPoint = new MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.delay = interval;
|
||||
endPoint.angle = ( float ) recognizedListResult.heading;
|
||||
|
||||
MovingPoint startPoint = new MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.delay = 0L;
|
||||
startPoint.angle = ( float ) lastPosition.heading;
|
||||
List< MovingPoint > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
Message msg = new Message();
|
||||
|
||||
@@ -206,7 +206,7 @@ class BaseDrawer {
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( lon, lat, angle, true, isRtk );
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
Log.i( "timer-matchRoad", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ class BaseDrawer {
|
||||
if ( interval < 45 ) {
|
||||
interval = 45;
|
||||
}
|
||||
return interval - 20;
|
||||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +256,7 @@ class BaseDrawer {
|
||||
double lat = start.point.lat + latStep * ( i + 1 );
|
||||
MovingPoint pd = new MovingPoint();
|
||||
pd.point = new MogoLatLng( lat, lon );
|
||||
pd.delay = ( i + 1 ) * frameInterval;
|
||||
pd.angle = ( float ) _angle;
|
||||
pd.marker = start.marker;
|
||||
arrayList.add( pd );
|
||||
@@ -273,6 +274,7 @@ class BaseDrawer {
|
||||
public MogoLatLng point;
|
||||
public float angle;
|
||||
public IMogoMarker marker;
|
||||
public long delay;
|
||||
|
||||
public void move() {
|
||||
try {
|
||||
|
||||
@@ -60,14 +60,18 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl(markerShowEntity, zIndex, 0, listener);
|
||||
return drawMapMarkerImpl( markerShowEntity, false, zIndex, 0, listener );
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl( markerShowEntity, matchRoadSide, zIndex, 0, listener );
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).matchOnRoadSide( matchRoadSide ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
|
||||
@@ -105,7 +105,7 @@ class OnlineCarDrawer {
|
||||
String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
|
||||
@@ -86,14 +86,14 @@ class RoadConditionDrawer {
|
||||
Logger.d( TAG, "draw road condition, sn = %s", sn );
|
||||
try {
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, true, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
|
||||
mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
|
||||
} else {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
|
||||
Reference in New Issue
Block a user