Merge branch 'feature/v1.0.4-opt-moving-marker' into feature/v1.0.5

This commit is contained in:
wangcongtao
2020-04-30 10:16:19 +08:00

View File

@@ -86,8 +86,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
mMarker.setObject( null );
mMarker = null;
}
if (mMovingPointOverlay != null){
if ( mMovingPointOverlay != null ) {
try {
mMovingPointOverlay.stopMove();
mMovingPointOverlay.destroy();
} catch ( Exception e ) {
e.printStackTrace();
@@ -435,27 +436,40 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
}
@Override
public void startSmooth(List<MogoLatLng> points,int duration) {
public void startSmooth( List< MogoLatLng > points, int duration ) {
if ( isDestroyed() ) {
return;
}
if (mMarker != null && points.size() > 0){
List<LatLng> p = new ArrayList<>();
for (int i = 0; i < points.size(); i++) {
p.add(ObjectUtils.fromMogo2(points.get(i)));
if ( mMarker != null && points.size() > 0 ) {
List< LatLng > p = new ArrayList<>();
for ( int i = 0; i < points.size(); i++ ) {
p.add( ObjectUtils.fromMogo2( points.get( i ) ) );
}
mMovingPointOverlay = new MovingPointOverlay(AMapWrapper.getAMap(),mMarker);
mMovingPointOverlay.setPoints(p);
mMovingPointOverlay.setTotalDuration(duration);
mMovingPointOverlay.setVisible(true);
mMovingPointOverlay.setMoveListener(new MovingPointOverlay.MoveListener() {
@Override
public void move(double v) {
mMovingPointOverlay = new MovingPointOverlay( AMapWrapper.getAMap(), mMarker );
mMovingPointOverlay.setPoints( p );
mMovingPointOverlay.setTotalDuration( duration );
mMovingPointOverlay.setMoveListener( v -> {
try {
LatLng position = mMovingPointOverlay.getPosition();
Point point = AMapWrapper.getAMap().getProjection().toScreenLocation( position );
if ( point.x < 0 || point.x > WindowUtils.getScreenWidth( AbsMogoApplication.getApp() )
|| point.y < 0 || point.y > WindowUtils.getScreenHeight( AbsMogoApplication.getApp() ) ) {
if ( mMarker.isVisible() ) {
mMovingPointOverlay.setVisible( false );
Logger.d( TAG, "hide moving marker" );
}
} else {
if ( !mMarker.isVisible() ) {
mMovingPointOverlay.setVisible( true );
Logger.d( TAG, "show moving marker" );
}
}
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
});
} );
mMovingPointOverlay.startSmoothMove();
}
}