diff --git a/.idea/misc.xml b/.idea/misc.xml index 703e5d4b89..8a8f75bfe2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index db84b9275e..e40891f0bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,7 @@ dependencies { // implementation rootProject.ext.dependencies.moduledemo // implementation rootProject.ext.dependencies.moduledemo2 +// implementation rootProject.ext.dependencies.modulechattingprovider // implementation rootProject.ext.dependencies.modulechatting diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 3af687459b..d2f1206eb8 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -27,6 +27,7 @@ public class MogoApplication extends AbsMogoApplication { DebugConfig.setNetMode( DebugConfig.NET_MODE_QA ); MogoModulePaths.addModule(new MogoModule(OnLineCarConstants.TAG, "CARD_TYPE_ROAD_ONLINECAR")); MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, "CARD_TYPE_ROAD_CODITION" ) ); + MogoModulePaths.addModule(new MogoModule( OnLineCarConstants.TAG, "CARD_TYPE_ROAD_ONLINECAR")); // MogoModulePaths.addModule(new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME)); } diff --git a/config.gradle b/config.gradle index c1d0b932b7..909fd6986b 100644 --- a/config.gradle +++ b/config.gradle @@ -95,6 +95,7 @@ ext { mogoconnection : "com.mogo.connection:mogo-connection:${MOGO_CONNECTION_VERSION}", moduleextensions : "com.mogo.module:module-extensions:${MOGO_MODULE_EXTENSIONS_VERSION}", modulechatting : "com.mogo.module.carchatting:module-carchatting:${CARCHATTING_VERSION}", + modulechattingprovider : "com.mogo.module.carchatting:module-carchatting-provider:${CARCHATTINGPROVIDER_VERSION}", // 在线车辆 moduleonlinecar : "com.mogo.module:module-onlinecar:${MOGO_MODULE_ONLINECAR_VERSION}", diff --git a/gradle.properties b/gradle.properties index 8a7f1f677d..0cc8c4f309 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,5 +45,6 @@ MOGO_MODULE_NAVI_VERSION=1.0.0-SNAPSHOT MOGO_MODULE_SERVICE_VERSION=1.0.0-SNAPSHOT MOGO_MODULE_EXTENSIONS_VERSION=1.0.0-SNAPSHOT CARCHATTING_VERSION=1.0.0-SNAPSHOT +CARCHATTINGPROVIDER_VERSION=1.0.0-SNAPSHOT MOGO_MODULE_ONLINECAR_VERSION=1.0.0-SNAPSHOT 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 e705ae6eac..150fa1c5dd 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 @@ -242,7 +242,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, */ @Override public void onPOIClick( Poi poi ) { - if ( InterceptorHandler.getInstance().ignorePoiClickedWhenNaviing( getContext() ) ) { + if ( InterceptorHandler.getInstance().ignorePoiClicked( getContext() ) ) { return; } MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) ); @@ -250,7 +250,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onMapClick( LatLng latLng ) { - if ( InterceptorHandler.getInstance().ignoreMapClickedWhenNaviing( getContext() ) ) { + if ( InterceptorHandler.getInstance().ignoreMapClicked( getContext() ) ) { return; } MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( latLng ) ); diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java index 819d5b5cf3..a52ef55c39 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java @@ -25,7 +25,7 @@ public interface IInterceptor { * @param context * @return */ - boolean ignorePoiClickedWhenNaviing( Context context ); + boolean ignorePoiClicked( Context context ); /** * 导航时,是否响应地图点击 @@ -33,5 +33,13 @@ public interface IInterceptor { * @param context * @return */ - boolean ignoreMapClickedWhenNaviing( Context context ); + boolean ignoreMapClicked( Context context ); + + /** + * 请求绘制路线 + * + * @param context + * @return + */ + boolean ignoreDrawRouteOverlay( Context context ); } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java index d1b1e41519..7ed3e125aa 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java @@ -14,6 +14,8 @@ public class InterceptorHandler implements IInterceptor { private static volatile InterceptorHandler sInstance; + private Context mContext; + private InterceptorHandler() { } @@ -32,18 +34,27 @@ public class InterceptorHandler implements IInterceptor { sInstance = null; } + public void init( Context context ) { + mContext = context; + } + @Override public boolean ignoreAddMarkersMoveToCenterParameters( Context context ) { return NaviClient.getInstance( context ).isNaviing(); } @Override - public boolean ignorePoiClickedWhenNaviing( Context context ) { + public boolean ignorePoiClicked( Context context ) { return NaviClient.getInstance( context ).isNaviing(); } @Override - public boolean ignoreMapClickedWhenNaviing( Context context ) { + public boolean ignoreMapClicked( Context context ) { + return NaviClient.getInstance( context ).isNaviing(); + } + + @Override + public boolean ignoreDrawRouteOverlay( Context context ) { return NaviClient.getInstance( context ).isNaviing(); } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java index dee097f456..fdc169a284 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java @@ -9,6 +9,7 @@ import com.amap.api.navi.model.NaviLatLng; import com.mogo.map.MogoLatLng; import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoCalculatePath; import com.mogo.map.navi.MogoNaviConfig; import com.mogo.utils.logger.Logger; @@ -138,6 +139,14 @@ public class NaviClient implements IMogoNavi { return false; } + @Override + public List< MogoCalculatePath > getCalculatedStrategies() { + if ( mAMapNaviListener != null ) { + return mAMapNaviListener.getCalculateStrategies(); + } + return null; + } + // -- end private boolean checkAMapNavi() { 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 f5d9d1d93b..5af657e925 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 @@ -12,9 +12,12 @@ import com.amap.api.navi.model.NaviInfo; import com.mogo.map.impl.amap.AMapWrapper; import com.mogo.map.impl.amap.message.AMapMessageManager; import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.navi.MogoCalculatePath; import com.mogo.map.navi.MogoNaviListenerHandler; import com.mogo.utils.logger.Logger; +import java.util.List; + /** * @author congtaowang * @since 2019-12-25 @@ -153,4 +156,11 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter { } } } + + public List< MogoCalculatePath > getCalculateStrategies() { + if ( mNaviOverlayHelper != null ) { + return mNaviOverlayHelper.getCalculateStrategies(); + } + return null; + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java index eeace7d2d1..776be5b0ff 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java @@ -14,6 +14,7 @@ import com.amap.api.navi.model.AMapNaviPath; import com.amap.api.navi.model.NaviInfo; import com.mogo.map.impl.amap.R; import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper; +import com.mogo.map.navi.MogoCalculatePath; import com.mogo.utils.WindowUtils; import com.mogo.utils.logger.Logger; @@ -29,7 +30,7 @@ import java.util.TreeMap; *

* 导航路径管理 */ -public class NaviOverlayHelper { +public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteraction { private static final String TAG = "NaviOverlayHelper"; @@ -176,9 +177,15 @@ public class NaviOverlayHelper { if ( polyline == null ) { return false; } + return handleClickedPolyline( polyline.getId() ); + } - Logger.i( TAG, "polyline id = " + polyline.getId() ); - mSelectedCalculatePathItem = isCalculatePolyline( polyline ); + private boolean handleClickedPolyline( String id ) { + if ( id == null ) { + return false; + } + Logger.i( TAG, "polyline id = " + id ); + mSelectedCalculatePathItem = isCalculatePolyline( id ); if ( mSelectedCalculatePathItem == null ) { return false; } @@ -199,7 +206,7 @@ public class NaviOverlayHelper { return true; } - private CalculatePathItem isCalculatePolyline( Polyline polyline ) { + private CalculatePathItem isCalculatePolyline( String id ) { CalculatePathItem result = null; if ( mCalculatePathItems == null || mCalculatePathItems.isEmpty() ) { return result; @@ -215,8 +222,7 @@ public class NaviOverlayHelper { if ( wrapper.getTrafficColorfulPolyline() == null ) { continue; } - if ( TextUtils.equals( wrapper.getTrafficColorfulPolyline().getId(), polyline.getId() ) - || wrapper.getTrafficColorfulPolyline() == polyline ) { + if ( TextUtils.equals( wrapper.getTrafficColorfulPolyline().getId(), id ) ) { result = calculatePathItem; } } @@ -249,4 +255,34 @@ public class NaviOverlayHelper { } } } + + + public List< MogoCalculatePath > getCalculateStrategies() { + List< MogoCalculatePath > paths = new ArrayList<>(); + if ( mCalculatePathItems != null && !mCalculatePathItems.isEmpty() ) { + for ( CalculatePathItem calculatePathItem : mCalculatePathItems ) { + MogoCalculatePath path = new MogoCalculatePath( this ); + path.setDistance( calculatePathItem.getDistance() ); + path.setPathId( calculatePathItem.getId() ); + path.setStrategyName( calculatePathItem.getStrategyName() ); + path.setTime( calculatePathItem.getTime() ); + path.setTrafficLights( calculatePathItem.getTrafficNumber() ); + paths.add( path ); + final RouteOverLayWrapper wrapper = calculatePathItem.getOverLazWrapper( true ); + if ( wrapper == null ) { + continue; + } + if ( wrapper.getTrafficColorfulPolyline() == null ) { + continue; + } + path.setTagId( wrapper.getTrafficColorfulPolyline().getId() ); + } + } + return paths; + } + + @Override + public void onItemClicked( String tagId ) { + handleClickedPolyline( tagId ); + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapUtil.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapUtil.java new file mode 100755 index 0000000000..a7a6f8eabd --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/AMapUtil.java @@ -0,0 +1,268 @@ +package com.mogo.map.impl.amap.overlay; + +import android.text.Html; +import android.text.Spanned; +import android.widget.EditText; + +import com.amap.api.maps.model.LatLng; +import com.amap.api.services.core.LatLonPoint; +import com.amap.api.services.route.BusPath; +import com.amap.api.services.route.BusStep; +import com.amap.api.services.route.RouteBusLineItem; +import com.amap.api.services.route.RouteRailwayItem; +import com.mogo.map.impl.amap.R; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class AMapUtil { + /** + * 判断edittext是否null + */ + public static String checkEditText(EditText editText) { + if (editText != null && editText.getText() != null + && !(editText.getText().toString().trim().equals(""))) { + return editText.getText().toString().trim(); + } else { + return ""; + } + } + + public static Spanned stringToSpan(String src) { + return src == null ? null : Html.fromHtml(src.replace("\n", "
")); + } + + public static String colorFont(String src, String color) { + StringBuffer strBuf = new StringBuffer(); + + strBuf.append("").append(src) + .append(""); + return strBuf.toString(); + } + + public static String makeHtmlNewLine() { + return "
"; + } + + public static String makeHtmlSpace(int number) { + final String space = " "; + StringBuilder result = new StringBuilder(); + for (int i = 0; i < number; i++) { + result.append(space); + } + return result.toString(); + } + + public static String getFriendlyLength(int lenMeter) { + if (lenMeter > 10000) // 10 km + { + int dis = lenMeter / 1000; + return dis + ChString.Kilometer; + } + + if (lenMeter > 1000) { + float dis = (float) lenMeter / 1000; + DecimalFormat fnum = new DecimalFormat("##0.0"); + String dstr = fnum.format(dis); + return dstr + ChString.Kilometer; + } + + if (lenMeter > 100) { + int dis = lenMeter / 50 * 50; + return dis + ChString.Meter; + } + + int dis = lenMeter / 10 * 10; + if (dis == 0) { + dis = 10; + } + + return dis + ChString.Meter; + } + + public static boolean IsEmptyOrNullString(String s) { + return (s == null) || (s.trim().length() == 0); + } + + /** + * 把LatLng对象转化为LatLonPoint对象 + */ + public static LatLonPoint convertToLatLonPoint(LatLng latlon) { + return new LatLonPoint(latlon.latitude, latlon.longitude); + } + + /** + * 把LatLonPoint对象转化为LatLon对象 + */ + public static LatLng convertToLatLng(LatLonPoint latLonPoint) { + return new LatLng(latLonPoint.getLatitude(), latLonPoint.getLongitude()); + } + + /** + * 把集合体的LatLonPoint转化为集合体的LatLng + */ + public static ArrayList convertArrList(List shapes) { + ArrayList lineShapes = new ArrayList(); + for (LatLonPoint point : shapes) { + LatLng latLngTemp = AMapUtil.convertToLatLng(point); + lineShapes.add(latLngTemp); + } + return lineShapes; + } + + /** + * long类型时间格式化 + */ + public static String convertToTime(long time) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(time); + return df.format(date); + } + + public static final String HtmlBlack = "#000000"; + public static final String HtmlGray = "#808080"; + + public static String getFriendlyTime(int second) { + if (second > 3600) { + int hour = second / 3600; + int miniate = (second % 3600) / 60; + return hour + "小时" + miniate + "分钟"; + } + if (second >= 60) { + int miniate = second / 60; + return miniate + "分钟"; + } + return second + "秒"; + } + + //路径规划方向指示和图片对应 + public static int getDriveActionID(String actionName) { + if (actionName == null || actionName.equals("")) { + return R.drawable.dir3; + } + if ("左转".equals(actionName)) { + return R.drawable.dir2; + } + if ("右转".equals(actionName)) { + return R.drawable.dir1; + } + if ("向左前方行驶".equals(actionName) || "靠左".equals(actionName)) { + return R.drawable.dir6; + } + if ("向右前方行驶".equals(actionName) || "靠右".equals(actionName)) { + return R.drawable.dir5; + } + if ("向左后方行驶".equals(actionName) || "左转调头".equals(actionName)) { + return R.drawable.dir7; + } + if ("向右后方行驶".equals(actionName)) { + return R.drawable.dir8; + } + if ("直行".equals(actionName)) { + return R.drawable.dir3; + } + if ("减速行驶".equals(actionName)) { + return R.drawable.dir4; + } + return R.drawable.dir3; + } + + public static int getWalkActionID(String actionName) { + if (actionName == null || actionName.equals("")) { + return R.drawable.dir13; + } + if ("左转".equals(actionName)) { + return R.drawable.dir2; + } + if ("右转".equals(actionName)) { + return R.drawable.dir1; + } + if ("向左前方".equals(actionName) || "靠左".equals(actionName) || actionName.contains("向左前方")) { + return R.drawable.dir6; + } + if ("向右前方".equals(actionName) || "靠右".equals(actionName) || actionName.contains("向右前方")) { + return R.drawable.dir5; + } + if ("向左后方".equals(actionName) || actionName.contains("向左后方")) { + return R.drawable.dir7; + } + if ("向右后方".equals(actionName) || actionName.contains("向右后方")) { + return R.drawable.dir8; + } + if ("直行".equals(actionName)) { + return R.drawable.dir3; + } + if ("通过人行横道".equals(actionName)) { + return R.drawable.dir9; + } + if ("通过过街天桥".equals(actionName)) { + return R.drawable.dir11; + } + if ("通过地下通道".equals(actionName)) { + return R.drawable.dir10; + } + + return R.drawable.dir13; + } + + public static String getBusPathTitle(BusPath busPath) { + if (busPath == null) { + return String.valueOf(""); + } + List busSetps = busPath.getSteps(); + if (busSetps == null) { + return String.valueOf(""); + } + StringBuffer sb = new StringBuffer(); + for (BusStep busStep : busSetps) { + StringBuffer title = new StringBuffer(); + if (busStep.getBusLines().size() > 0) { + for (RouteBusLineItem busline : busStep.getBusLines()) { + if (busline == null) { + continue; + } + + String buslineName = getSimpleBusLineName(busline.getBusLineName()); + title.append(buslineName); + title.append(" / "); + } +// RouteBusLineItem busline = busStep.getBusLines().get(0); + + sb.append(title.substring(0, title.length() - 3)); + sb.append(" > "); + } + if (busStep.getRailway() != null) { + RouteRailwayItem railway = busStep.getRailway(); + sb.append(railway.getTrip() + "(" + railway.getDeparturestop().getName() + + " - " + railway.getArrivalstop().getName() + ")"); + sb.append(" > "); + } + } + return sb.substring(0, sb.length() - 3); + } + + public static String getBusPathDes(BusPath busPath) { + if (busPath == null) { + return String.valueOf(""); + } + long second = busPath.getDuration(); + String time = getFriendlyTime((int) second); + float subDistance = busPath.getDistance(); + String subDis = getFriendlyLength((int) subDistance); + float walkDistance = busPath.getWalkDistance(); + String walkDis = getFriendlyLength((int) walkDistance); + return String.valueOf(time + " | " + subDis + " | 步行" + walkDis); + } + + public static String getSimpleBusLineName(String busLineName) { + if (busLineName == null) { + return String.valueOf(""); + } + return busLineName.replaceAll("\\(.*?\\)", ""); + } + + +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/ChString.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/ChString.java new file mode 100755 index 0000000000..2368d553ca --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/ChString.java @@ -0,0 +1,26 @@ +package com.mogo.map.impl.amap.overlay; + +public class ChString { + public static final String Kilometer = "\u516c\u91cc";// "公里"; + public static final String Meter = "\u7c73";// "米"; + public static final String ByFoot = "\u6b65\u884c";// "步行"; + public static final String To = "\u53bb\u5f80";// "去往"; + public static final String Station = "\u8f66\u7ad9";// "车站"; + public static final String TargetPlace = "\u76ee\u7684\u5730";// "目的地"; + public static final String StartPlace = "\u51fa\u53d1\u5730";// "出发地"; + public static final String About = "\u5927\u7ea6";// "大约"; + public static final String Direction = "\u65b9\u5411";// "方向"; + + public static final String GetOn = "\u4e0a\u8f66";// "上车"; + public static final String GetOff = "\u4e0b\u8f66";// "下车"; + public static final String Zhan = "\u7ad9";// "站"; + + public static final String cross = "\u4ea4\u53c9\u8def\u53e3"; // 交叉路口 + public static final String type = "\u7c7b\u522b"; // 类别 + public static final String address = "\u5730\u5740"; // 地址 + public static final String PrevStep = "\u4e0a\u4e00\u6b65"; + public static final String NextStep = "\u4e0b\u4e00\u6b65"; + public static final String Gong = "\u516c\u4ea4"; + public static final String ByBus = "\u4e58\u8f66"; + public static final String Arrive = "\u5230\u8FBE";// 到达 +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/DrivingRouteOverlay.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/DrivingRouteOverlay.java new file mode 100755 index 0000000000..619962b46a --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/DrivingRouteOverlay.java @@ -0,0 +1,388 @@ +package com.mogo.map.impl.amap.overlay; + +import android.content.Context; +import android.graphics.Color; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.model.BitmapDescriptor; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.MarkerOptions; +import com.amap.api.maps.model.PolylineOptions; +import com.amap.api.services.core.LatLonPoint; +import com.amap.api.services.route.DrivePath; +import com.amap.api.services.route.DriveStep; +import com.amap.api.services.route.TMC; +import com.mogo.map.impl.amap.R; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 导航路线图层类 + */ +public class DrivingRouteOverlay extends RouteOverlay { + private DrivePath drivePath; + private List throughPointList; + private List throughPointMarkerList = new ArrayList(); + private boolean throughPointMarkerVisible = true; + private List tmcs; + private PolylineOptions mPolylineOptions; + private PolylineOptions mPolylineOptionscolor; + private Context mContext; + private boolean isColorfulline = true; + private float mWidth = 4; + private List mLatLngsOfPath; + + public void setIsColorfulline(boolean iscolorfulline) { + this.isColorfulline = iscolorfulline; + } + + /** + * 根据给定的参数,构造一个导航路线图层类对象。 + * + * @param amap 地图对象。 + * @param path 导航路线规划方案。 + * @param context 当前的activity对象。 + */ + public DrivingRouteOverlay(Context context, + AMap amap, + DrivePath path, + LatLonPoint start, + LatLonPoint end, + List throughPointList) { + super(context); + mContext = context; + mAMap = amap; + this.drivePath = path; + startPoint = AMapUtil.convertToLatLng(start); + endPoint = AMapUtil.convertToLatLng(end); + this.throughPointList = throughPointList; + + initBitmapDescriptor(); + } + + public float getRouteWidth() { + return mWidth; + } + + /** + * 设置路线宽度 + * + * @param mWidth 路线宽度,取值范围:大于0 + */ + public void setRouteWidth(float mWidth) { + this.mWidth = mWidth; + } + + /** + * 添加驾车路线添加到地图上显示。 + */ + public void addToMap() { + initPolylineOptions(); + try { + if (mAMap == null) { + return; + } + + if (mWidth == 0 || drivePath == null) { + return; + } + mLatLngsOfPath = new ArrayList(); + tmcs = new ArrayList(); + List drivePaths = drivePath.getSteps(); + mPolylineOptions.add(startPoint); + for (int i = 0; i < drivePaths.size(); i++) { + DriveStep step = drivePaths.get(i); + List latlonPoints = step.getPolyline(); + List tmclist = step.getTMCs(); + tmcs.addAll(tmclist); + addDrivingStationMarkers(step, convertToLatLng(latlonPoints.get(0))); + for (LatLonPoint latlonpoint : latlonPoints) { + mPolylineOptions.add(convertToLatLng(latlonpoint)); + mLatLngsOfPath.add(convertToLatLng(latlonpoint)); + } + } + mPolylineOptions.add(endPoint); + if (startMarker != null) { + startMarker.remove(); + startMarker = null; + } + + if (endMarker != null) { + endMarker.remove(); + endMarker = null; + } +// addStartAndEndMarker(); +// addThroughPointMarker(); + if (isColorfulline && tmcs.size() > 0) { + colorWayUpdate(tmcs); + showcolorPolyline(); + } else { + showPolyline(); + } + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + /** + * 初始化线段属性 + */ + private void initPolylineOptions() { + mPolylineOptions = null; + mPolylineOptions = new PolylineOptions(); + mPolylineOptions.color(getDriveColor()).width(getRouteWidth()); + } + + private void showPolyline() { + addPolyLine(mPolylineOptions); + } + + private void showcolorPolyline() { + addPolyLine(mPolylineOptionscolor); + } + + /** + * 根据不同的路段拥堵情况展示不同的颜色 + * + * @param tmcSection + */ + private void colorWayUpdate(List tmcSection) { + if (mAMap == null) { + return; + } + if (tmcSection == null || tmcSection.size() <= 0) { + return; + } + TMC segmentTrafficStatus; + mPolylineOptionscolor = null; + mPolylineOptionscolor = new PolylineOptions(); + mPolylineOptionscolor.width(getRouteWidth()); + List colorList = new ArrayList(); + List bitmapDescriptors = new ArrayList(); + List points = new ArrayList<>(); + List texIndexList = new ArrayList(); +// mPolylineOptionscolor.add(startPoint); +// mPolylineOptionscolor.add(AMapUtil.convertToLatLng(tmcSection.get(0).getPolyline().get(0))); + + points.add(startPoint); + points.add(AMapUtil.convertToLatLng(tmcSection.get(0).getPolyline().get(0))); + colorList.add(getDriveColor()); + bitmapDescriptors.add(defaultRoute); + + BitmapDescriptor bitmapDescriptor = null; + int textIndex = 0; + texIndexList.add(textIndex); + texIndexList.add(++textIndex); + for (int i = 0; i < tmcSection.size(); i++) { + segmentTrafficStatus = tmcSection.get(i); + int color = getcolor(segmentTrafficStatus.getStatus()); + bitmapDescriptor = getTrafficBitmapDescriptor(segmentTrafficStatus.getStatus()); + List mployline = segmentTrafficStatus.getPolyline(); + for (int j = 0; j < mployline.size(); j++) { +// mPolylineOptionscolor.add(AMapUtil.convertToLatLng(mployline.get(j))); + points.add(AMapUtil.convertToLatLng(mployline.get(j))); + colorList.add(color); + + texIndexList.add(++textIndex); + bitmapDescriptors.add(bitmapDescriptor); + } + } + + points.add(endPoint); + colorList.add(getDriveColor()); + bitmapDescriptors.add(defaultRoute); + texIndexList.add(++textIndex); + mPolylineOptionscolor.addAll(points); + mPolylineOptionscolor.colorValues(colorList); + +// mPolylineOptionscolor.setCustomTextureIndex(texIndexList); +// mPolylineOptionscolor.setCustomTextureList(bitmapDescriptors); + } + + private BitmapDescriptor defaultRoute = null; + private BitmapDescriptor unknownTraffic = null; + private BitmapDescriptor smoothTraffic = null; + private BitmapDescriptor slowTraffic = null; + private BitmapDescriptor jamTraffic = null; + private BitmapDescriptor veryJamTraffic = null; + + private void initBitmapDescriptor() { + defaultRoute = BitmapDescriptorFactory.fromResource( R.drawable.amap_route_color_texture_6_arrow); + smoothTraffic = BitmapDescriptorFactory.fromResource(R.drawable.amap_route_color_texture_4_arrow); + unknownTraffic = BitmapDescriptorFactory.fromResource(R.drawable.amap_route_color_texture_0_arrow); + slowTraffic = BitmapDescriptorFactory.fromResource(R.drawable.amap_route_color_texture_3_arrow); + jamTraffic = BitmapDescriptorFactory.fromResource(R.drawable.amap_route_color_texture_2_arrow); + veryJamTraffic = BitmapDescriptorFactory.fromResource(R.drawable.amap_route_color_texture_9_arrow); + } + + private BitmapDescriptor getTrafficBitmapDescriptor(String status) { + if (status.equals("畅通")) { + return smoothTraffic; + } else if (status.equals("缓行")) { + return slowTraffic; + } else if (status.equals("拥堵")) { + return jamTraffic; + } else if (status.equals("严重拥堵")) { + return veryJamTraffic; + } else { + return defaultRoute; + } + } + + + private int getcolor(String status) { + if (status.equals("畅通")) { + return Color.GREEN; + } else if (status.equals("缓行")) { + return Color.YELLOW; + } else if (status.equals("拥堵")) { + return Color.RED; + } else if (status.equals("严重拥堵")) { + return Color.parseColor("#990033"); + } else { + return Color.GREEN; + } + } + + public LatLng convertToLatLng(LatLonPoint point) { + return new LatLng(point.getLatitude(), point.getLongitude()); + } + + /** + * @param driveStep + * @param latLng + */ + private void addDrivingStationMarkers(DriveStep driveStep, LatLng latLng) { + addStationMarker(new MarkerOptions() + .position(latLng) + .title("\u65B9\u5411:" + driveStep.getAction() + + "\n\u9053\u8DEF:" + driveStep.getRoad()) + .snippet(driveStep.getInstruction()).visible(nodeIconVisible) + .anchor(0.5f, 0.5f).icon(getDriveBitmapDescriptor())); + } + + @Override + protected LatLngBounds getLatLngBounds() { + LatLngBounds.Builder b = LatLngBounds.builder(); + b.include(new LatLng(startPoint.latitude, startPoint.longitude)); + b.include(new LatLng(endPoint.latitude, endPoint.longitude)); + if (this.throughPointList != null && this.throughPointList.size() > 0) { + for (int i = 0; i < this.throughPointList.size(); i++) { + b.include(new LatLng( + this.throughPointList.get(i).getLatitude(), + this.throughPointList.get(i).getLongitude())); + } + } + return b.build(); + } + + public void setThroughPointIconVisibility(boolean visible) { + try { + throughPointMarkerVisible = visible; + if (this.throughPointMarkerList != null + && this.throughPointMarkerList.size() > 0) { + for (int i = 0; i < this.throughPointMarkerList.size(); i++) { + this.throughPointMarkerList.get(i).setVisible(visible); + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + + private void addThroughPointMarker() { + if (this.throughPointList != null && this.throughPointList.size() > 0) { + LatLonPoint latLonPoint = null; + for (int i = 0; i < this.throughPointList.size(); i++) { + latLonPoint = this.throughPointList.get(i); + if (latLonPoint != null) { + throughPointMarkerList.add(mAMap + .addMarker((new MarkerOptions()) + .position( + new LatLng(latLonPoint + .getLatitude(), latLonPoint + .getLongitude())) + .visible(throughPointMarkerVisible) + .icon(getThroughPointBitDes()) + .title("\u9014\u7ECF\u70B9"))); + } + } + } + } + + private BitmapDescriptor getThroughPointBitDes() { + return BitmapDescriptorFactory.fromResource(R.drawable.amap_through); + + } + + /** + * 获取两点间距离 + * + * @param start + * @param end + * @return + */ + public static int calculateDistance(LatLng start, LatLng end) { + double x1 = start.longitude; + double y1 = start.latitude; + double x2 = end.longitude; + double y2 = end.latitude; + return calculateDistance(x1, y1, x2, y2); + } + + public static int calculateDistance(double x1, double y1, double x2, double y2) { + final double NF_pi = 0.01745329251994329; // 弧度 PI/180 + x1 *= NF_pi; + y1 *= NF_pi; + x2 *= NF_pi; + y2 *= NF_pi; + double sinx1 = Math.sin(x1); + double siny1 = Math.sin(y1); + double cosx1 = Math.cos(x1); + double cosy1 = Math.cos(y1); + double sinx2 = Math.sin(x2); + double siny2 = Math.sin(y2); + double cosx2 = Math.cos(x2); + double cosy2 = Math.cos(y2); + double[] v1 = new double[3]; + v1[0] = cosy1 * cosx1 - cosy2 * cosx2; + v1[1] = cosy1 * sinx1 - cosy2 * sinx2; + v1[2] = siny1 - siny2; + double dist = Math.sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); + + return (int) (Math.asin(dist / 2) * 12742001.5798544); + } + + + //获取指定两点之间固定距离点 + public static LatLng getPointForDis(LatLng sPt, LatLng ePt, double dis) { + double lSegLength = calculateDistance(sPt, ePt); + double preResult = dis / lSegLength; + return new LatLng((ePt.latitude - sPt.latitude) * preResult + sPt.latitude, (ePt.longitude - sPt.longitude) * preResult + sPt.longitude); + } + + /** + * 去掉DriveLineOverlay上的线段和标记。 + */ + @Override + public void removeFromMap() { + try { + super.removeFromMap(); + if (this.throughPointMarkerList != null + && this.throughPointMarkerList.size() > 0) { + for (int i = 0; i < this.throughPointMarkerList.size(); i++) { + this.throughPointMarkerList.get(i).remove(); + } + this.throughPointMarkerList.clear(); + } + } catch (Throwable e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/OnRouteSearchListenerAdapter.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/OnRouteSearchListenerAdapter.java new file mode 100644 index 0000000000..c5189413a8 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/OnRouteSearchListenerAdapter.java @@ -0,0 +1,36 @@ +package com.mogo.map.impl.amap.overlay; + +import com.amap.api.services.route.BusRouteResult; +import com.amap.api.services.route.DriveRouteResult; +import com.amap.api.services.route.RideRouteResult; +import com.amap.api.services.route.RouteSearch; +import com.amap.api.services.route.WalkRouteResult; + +/** + * @author congtaowang + * @since 2020-01-08 + *

+ * 描述 + */ +public abstract class OnRouteSearchListenerAdapter implements RouteSearch.OnRouteSearchListener { + + @Override + public void onBusRouteSearched( BusRouteResult busRouteResult, int i ) { + + } + + @Override + public void onDriveRouteSearched( DriveRouteResult driveRouteResult, int i ) { + + } + + @Override + public void onWalkRouteSearched( WalkRouteResult walkRouteResult, int i ) { + + } + + @Override + public void onRideRouteSearched( RideRouteResult rideRouteResult, int i ) { + + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlay.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlay.java new file mode 100755 index 0000000000..3dcae30d10 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlay.java @@ -0,0 +1,236 @@ +package com.mogo.map.impl.amap.overlay; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Color; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.CameraUpdateFactory; +import com.amap.api.maps.model.BitmapDescriptor; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +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.mogo.map.impl.amap.R; + +import java.util.ArrayList; +import java.util.List; + + +public class RouteOverlay { + protected List stationMarkers = new ArrayList(); + protected List allPolyLines = new ArrayList(); + protected Marker startMarker; + protected Marker endMarker; + protected LatLng startPoint; + protected LatLng endPoint; + protected AMap mAMap; + private Context mContext; + private Bitmap startBit, endBit, busBit, walkBit, driveBit; + protected boolean nodeIconVisible = true; + + public RouteOverlay(Context context) { + mContext = context; + } + + /** + * 去掉BusRouteOverlay上所有的Marker。 + * + * @since V2.1.0 + */ + public void removeFromMap() { + if (startMarker != null) { + startMarker.remove(); + + } + if (endMarker != null) { + endMarker.remove(); + } + for (Marker marker : stationMarkers) { + marker.remove(); + } + for (Polyline line : allPolyLines) { + line.remove(); + } + destroyBit(); + } + + private void destroyBit() { + if (startBit != null) { + startBit.recycle(); + startBit = null; + } + if (endBit != null) { + endBit.recycle(); + endBit = null; + } + if (busBit != null) { + busBit.recycle(); + busBit = null; + } + if (walkBit != null) { + walkBit.recycle(); + walkBit = null; + } + if (driveBit != null) { + driveBit.recycle(); + driveBit = null; + } + } + + /** + * 给起点Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 + * + * @return 更换的Marker图片。 + * @since V2.1.0 + */ + protected BitmapDescriptor getStartBitmapDescriptor() { + return BitmapDescriptorFactory.fromResource( R.drawable.amap_start); + } + + /** + * 给终点Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 + * + * @return 更换的Marker图片。 + * @since V2.1.0 + */ + protected BitmapDescriptor getEndBitmapDescriptor() { + return BitmapDescriptorFactory.fromResource(R.drawable.amap_end); + } + + /** + * 给公交Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 + * + * @return 更换的Marker图片。 + * @since V2.1.0 + */ + protected BitmapDescriptor getBusBitmapDescriptor() { + return BitmapDescriptorFactory.fromResource(R.drawable.amap_bus); + } + + /** + * 给步行Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 + * + * @return 更换的Marker图片。 + * @since V2.1.0 + */ + protected BitmapDescriptor getWalkBitmapDescriptor() { + return BitmapDescriptorFactory.fromResource(R.drawable.amap_man); + } + + protected BitmapDescriptor getDriveBitmapDescriptor() { + return BitmapDescriptorFactory.fromResource(R.drawable.amap_car); + } + + protected void addStartAndEndMarker() { + startMarker = mAMap.addMarker((new MarkerOptions()) + .position(startPoint).icon(getStartBitmapDescriptor()) + .title("\u8D77\u70B9")); + // startMarker.showInfoWindow(); + + endMarker = mAMap.addMarker((new MarkerOptions()).position(endPoint) + .icon(getEndBitmapDescriptor()).title("\u7EC8\u70B9")); + // mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startPoint, + // getShowRouteZoom())); + } + + /** + * 移动镜头到当前的视角。 + * + * @since V2.1.0 + */ + public void zoomToSpan() { + if (startPoint != null) { + if (mAMap == null) + return; + try { + LatLngBounds bounds = getLatLngBounds(); + mAMap.animateCamera(CameraUpdateFactory + .newLatLngBounds(bounds, 50)); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + protected LatLngBounds getLatLngBounds() { + LatLngBounds.Builder b = LatLngBounds.builder(); + b.include(new LatLng(startPoint.latitude, startPoint.longitude)); + b.include(new LatLng(endPoint.latitude, endPoint.longitude)); + for (Polyline polyline : allPolyLines) { + for (LatLng point : polyline.getPoints()) { + b.include(point); + } + } + return b.build(); + } + + /** + * 路段节点图标控制显示接口。 + * + * @param visible true为显示节点图标,false为不显示。 + * @since V2.3.1 + */ + public void setNodeIconVisibility(boolean visible) { + try { + nodeIconVisible = visible; + if (this.stationMarkers != null && this.stationMarkers.size() > 0) { + for (int i = 0; i < this.stationMarkers.size(); i++) { + this.stationMarkers.get(i).setVisible(visible); + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + + protected void addStationMarker(MarkerOptions options) { + if (options == null) { + return; + } + Marker marker = mAMap.addMarker(options); + if (marker != null) { + stationMarkers.add(marker); + } + + } + + protected void addPolyLine(PolylineOptions options) { + if (options == null) { + return; + } + Polyline polyline = mAMap.addPolyline(options); + if (polyline != null) { + allPolyLines.add(polyline); + } + } + + protected float getRouteWidth() { + return 18f; + } + + protected int getWalkColor() { + return Color.parseColor("#6db74d"); + } + + /** + * 自定义路线颜色。 + * return 自定义路线颜色。 + * + * @since V2.2.1 + */ + protected int getBusColor() { + return Color.parseColor("#537edc"); + } + + protected int getDriveColor() { + return Color.parseColor("#537edc"); + } + + // protected int getShowRouteZoom() { + // return 15; + // } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlayHelper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlayHelper.java new file mode 100644 index 0000000000..f5ea198d91 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverlayHelper.java @@ -0,0 +1,96 @@ +package com.mogo.map.impl.amap.overlay; + +import android.content.Context; + +import com.amap.api.services.core.LatLonPoint; +import com.amap.api.services.route.DriveRouteResult; +import com.amap.api.services.route.RouteSearch; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.amap.InterceptorHandler; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2020-01-08 + *

+ * 给定起点、途经点,规划路径 + */ +public class RouteOverlayHelper { + + private static final String TAG = "RouteOverlayHelper"; + + private static volatile RouteOverlayHelper sInstance; + + private DrivingRouteOverlay mDrivingRouteOverlay; + + private RouteOverlayHelper() { + } + + public static RouteOverlayHelper getInstance() { + if ( sInstance == null ) { + synchronized ( RouteOverlayHelper.class ) { + if ( sInstance == null ) { + sInstance = new RouteOverlayHelper(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + public void addRouteWay( final Context context, MogoLatLng start, MogoLatLng end, List< MogoLatLng > wayPoints ) { + if ( wayPoints == null || wayPoints.isEmpty() ) { + return; + } + if ( InterceptorHandler.getInstance().ignoreDrawRouteOverlay( context ) ) { + Logger.w( TAG, "naviing." ); + return; + } + + if ( mDrivingRouteOverlay != null ) { + mDrivingRouteOverlay.removeFromMap(); + } + + RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo( new LatLonPoint( start.lat, start.lng ), + new LatLonPoint( end.lat, end.lng ) ); + final List< LatLonPoint > ways = new ArrayList<>(); + for ( MogoLatLng wayPoint : wayPoints ) { + ways.add( new LatLonPoint( wayPoint.lat, wayPoint.lng ) ); + } + RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery( fromAndTo, 0, ways, null, "" ); + RouteSearch routeSearch = new RouteSearch( context ); + routeSearch.calculateDriveRouteAsyn( query ); + routeSearch.setRouteSearchListener( new OnRouteSearchListenerAdapter() { + @Override + public void onDriveRouteSearched( DriveRouteResult driveRouteResult, int i ) { + super.onDriveRouteSearched( driveRouteResult, i ); + if ( i != 1000 ) { + Logger.e( TAG, "算路失败. code = %d", i ); + return; + } + mDrivingRouteOverlay = new DrivingRouteOverlay( context, null, + driveRouteResult.getPaths().get( 0 ), + driveRouteResult.getStartPos(), + driveRouteResult.getTargetPos(), + null ); + mDrivingRouteOverlay.setNodeIconVisibility( false ); + mDrivingRouteOverlay.setIsColorfulline( false ); + mDrivingRouteOverlay.addToMap(); + mDrivingRouteOverlay.zoomToSpan(); + } + } ); + } + + public void removeAll() { + if ( mDrivingRouteOverlay != null ) { + mDrivingRouteOverlay.removeFromMap(); + } + mDrivingRouteOverlay = null; + } +} diff --git a/libraries/map-amap/src/main/res/drawable/amap_bus.png b/libraries/map-amap/src/main/res/drawable/amap_bus.png new file mode 100755 index 0000000000..66f73f4454 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_bus.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_car.png b/libraries/map-amap/src/main/res/drawable/amap_car.png new file mode 100755 index 0000000000..b12b10c83f Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_car.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_end.png b/libraries/map-amap/src/main/res/drawable/amap_end.png new file mode 100755 index 0000000000..5503dc5a28 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_end.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_man.png b/libraries/map-amap/src/main/res/drawable/amap_man.png new file mode 100755 index 0000000000..16842d5d12 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_man.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_ride.png b/libraries/map-amap/src/main/res/drawable/amap_ride.png new file mode 100755 index 0000000000..2fa5633c59 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_ride.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_0_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_0_arrow.png new file mode 100755 index 0000000000..21793fea2b Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_0_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_1_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_1_arrow.png new file mode 100755 index 0000000000..d7d832857f Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_1_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_2_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_2_arrow.png new file mode 100755 index 0000000000..c1d019b4ae Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_2_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_3_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_3_arrow.png new file mode 100755 index 0000000000..b3318ad436 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_3_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_4_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_4_arrow.png new file mode 100755 index 0000000000..038e63f485 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_4_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_5_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_5_arrow.png new file mode 100755 index 0000000000..e15ce84e87 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_5_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_6_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_6_arrow.png new file mode 100755 index 0000000000..9f3540757a Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_6_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_7_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_7_arrow.png new file mode 100755 index 0000000000..cef675f06f Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_7_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_8_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_8_arrow.png new file mode 100755 index 0000000000..c4d67d38a4 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_8_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_9_arrow.png b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_9_arrow.png new file mode 100755 index 0000000000..3c92f82f0d Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_route_color_texture_9_arrow.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_start.png b/libraries/map-amap/src/main/res/drawable/amap_start.png new file mode 100755 index 0000000000..cd716c8840 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_start.png differ diff --git a/libraries/map-amap/src/main/res/drawable/amap_through.png b/libraries/map-amap/src/main/res/drawable/amap_through.png new file mode 100755 index 0000000000..e636b446c1 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/amap_through.png differ diff --git a/libraries/map-amap/src/main/res/drawable/app_icon.png b/libraries/map-amap/src/main/res/drawable/app_icon.png new file mode 100644 index 0000000000..c97be4be12 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/app_icon.png differ diff --git a/libraries/map-amap/src/main/res/drawable/default_image.png b/libraries/map-amap/src/main/res/drawable/default_image.png new file mode 100644 index 0000000000..fdc210cd25 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/default_image.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir1.png b/libraries/map-amap/src/main/res/drawable/dir1.png new file mode 100755 index 0000000000..fec3f4ec69 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir1.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir10.png b/libraries/map-amap/src/main/res/drawable/dir10.png new file mode 100755 index 0000000000..34c2228f6c Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir10.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir11.png b/libraries/map-amap/src/main/res/drawable/dir11.png new file mode 100755 index 0000000000..df9e8dc67c Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir11.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir12.png b/libraries/map-amap/src/main/res/drawable/dir12.png new file mode 100755 index 0000000000..a4ba8c22cb Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir12.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir13.png b/libraries/map-amap/src/main/res/drawable/dir13.png new file mode 100755 index 0000000000..39ad870c5f Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir13.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir14.png b/libraries/map-amap/src/main/res/drawable/dir14.png new file mode 100755 index 0000000000..a3c1632562 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir14.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir15.png b/libraries/map-amap/src/main/res/drawable/dir15.png new file mode 100755 index 0000000000..c99fb65b94 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir15.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir16.png b/libraries/map-amap/src/main/res/drawable/dir16.png new file mode 100755 index 0000000000..86898c2144 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir16.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir2.png b/libraries/map-amap/src/main/res/drawable/dir2.png new file mode 100755 index 0000000000..750b6fbb7e Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir2.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir3.png b/libraries/map-amap/src/main/res/drawable/dir3.png new file mode 100755 index 0000000000..8cbe886e81 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir3.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir4.png b/libraries/map-amap/src/main/res/drawable/dir4.png new file mode 100755 index 0000000000..cfe7d6c0fb Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir4.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir5.png b/libraries/map-amap/src/main/res/drawable/dir5.png new file mode 100755 index 0000000000..e465d5eec2 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir5.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir6.png b/libraries/map-amap/src/main/res/drawable/dir6.png new file mode 100755 index 0000000000..0d2f3c0360 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir6.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir7.png b/libraries/map-amap/src/main/res/drawable/dir7.png new file mode 100755 index 0000000000..e53c9ff451 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir7.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir8.png b/libraries/map-amap/src/main/res/drawable/dir8.png new file mode 100755 index 0000000000..edfdbe1df0 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir8.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir9.png b/libraries/map-amap/src/main/res/drawable/dir9.png new file mode 100755 index 0000000000..a762d0b74a Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir9.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir_end.png b/libraries/map-amap/src/main/res/drawable/dir_end.png new file mode 100755 index 0000000000..f3cb78aed4 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir_end.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir_start.png b/libraries/map-amap/src/main/res/drawable/dir_start.png new file mode 100755 index 0000000000..4d2a797823 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir_start.png differ diff --git a/libraries/map-amap/src/main/res/drawable/dir_station.png b/libraries/map-amap/src/main/res/drawable/dir_station.png new file mode 100755 index 0000000000..2ed622283b Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/dir_station.png differ diff --git a/libraries/map-amap/src/main/res/drawable/ic_refresh.png b/libraries/map-amap/src/main/res/drawable/ic_refresh.png new file mode 100644 index 0000000000..d86c3f8024 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/ic_refresh.png differ diff --git a/libraries/map-amap/src/main/res/drawable/ic_snapshot_ph.png b/libraries/map-amap/src/main/res/drawable/ic_snapshot_ph.png new file mode 100644 index 0000000000..281f1bb163 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/ic_snapshot_ph.png differ diff --git a/libraries/map-amap/src/main/res/drawable/join_checkbox_bg.png b/libraries/map-amap/src/main/res/drawable/join_checkbox_bg.png new file mode 100755 index 0000000000..89d00803c5 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/join_checkbox_bg.png differ diff --git a/libraries/map-amap/src/main/res/drawable/live_exit.png b/libraries/map-amap/src/main/res/drawable/live_exit.png new file mode 100644 index 0000000000..7d9b50f159 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/live_exit.png differ diff --git a/libraries/map-amap/src/main/res/drawable/location_city_image.png b/libraries/map-amap/src/main/res/drawable/location_city_image.png new file mode 100644 index 0000000000..ce5515c529 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/location_city_image.png differ diff --git a/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_normal.png b/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_normal.png new file mode 100644 index 0000000000..9c1a2a4aea Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_normal.png differ diff --git a/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_press.png b/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_press.png new file mode 100644 index 0000000000..d927b18877 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/main_solid_left_page_up_press.png differ diff --git a/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_normal.png b/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_normal.png new file mode 100644 index 0000000000..dda526f475 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_normal.png differ diff --git a/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_press.png b/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_press.png new file mode 100644 index 0000000000..2289209d9a Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/main_solid_right_page_up_press.png differ diff --git a/libraries/map-amap/src/main/res/drawable/mainpage_location_img.png b/libraries/map-amap/src/main/res/drawable/mainpage_location_img.png new file mode 100644 index 0000000000..7a463ac3ab Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/mainpage_location_img.png differ diff --git a/libraries/map-amap/src/main/res/drawable/map_location_normal.png b/libraries/map-amap/src/main/res/drawable/map_location_normal.png new file mode 100644 index 0000000000..53f5b5a14a Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/map_location_normal.png differ diff --git a/libraries/map-amap/src/main/res/drawable/map_location_press.png b/libraries/map-amap/src/main/res/drawable/map_location_press.png new file mode 100644 index 0000000000..e3e430c8d6 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/map_location_press.png differ diff --git a/libraries/map-amap/src/main/res/drawable/not_join_checkbox_bg.png b/libraries/map-amap/src/main/res/drawable/not_join_checkbox_bg.png new file mode 100755 index 0000000000..663addd255 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/not_join_checkbox_bg.png differ diff --git a/libraries/map-amap/src/main/res/drawable/public_arrow_back_iv.png b/libraries/map-amap/src/main/res/drawable/public_arrow_back_iv.png new file mode 100644 index 0000000000..cd7159e219 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/public_arrow_back_iv.png differ diff --git a/libraries/map-amap/src/main/res/drawable/search_information_normal.png b/libraries/map-amap/src/main/res/drawable/search_information_normal.png new file mode 100644 index 0000000000..69529ef0bd Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/search_information_normal.png differ diff --git a/libraries/map-amap/src/main/res/drawable/search_information_press.png b/libraries/map-amap/src/main/res/drawable/search_information_press.png new file mode 100644 index 0000000000..8338cc95ae Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/search_information_press.png differ diff --git a/libraries/map-amap/src/main/res/drawable/video_loading_img.png b/libraries/map-amap/src/main/res/drawable/video_loading_img.png new file mode 100644 index 0000000000..48be2bdd18 Binary files /dev/null and b/libraries/map-amap/src/main/res/drawable/video_loading_img.png differ diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java index 8eac9516c3..50c75c5dc1 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java @@ -1,5 +1,9 @@ package com.mogo.map.marker; +import android.content.Context; + +import com.mogo.map.MogoLatLng; + import java.util.ArrayList; import java.util.List; @@ -55,4 +59,19 @@ public interface IMogoMarkerManager { * @param tag 需要保留的类型 */ void removeMarkersExcept( String tag ); + + /** + * 添加搜索路线 + * + * @param context 上下文 + * @param startPoint 起点 + * @param endPoint 终点 + * @param wayPoints 途经点 + */ + void addRouteWay( Context context, MogoLatLng startPoint, MogoLatLng endPoint, List< MogoLatLng > wayPoints ); + + /** + * 移除添加的导航预测路线 + */ + void removeRouteWayOverlay(); } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java index c72ff5ffcc..adb910084b 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java @@ -69,4 +69,11 @@ public interface IMogoNavi { * @return */ boolean isNaviing(); + + /** + * 获取路线规划策略 + * + * @return 规划的路线 + */ + List< MogoCalculatePath > getCalculatedStrategies(); } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoCalculatePath.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoCalculatePath.java new file mode 100644 index 0000000000..6034fddefe --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoCalculatePath.java @@ -0,0 +1,106 @@ +package com.mogo.map.navi; + +/** + * @author congtaowang + * @since 2020-01-08 + *

+ * 规划路线信息 + */ +public class MogoCalculatePath { + + /** + * 策略名称 + */ + public String mStrategyName; + + /** + * 时间 + */ + public String mTime; + + /** + * 距离 + */ + public String mDistance; + + /** + * 红绿灯个数 + */ + public int mTrafficLights; + + /** + * 路线ID,用于选择那一条线 + */ + public String mTagId; + + /** + * 规划的线路ID + */ + public int mPathId; + + /** + * 点击事件 + */ + public OnItemClickInteraction mOnItemClickInteraction; + + public MogoCalculatePath( OnItemClickInteraction onItemClickInteraction ) { + this.mOnItemClickInteraction = onItemClickInteraction; + } + + public String getStrategyName() { + return mStrategyName; + } + + public void setStrategyName( String mStrategyName ) { + this.mStrategyName = mStrategyName; + } + + public String getTime() { + return mTime; + } + + public void setTime( String mTime ) { + this.mTime = mTime; + } + + public String getDistance() { + return mDistance; + } + + public void setDistance( String mDistance ) { + this.mDistance = mDistance; + } + + public int getTrafficLights() { + return mTrafficLights; + } + + public void setTrafficLights( int mTrafficLights ) { + this.mTrafficLights = mTrafficLights; + } + + public String getTagId() { + return mTagId; + } + + public void setTagId( String mTagId ) { + this.mTagId = mTagId; + } + + public int getPathId() { + return mPathId; + } + + public void setPathId( int mPathId ) { + this.mPathId = mPathId; + } + + public interface OnItemClickInteraction { + + void onItemClicked( String tagId ); + } + + public OnItemClickInteraction getOnItemClickInteraction() { + return mOnItemClickInteraction; + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java index 7e9baa5ef9..3072f7e06d 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java @@ -3,6 +3,7 @@ package com.mogo.map; import android.content.Context; import com.mogo.map.impl.amap.InterceptorHandler; +import com.mogo.map.impl.amap.overlay.RouteOverlayHelper; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.IMogoMarkerManager; import com.mogo.map.marker.MogoMarkerOptions; @@ -81,4 +82,14 @@ public class MogoMarkerManager implements IMogoMarkerManager { public void removeMarkersExcept( String tag ) { MogoMarkersHandler.getInstance().deleteAllExcept( tag ); } + + @Override + public void addRouteWay( Context context, MogoLatLng startPoint, MogoLatLng endPoint, List< MogoLatLng > wayPoints ) { + RouteOverlayHelper.getInstance().addRouteWay( context, startPoint, endPoint, wayPoints ); + } + + @Override + public void removeRouteWayOverlay() { + RouteOverlayHelper.getInstance().removeAll(); + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java index 4dca64d5c6..48be28d3a7 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java @@ -4,6 +4,7 @@ import android.content.Context; import com.mogo.map.impl.amap.navi.NaviClient; import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoCalculatePath; import com.mogo.map.navi.MogoNaviConfig; import java.util.List; @@ -95,4 +96,12 @@ public class MogoNavi implements IMogoNavi { } return false; } + + @Override + public List< MogoCalculatePath > getCalculatedStrategies() { + if ( mDelegate != null ) { + return mDelegate.getCalculatedStrategies(); + } + return null; + } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java index a75f52ee00..218704c86a 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java @@ -6,6 +6,8 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import com.mogo.module.apps.RefreshAppsListLiveData; + public class AppInstallReceiver extends BroadcastReceiver { @Override @@ -37,6 +39,6 @@ public class AppInstallReceiver extends BroadcastReceiver { } private void notifyRefreshAppsList( String packageName ) { - + RefreshAppsListLiveData.getInstance().postValue( packageName ); } } \ No newline at end of file diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java index 16cd869302..95a59f095f 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java @@ -1,6 +1,12 @@ package com.mogo.module.main; +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.Build; import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.text.TextUtils; +import android.util.Log; import android.view.View; import androidx.annotation.NonNull; @@ -33,6 +39,7 @@ import com.mogo.service.module.IMogoModuleProvider; import com.mogo.utils.logger.Logger; import java.util.List; +import java.util.UUID; /** * @author congtaowang