diff --git a/.idea/misc.xml b/.idea/misc.xml index 707ee6e613..2dc54c489f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java index 48317822a8..c373965b87 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java @@ -1,10 +1,8 @@ package com.mogo.map.impl.amap.marker; -import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.view.View; -import android.view.animation.BounceInterpolator; import android.view.animation.Interpolator; import com.amap.api.maps.model.BitmapDescriptor; @@ -442,36 +440,31 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer { 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 ) ) ); - } - 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(); + if ( mMarker == null ) { + return; } + + if ( points == null || points.isEmpty() ) { + return; + } + + List< LatLng > newPoints = new ArrayList<>(); + for ( int i = 0; i < points.size(); i++ ) { + LatLng point = ObjectUtils.fromMogo2( points.get( i ) ); + if ( point == null ) { + continue; + } + newPoints.add( point ); + } + if ( newPoints.isEmpty() ) { + return; + } + if ( mMovingPointOverlay == null ) { + mMovingPointOverlay = new MovingPointOverlay( AMapWrapper.getAMap(), mMarker ); + } + mMovingPointOverlay.setPoints( newPoints ); + mMovingPointOverlay.setTotalDuration( duration ); + mMovingPointOverlay.startSmoothMove(); } }