diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index bc39f455c6..65d62c8ff2 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -7,6 +7,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.os.Bundle; import android.os.SystemClock; +import android.os.Trace; import android.view.MotionEvent; import android.view.View; import android.view.animation.Interpolator; @@ -319,7 +320,9 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onLockMap( boolean isLock ) { Logger.d( TAG, "lock status = %s", isLock ); + Trace.beginSection( "timer.onCameraChangeFinish" ); MogoMapListenerHandler.getInstance().onLockMap( isLock ); + Trace.endSection(); } @Override @@ -418,7 +421,6 @@ public class AMapNaviViewWrapper implements IMogoMapView, } - private boolean checkAMapView() { if ( mMapView == null ) { Logger.e( TAG, "高德mapView实例为空,请检查" ); @@ -549,17 +551,19 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onCameraChangeFinish( CameraPosition cameraPosition ) { if ( cameraPosition != null ) { - MogoMapListenerHandler.getInstance() - .onMapChanged( ObjectUtils.fromAMap( cameraPosition.target ), cameraPosition.zoom, - cameraPosition.tilt, cameraPosition.bearing ); + Trace.beginSection( "timer.onCameraChangeFinish" ); + MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.target ), + cameraPosition.zoom, + cameraPosition.tilt, + cameraPosition.bearing ); + Trace.endSection(); } } @Override public MogoLatLng getCameraNorthEastPosition() { try { - return ObjectUtils.fromAMap( - mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast ); + return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast ); } catch ( Exception e ) { } @@ -569,8 +573,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public MogoLatLng getCameraSouthWestPosition() { try { - return ObjectUtils.fromAMap( - mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest ); + return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest ); } catch ( Exception e ) { } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java index 9b73bf10ab..6372fcd37f 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java @@ -6,16 +6,21 @@ import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; +import com.amap.api.maps.model.Polyline; +import com.amap.api.maps.model.PolylineOptions; import com.amap.api.navi.AMapNaviView; import com.mogo.map.IMogoMap; import com.mogo.map.IMogoUiSettings; import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter; import com.mogo.map.impl.amap.marker.AMapMarkerWrapper; +import com.mogo.map.impl.amap.overlay.AMapPolylineWrapper; import com.mogo.map.impl.amap.uicontroller.AMapUIController; import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; import com.mogo.map.marker.MogoMarkersHandler; +import com.mogo.map.overlay.IMogoPolyline; +import com.mogo.map.overlay.MogoPolylineOptions; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.utils.logger.Logger; @@ -219,6 +224,19 @@ public class AMapWrapper implements IMogoMap { return 0; } + @Override + public IMogoPolyline addPolyline( MogoPolylineOptions options ) { + if ( checkAMap() ) { + PolylineOptions polylineOptions = ObjectUtils.fromMogo( options ); + if ( polylineOptions == null ) { + return null; + } + Polyline polyline = mAMap.addPolyline( polylineOptions ); + return new AMapPolylineWrapper( polyline, options ); + } + return null; + } + private boolean checkAMap() { if ( mAMap == null ) { Logger.e( TAG, "高德map实例为空,请检查" ); diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java index 8dc2020411..a551c302bc 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java @@ -1,6 +1,7 @@ package com.mogo.map.impl.amap.location; import android.content.Context; +import android.os.Trace; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; @@ -139,6 +140,7 @@ public class ALocationClient implements IMogoLocationClient { aMapLocation.getLongitude() == 0.0D ) { return; } + Trace.beginSection("timer.onLocationChanged"); mLastLocation = ObjectUtils.fromAMap( aMapLocation ); synchronized ( sListeners ) { Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator(); @@ -146,6 +148,7 @@ public class ALocationClient implements IMogoLocationClient { listenerIterator.next().onLocationChanged( mLastLocation.clone() ); } } + Trace.endSection(); } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java index 92cd15011f..81259970c1 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java @@ -2,6 +2,7 @@ package com.mogo.map.impl.amap.navi; import android.content.Context; import android.graphics.Rect; +import android.os.Trace; import com.amap.api.maps.model.Polyline; import com.amap.api.navi.AMapNavi; @@ -178,8 +179,10 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter { @Override public void onNaviInfoUpdate( NaviInfo naviInfo ) { + Trace.beginSection( "NaviListenerAdapter.onNaviInfoUpdate" ); MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( ObjectUtils.fromAMap( mContext, naviInfo ) ); mNaviOverlayHelper.handleNaviInfoUpdate( naviInfo ); + Trace.endSection(); } @Override @@ -201,8 +204,10 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter { @Override public void onLocationChange( AMapNaviLocation aMapNaviLocation ) { + Trace.beginSection( "NaviListenerAdapter.onLocationChange" ); super.onLocationChange( aMapNaviLocation ); mNaviOverlayHelper.handlePassedLocation( aMapNaviLocation ); + Trace.endSection(); } public void stopNavi() { diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapPolylineWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapPolylineWrapper.java new file mode 100644 index 0000000000..0c2766d842 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapPolylineWrapper.java @@ -0,0 +1,196 @@ +package com.mogo.map.impl.amap.overlay; + +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.Polyline; +import com.amap.api.maps.model.PolylineOptions; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.overlay.IMogoPolyline; +import com.mogo.map.overlay.MogoPolylineOptions; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2020-03-10 + *
+ * 描述 + */ +public class AMapPolylineWrapper implements IMogoPolyline { + + private Polyline mPolyline; + private MogoPolylineOptions mOptions; + private boolean mIsDestroyed = false; + + public AMapPolylineWrapper( Polyline mPolyline, + MogoPolylineOptions mOptions ) { + this.mPolyline = mPolyline; + this.mOptions = mOptions; + } + + @Override + public void destroy() { + remove(); + } + + @Override + public void remove() { + if ( mPolyline != null ) { + mPolyline.remove(); + } + mIsDestroyed = true; + } + + @Override + public String getId() { + if ( mPolyline != null ) { + return mPolyline.getId(); + } + return null; + } + + @Override + public void setPoints( List< MogoLatLng > lonLats ) { + if ( lonLats == null || lonLats.isEmpty() ) { + mPolyline.setPoints( new ArrayList< LatLng >() ); + return; + } + ArrayList< LatLng > points = new ArrayList<>(); + for ( MogoLatLng lonLat : lonLats ) { + LatLng latLng = ObjectUtils.fromMogo2( lonLat ); + if ( latLng == null ) { + continue; + } + points.add( latLng ); + } + mPolyline.setPoints( points ); + } + + @Override + public List< MogoLatLng > getPoints() { + if ( mPolyline == null ) { + return null; + } + ArrayList< MogoLatLng > lonLats = new ArrayList<>(); + List< LatLng > points = mPolyline.getPoints(); + if ( points != null ) { + for ( LatLng latLng : points ) { + MogoLatLng lonLat = ObjectUtils.fromAMap( latLng ); + if ( lonLat == null ) { + continue; + } + lonLats.add( lonLat ); + } + } + return lonLats; + } + + @Override + public void setGeodesic( boolean draw ) { + if ( mPolyline != null ) { + mPolyline.setGeodesic( draw ); + } + } + + @Override + public boolean isGeodesic() { + return mPolyline == null ? false : mPolyline.isGeodesic(); + } + + @Override + public void setDottedLine( boolean dottedLine ) { + if ( mPolyline != null ) { + mPolyline.setDottedLine( dottedLine ); + } + } + + @Override + public boolean isDottedLine() { + return mPolyline == null ? false : mPolyline.isDottedLine(); + } + + @Override + public void setWidth( float width ) { + if ( mPolyline != null ) { + mPolyline.setWidth( width ); + } + } + + @Override + public float getWidth() { + if ( mPolyline != null ) { + return mPolyline.getWidth(); + } + return 0; + } + + @Override + public void setColor( int color ) { + if ( mPolyline != null ) { + mPolyline.setColor( color ); + } + } + + @Override + public int getColor() { + if ( mPolyline != null ) { + return mPolyline.getColor(); + } + return 0; + } + + @Override + public void setZIndex( float zIndex ) { + if ( mPolyline != null ) { + mPolyline.setZIndex( zIndex ); + } + } + + @Override + public float getZIndex() { + if ( mPolyline != null ) { + return mPolyline.getZIndex(); + } + return 0; + } + + @Override + public void setVisible( boolean visible ) { + if ( mPolyline != null ) { + mPolyline.setVisible( visible ); + } + } + + @Override + public boolean isVisible() { + if ( mPolyline != null ) { + return mPolyline.isVisible(); + } + return false; + } + + @Override + public void setTransparency( float transparency ) { + if ( mPolyline != null ) { + mPolyline.setTransparency( transparency ); + } + } + + @Override + public void setOption( MogoPolylineOptions option ) { + PolylineOptions target = ObjectUtils.fromMogo( option ); + if ( target == null ) { + return; + } + mOptions = option; + if ( mPolyline != null ) { + mPolyline.setOptions( target ); + } + } + + @Override + public boolean isDestroyed() { + return false; + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java index 415974d956..e2f3c11892 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java @@ -10,6 +10,7 @@ import com.amap.api.maps.model.BitmapDescriptorFactory; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.Poi; +import com.amap.api.maps.model.PolylineOptions; import com.amap.api.navi.model.AMapCongestionLink; import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; import com.amap.api.navi.model.AimLessModeCongestionInfo; @@ -46,6 +47,7 @@ import com.mogo.map.navi.MogoCongestionLink; import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.navi.MogoNaviListenerHandler; import com.mogo.map.navi.MogoTraffic; +import com.mogo.map.overlay.MogoPolylineOptions; import com.mogo.map.search.geo.MogoAoiItem; import com.mogo.map.search.geo.MogoBusinessArea; import com.mogo.map.search.geo.MogoCrossroad; @@ -704,4 +706,31 @@ public class ObjectUtils { } return null; } + + public static PolylineOptions fromMogo( MogoPolylineOptions options ) { + if ( options == null ) { + return null; + } + PolylineOptions target = new PolylineOptions(); + if ( options.getPoints() != null ) { + List< LatLng > points = new ArrayList<>(); + for ( MogoLatLng point : options.getPoints() ) { + points.add( fromMogo2( point ) ); + } + target.addAll( points ); + } + target.width( options.getWidth() ); + target.color( options.getColor() ); + target.zIndex( options.getWidth() ); + target.visible( options.isVisible() ); + target.geodesic( options.isGeodesic() ); + target.setDottedLine( options.isDottedLine() ); + target.useGradient( options.isGradient() ); + target.transparency( options.getTransparency() ); + target.aboveMaskLayer( options.isAboveMaskLayer() ); + target.lineCapType( PolylineOptions.LineCapType.LineCapRound ); + target.lineJoinType( PolylineOptions.LineJoinType.LineJoinRound ); + target.setDottedLineType( PolylineOptions.DOTTEDLINE_TYPE_CIRCLE ); + return target; + } } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java index f306f0f4cb..1c648028dd 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java @@ -2,6 +2,8 @@ package com.mogo.map; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.overlay.IMogoPolyline; +import com.mogo.map.overlay.MogoPolylineOptions; import com.mogo.map.uicontroller.IMogoMapUIController; import java.util.ArrayList; @@ -127,4 +129,12 @@ public interface IMogoMap { * @return */ float getZoomLevel(); + + /** + * 添加线段 + * + * @param options + * @return + */ + IMogoPolyline addPolyline( MogoPolylineOptions options ); } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java index 5c90b7de00..186e614ee8 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java @@ -54,63 +54,49 @@ public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListene @Override public void onMapLoaded() { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onMapLoaded(); - } + mDelegateListener.onMapLoaded(); } } @Override public void onTouch( MotionEvent motionEvent ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onTouch( motionEvent ); - } + mDelegateListener.onTouch( motionEvent ); } } @Override public void onPOIClick( MogoPoi poi ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onPOIClick( poi ); - } + mDelegateListener.onPOIClick( poi ); } } @Override public void onMapClick( MogoLatLng latLng ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onMapClick( latLng ); - } + mDelegateListener.onMapClick( latLng ); } } @Override public void onLockMap( boolean isLock ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onLockMap( isLock ); - } + mDelegateListener.onLockMap( isLock ); } } @Override public void onMapModeChanged( EnumMapUI ui ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onMapModeChanged( ui ); - } + mDelegateListener.onMapModeChanged( ui ); } } @Override public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) { if ( mDelegateListener != null ) { - synchronized ( mDelegateListener ) { - mDelegateListener.onMapChanged( location, zoom, tilt, bearing ); - } + mDelegateListener.onMapChanged( location, zoom, tilt, bearing ); } } } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoOverlayManager.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoOverlayManager.java new file mode 100644 index 0000000000..f429797e1a --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoOverlayManager.java @@ -0,0 +1,18 @@ +package com.mogo.map.overlay; + +/** + * @author congtaowang + * @since 2020-03-10 + *
+ * 覆盖物 + */ +public interface IMogoOverlayManager { + + /** + * 绘制线段 + * + * @param options + * @return + */ + IMogoPolyline addPolyline( MogoPolylineOptions options ); +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoPolyline.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoPolyline.java new file mode 100644 index 0000000000..f20e545720 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/IMogoPolyline.java @@ -0,0 +1,144 @@ +package com.mogo.map.overlay; + +import androidx.annotation.ColorInt; + +import com.mogo.map.IDestroyable; +import com.mogo.map.MogoLatLng; + +import java.util.List; + +/** + * @author congtaowang + * @since 2020-03-10 + *
+ * 线段 + */ +public interface IMogoPolyline extends IDestroyable { + + + /** + * 是否已经销毁 + * + * @return + */ + boolean isDestroyed(); + + /** + * 移除 + */ + void remove(); + + /** + * 获取ID + * + * @return + */ + String getId(); + + /** + * 设置绘制点数据 + * + * @param lonLats + */ + void setPoints( List< MogoLatLng > lonLats ); + + /** + * 获取点 + * + * @return + */ + List< MogoLatLng > getPoints(); + + /** + * 测地线 + * + * @param draw + */ + void setGeodesic( boolean draw ); + + /** + * 是否设置了测地线 + * + * @return + */ + boolean isGeodesic(); + + /** + * 虚线 + * + * @param dottedLine + */ + void setDottedLine( boolean dottedLine ); + + /** + * 是否是虚线 + * + * @return + */ + boolean isDottedLine(); + + /** + * 设置线宽 + * + * @param width + */ + void setWidth( float width ); + + /** + * 获取线宽 + * + * @return + */ + float getWidth(); + + /** + * 设置线条颜色 + * + * @param color + */ + void setColor( @ColorInt int color ); + + /** + * 获取线条颜色 + * + * @return + */ + @ColorInt + int getColor(); + + /** + * 设置Z轴 + */ + void setZIndex( float zIndex ); + + /** + * 获取Z轴 + * + * @return + */ + float getZIndex(); + + /** + * 设置显示/隐藏 + */ + void setVisible( boolean visible ); + + /** + * 是否可见 + * + * @return + */ + boolean isVisible(); + + /** + * 设置透明度 + * + * @param transparency + */ + void setTransparency( float transparency ); + + /** + * 设置配置项 + */ + void setOption( MogoPolylineOptions option ); +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/MogoPolylineOptions.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/MogoPolylineOptions.java new file mode 100644 index 0000000000..a9cd740f09 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/overlay/MogoPolylineOptions.java @@ -0,0 +1,214 @@ +package com.mogo.map.overlay; + +import android.graphics.Color; + +import androidx.annotation.ColorInt; + +import com.mogo.map.MogoLatLng; +import com.mogo.map.location.MogoLocation; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author congtaowang + * @since 2020-03-10 + *
+ * 线段属性 + */ +public class MogoPolylineOptions { + + private List< MogoLatLng > mPoints; + private float mWidth = 10.0F; + private int mColor = Color.BLACK; + private float mZIndex = 0.0F; + private boolean mIsVisible = true; + private boolean mIsGeodesic = false; + private boolean mIsDottedLine = false; + private boolean mIsGradient = false; + private float mTransparency = 1.0F; + private boolean mIsAboveMaskLayer = false; + private boolean mIsPointsUpdated = false; + + public MogoPolylineOptions() { + this.mPoints = new ArrayList<>(); + } + + /** + * 设置顶点 + * + * @param points + * @return + */ + public MogoPolylineOptions points( List< MogoLatLng > points ) { + this.mPoints.clear(); + this.mPoints.addAll( points ); + this.mIsPointsUpdated = true; + return this; + } + + /** + * 添加顶点到集合最后 + * + * @param points + * @return + */ + public MogoPolylineOptions add( MogoLatLng... points ) { + if ( points != null ) { + this.mPoints.addAll( Arrays.asList( points ) ); + this.mIsPointsUpdated = true; + } + return this; + } + + public MogoPolylineOptions add( double lon, double lat ) { + this.mPoints.add( new MogoLatLng( lat, lon ) ); + return this; + } + + public MogoPolylineOptions add( MogoLocation location ) { + if ( location != null ) { + this.mPoints.add( new MogoLatLng( location.getLatitude(), location.getLongitude() ) ); + } + return this; + } + + /** + * 设置线宽 + */ + public MogoPolylineOptions width( float width ) { + this.mWidth = width; + return this; + } + + /** + * 设置线的颜色 + * + * @param color + * @return + */ + public MogoPolylineOptions color( @ColorInt int color ) { + this.mColor = color; + return this; + } + + /** + * 设置Z轴的值 + * + * @param zIndex + * @return + */ + public MogoPolylineOptions zIndex( float zIndex ) { + this.mZIndex = zIndex; + return this; + } + + /** + * 设置是否可见 + * + * @param isVisible + * @return + */ + public MogoPolylineOptions visible( boolean isVisible ) { + this.mIsVisible = isVisible; + return this; + } + + /** + * 设置是否绘制测地线 + * + * @param isGeodesic + * @return + */ + public MogoPolylineOptions geodesic( boolean isGeodesic ) { + this.mIsGeodesic = isGeodesic; + return this; + } + + /** + * 是否是虚线 + * + * @param isDottedLine + * @return + */ + public MogoPolylineOptions dottedLine( boolean isDottedLine ) { + this.mIsDottedLine = isDottedLine; + return this; + } + + /** + * 是否使用渐变色 + * + * @param isGradient + * @return + */ + public MogoPolylineOptions useGradient( boolean isGradient ) { + this.mIsGradient = isGradient; + return this; + } + + /** + * 设置透明度 + * + * @param transparency + * @return + */ + public MogoPolylineOptions transparency( float transparency ) { + this.mTransparency = transparency; + return this; + } + + /** + * @param isAboveMaskLayer + * @return + */ + public MogoPolylineOptions aboveMaskLayer( boolean isAboveMaskLayer ) { + this.mIsAboveMaskLayer = isAboveMaskLayer; + return this; + } + + public List< MogoLatLng > getPoints() { + return mPoints; + } + + public float getWidth() { + return mWidth; + } + + public int getColor() { + return mColor; + } + + public float getZIndex() { + return mZIndex; + } + + public boolean isVisible() { + return mIsVisible; + } + + public boolean isGeodesic() { + return mIsGeodesic; + } + + public boolean isDottedLine() { + return mIsDottedLine; + } + + public boolean isGradient() { + return mIsGradient; + } + + public float getTransparency() { + return mTransparency; + } + + public boolean isAboveMaskLayer() { + return mIsAboveMaskLayer; + } + + public boolean isPointsUpdated() { + return mIsPointsUpdated; + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoOverlayManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoOverlayManager.java new file mode 100644 index 0000000000..6cde910cf3 --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoOverlayManager.java @@ -0,0 +1,40 @@ +package com.mogo.map; + +import com.mogo.map.overlay.IMogoOverlayManager; +import com.mogo.map.overlay.IMogoPolyline; +import com.mogo.map.overlay.MogoPolylineOptions; + +/** + * @author congtaowang + * @since 2020-03-10 + *
+ * 描述 + */ +public class MogoOverlayManager implements IMogoOverlayManager { + + private MogoOverlayManager() { + // private constructor + } + + private static final class InstanceHolder { + private static final MogoOverlayManager INSTANCE = new MogoOverlayManager(); + } + + public static MogoOverlayManager getInstance() { + return InstanceHolder.INSTANCE; + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return InstanceHolder.INSTANCE; + } + + @Override + public IMogoPolyline addPolyline( MogoPolylineOptions options ) { + try { + return MogoMap.getInstance().getMogoMap().addPolyline( options ); + } catch ( Exception e ) { + return null; + } + } +} diff --git a/modules/mogo-module-back/build.gradle b/modules/mogo-module-back/build.gradle index 28579c4416..f0c93b2d40 100644 --- a/modules/mogo-module-back/build.gradle +++ b/modules/mogo-module-back/build.gradle @@ -47,13 +47,21 @@ dependencies { implementation rootProject.ext.dependencies.rxandroid if (Boolean.valueOf(RELEASE)) { + implementation rootProject.ext.dependencies.mogomap + implementation rootProject.ext.dependencies.mogomapapi implementation rootProject.ext.dependencies.mogoutils implementation rootProject.ext.dependencies.mogocommons + implementation rootProject.ext.dependencies.mogoserviceapi implementation rootProject.ext.dependencies.modulecommon + implementation rootProject.ext.dependencies.moduleshare } else { + implementation project(":libraries:mogo-map") + implementation project(":libraries:mogo-map-api") implementation project(":foudations:mogo-utils") - api project(":foudations:mogo-commons") + implementation project(":foudations:mogo-commons") + implementation project(':services:mogo-service-api') implementation project(':modules:mogo-module-common') + implementation project(':modules:mogo-module-share') } } diff --git a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java index 5a1e46cb39..bb4d000185 100644 --- a/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java +++ b/modules/mogo-module-back/src/main/java/com/mogo/module/back/BackToLauncherModuleProvider.java @@ -1,33 +1,31 @@ package com.mogo.module.back; -import android.app.Activity; import android.content.Context; -import android.os.Build; +import android.content.Intent; import android.os.Bundle; -import android.text.TextUtils; -import android.util.ArrayMap; -import android.util.Log; import android.view.View; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; import com.alibaba.android.arouter.facade.annotation.Route; +import com.alibaba.android.arouter.launcher.ARouter; +import com.alibaba.idst.nls.internal.utils.L; +import com.mogo.commons.AbsMogoApplication; import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.location.IMogoLocationListener; import com.mogo.map.marker.IMogoMarkerClickListener; import com.mogo.map.navi.IMogoNaviListener; +import com.mogo.service.IMogoServiceApis; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.fragmentmanager.IMogoFragmentManager; +import com.mogo.service.intent.IMogoIntentListener; +import com.mogo.service.intent.IMogoIntentManager; import com.mogo.service.module.IMogoModuleLifecycle; import com.mogo.service.module.IMogoModuleProvider; import com.mogo.service.module.ModuleType; import com.mogo.utils.logger.Logger; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - /** * @author congtaowang * @since 2020-02-26 @@ -35,7 +33,12 @@ import java.util.Map; * 描述 */ @Route( path = BackToLauncherConst.MODULE_PATH ) -public class BackToLauncherModuleProvider implements IMogoModuleProvider { +public class BackToLauncherModuleProvider implements IMogoModuleProvider, IMogoIntentListener { + + private IMogoServiceApis mServiceApis; + private IMogoIntentManager mIntentManager; + + public static final String COMMAND_BACK = "com.ileja.launcher.back"; private static final String TAG = "BackToLauncherModuleProvider"; @@ -98,54 +101,17 @@ public class BackToLauncherModuleProvider implements IMogoModuleProvider { @Override public void init( Context context ) { BackToMainHomeManager.addMainHomeView(); -// final Activity activity = getTopActivity(context.getPackageName()); -// if ( activity instanceof FragmentActivity ) { -// Logger.d( TAG, "init." ); -// FragmentManager fragmentManager = ( ( FragmentActivity ) activity ).getSupportFragmentManager(); -// fragmentManager.beginTransaction() -// .add( new Back2LauncherFragment(), BackToLauncherConst.MODULE_NAME ) -// .commitAllowingStateLoss(); -// fragmentManager.executePendingTransactions(); -// } + mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(); + mIntentManager = mServiceApis.getIntentManagerApi(); + mIntentManager.registerIntentListener( COMMAND_BACK, this ); + BackToMainHomeManager.init( mServiceApis.getFragmentManagerApi() ); } -// /** -// * 获取当前运行的activity -// */ -// private Activity getTopActivity(String process) { -// Log.i("activity", "[getTopActivity]"); -// try { -// Class activityThreadClass = Class.forName("android.app.ActivityThread"); -// Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); -// Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); -// activitiesField.setAccessible(true); -// //16~18 HashMap -// //19~27 ArrayMap -// Map