dev
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 导航操作
|
||||
*/
|
||||
public interface IMogoNavi {
|
||||
|
||||
/**
|
||||
* 开启路径规划并导航
|
||||
*
|
||||
* @param endPoint 目的地
|
||||
*/
|
||||
void naviTo( MogoLatLng endPoint );
|
||||
|
||||
/**
|
||||
* 开启路径规划并导航
|
||||
*
|
||||
* @param endPoint 目的地
|
||||
* @param config 规划路线策略
|
||||
*/
|
||||
void naviTo( MogoLatLng endPoint, MogoNaviConfig config );
|
||||
|
||||
/**
|
||||
* 开启路径规划并导航
|
||||
*
|
||||
* @param endPoint 导航目的地
|
||||
* @param wayPoints 途经点
|
||||
*/
|
||||
void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints );
|
||||
|
||||
/**
|
||||
* 开启路径规划并导航
|
||||
*
|
||||
* @param endPoint 导航目的地
|
||||
* @param wayPoints 途经点
|
||||
* @param config 规划路线策略
|
||||
*/
|
||||
void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config );
|
||||
|
||||
/**
|
||||
* 重新算路
|
||||
*
|
||||
* @param config 规划路线策略
|
||||
*/
|
||||
void reCalculateRoute( MogoNaviConfig config );
|
||||
|
||||
/**
|
||||
* 退出导航
|
||||
*/
|
||||
void stopNavi();
|
||||
|
||||
/**
|
||||
* 开始导航
|
||||
*/
|
||||
void startNavi();
|
||||
|
||||
/**
|
||||
* 是否正在导航
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isNaviing();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 导航监听
|
||||
*/
|
||||
public interface IMogoNaviListener {
|
||||
|
||||
/**
|
||||
* 导航初始化失败
|
||||
*/
|
||||
void onInitNaviFailure();
|
||||
|
||||
/**
|
||||
* 导航初始化成功
|
||||
*/
|
||||
void onInitNaviSuccess();
|
||||
|
||||
/**
|
||||
* 导航引导信息
|
||||
*
|
||||
* @param naviinfo
|
||||
*/
|
||||
void onNaviInfoUpdate( MogoNaviInfo naviinfo );
|
||||
|
||||
/**
|
||||
* 导航开始回调
|
||||
*/
|
||||
void onStartNavi();
|
||||
|
||||
/**
|
||||
* 导航停止:包括到达目的地和主动停止导航
|
||||
*/
|
||||
void onStopNavi();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoNaviListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册导航回调,各业务模块不用关注
|
||||
*
|
||||
* @param listener 回调函数
|
||||
*/
|
||||
void registerHostNaviListener( IMogoNaviListener listener );
|
||||
|
||||
/**
|
||||
* 注销导航回调,各业务模块不用关注
|
||||
*/
|
||||
void unregisterHostNaviListener();
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 导航参数
|
||||
*/
|
||||
public class MogoNaviConfig {
|
||||
|
||||
/**
|
||||
* 是否躲避拥堵
|
||||
*/
|
||||
private boolean congestion = false;
|
||||
|
||||
/**
|
||||
* 不走高速
|
||||
*/
|
||||
private boolean avoidSpeed = false;
|
||||
|
||||
/**
|
||||
* 避免收费
|
||||
*/
|
||||
private boolean cost = false;
|
||||
|
||||
/**
|
||||
* 高速优先
|
||||
*/
|
||||
private boolean highSpeed = false;
|
||||
|
||||
/**
|
||||
* 是否多路线算路
|
||||
*/
|
||||
private boolean multipleRoute = true;
|
||||
|
||||
/**
|
||||
* 是否是正式的导航
|
||||
* <p>
|
||||
* false 为模拟导航
|
||||
*/
|
||||
private boolean realNavi = true;
|
||||
|
||||
/**
|
||||
* 是否躲避拥堵
|
||||
*/
|
||||
public MogoNaviConfig congestion( boolean congestion ) {
|
||||
this.congestion = congestion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不走高速
|
||||
*/
|
||||
public MogoNaviConfig avoidSpeed( boolean avoidSpeed ) {
|
||||
this.avoidSpeed = avoidSpeed;
|
||||
this.highSpeed = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 避免收费
|
||||
*/
|
||||
public MogoNaviConfig cost( boolean cost ) {
|
||||
this.cost = cost;
|
||||
this.highSpeed = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速优先
|
||||
*/
|
||||
public MogoNaviConfig highSpeed( boolean highSpeed ) {
|
||||
this.highSpeed = highSpeed;
|
||||
this.avoidSpeed = false;
|
||||
this.cost = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否多路线算路
|
||||
*/
|
||||
public MogoNaviConfig multipleRoute( boolean multipleRoute ) {
|
||||
this.multipleRoute = multipleRoute;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航模式
|
||||
*
|
||||
* @param realNavi true - 正式导航, false - 模拟导航
|
||||
* @return
|
||||
*/
|
||||
public MogoNaviConfig realNavi( boolean realNavi ) {
|
||||
this.realNavi = realNavi;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCongestion() {
|
||||
return congestion;
|
||||
}
|
||||
|
||||
public boolean isAvoidSpeed() {
|
||||
return avoidSpeed;
|
||||
}
|
||||
|
||||
public boolean isCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public boolean isHighSpeed() {
|
||||
return highSpeed;
|
||||
}
|
||||
|
||||
public boolean isMultipleRoute() {
|
||||
return multipleRoute;
|
||||
}
|
||||
|
||||
public boolean isRealNavi() {
|
||||
return realNavi;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 导航引导信息
|
||||
*/
|
||||
public class MogoNaviInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* 当前路线名称
|
||||
*/
|
||||
private String currentRoadName;
|
||||
|
||||
/**
|
||||
* 导航过程中当前的车速
|
||||
*/
|
||||
private int currentSpeed;
|
||||
|
||||
/**
|
||||
* 当前路段剩余距离
|
||||
*/
|
||||
private int curStepRetainDistance;
|
||||
|
||||
/**
|
||||
* 当前路段剩余时间
|
||||
*/
|
||||
private int curStepRetainTime;
|
||||
|
||||
/**
|
||||
* 导航转向图标
|
||||
*/
|
||||
private int iconType;
|
||||
|
||||
/**
|
||||
* 下条路名
|
||||
*/
|
||||
private String nextRoadName;
|
||||
|
||||
/**
|
||||
* 剩余时间(秒)
|
||||
*/
|
||||
private int pathRetainTime;
|
||||
|
||||
/**
|
||||
* 剩余距离
|
||||
*/
|
||||
private int pathRetainDistance;
|
||||
|
||||
public String getCurrentRoadName() {
|
||||
return currentRoadName;
|
||||
}
|
||||
|
||||
public void setCurrentRoadName( String currentRoadName ) {
|
||||
this.currentRoadName = currentRoadName;
|
||||
}
|
||||
|
||||
public int getCurrentSpeed() {
|
||||
return currentSpeed;
|
||||
}
|
||||
|
||||
public void setCurrentSpeed( int currentSpeed ) {
|
||||
this.currentSpeed = currentSpeed;
|
||||
}
|
||||
|
||||
public int getCurStepRetainDistance() {
|
||||
return curStepRetainDistance;
|
||||
}
|
||||
|
||||
public void setCurStepRetainDistance( int curStepRetainDistance ) {
|
||||
this.curStepRetainDistance = curStepRetainDistance;
|
||||
}
|
||||
|
||||
public int getCurStepRetainTime() {
|
||||
return curStepRetainTime;
|
||||
}
|
||||
|
||||
public void setCurStepRetainTime( int curStepRetainTime ) {
|
||||
this.curStepRetainTime = curStepRetainTime;
|
||||
}
|
||||
|
||||
public int getIconType() {
|
||||
return iconType;
|
||||
}
|
||||
|
||||
public void setIconType( int iconType ) {
|
||||
this.iconType = iconType;
|
||||
}
|
||||
|
||||
public String getNextRoadName() {
|
||||
return nextRoadName;
|
||||
}
|
||||
|
||||
public void setNextRoadName( String nextRoadName ) {
|
||||
this.nextRoadName = nextRoadName;
|
||||
}
|
||||
|
||||
public int getPathRetainTime() {
|
||||
return pathRetainTime;
|
||||
}
|
||||
|
||||
public void setPathRetainTime( int pathRetainTime ) {
|
||||
this.pathRetainTime = pathRetainTime;
|
||||
}
|
||||
|
||||
public int getPathRetainDistance() {
|
||||
return pathRetainDistance;
|
||||
}
|
||||
|
||||
public void setPathRetainDistance( int pathRetainDistance ) {
|
||||
this.pathRetainDistance = pathRetainDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.currentRoadName );
|
||||
dest.writeInt( this.currentSpeed );
|
||||
dest.writeInt( this.curStepRetainDistance );
|
||||
dest.writeInt( this.curStepRetainTime );
|
||||
dest.writeInt( this.iconType );
|
||||
dest.writeString( this.nextRoadName );
|
||||
dest.writeInt( this.pathRetainTime );
|
||||
dest.writeInt( this.pathRetainDistance );
|
||||
}
|
||||
|
||||
public MogoNaviInfo() {
|
||||
}
|
||||
|
||||
protected MogoNaviInfo( Parcel in ) {
|
||||
this.currentRoadName = in.readString();
|
||||
this.currentSpeed = in.readInt();
|
||||
this.curStepRetainDistance = in.readInt();
|
||||
this.curStepRetainTime = in.readInt();
|
||||
this.iconType = in.readInt();
|
||||
this.nextRoadName = in.readString();
|
||||
this.pathRetainTime = in.readInt();
|
||||
this.pathRetainDistance = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< MogoNaviInfo > CREATOR = new Parcelable.Creator< MogoNaviInfo >() {
|
||||
@Override
|
||||
public MogoNaviInfo createFromParcel( Parcel source ) {
|
||||
return new MogoNaviInfo( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoNaviInfo[] newArray( int size ) {
|
||||
return new MogoNaviInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 地图监听注册管理
|
||||
*/
|
||||
public class MogoNaviListenerHandler implements IMogoNaviListener, IMogoNaviListenerRegister {
|
||||
|
||||
private static volatile MogoNaviListenerHandler sInstance;
|
||||
|
||||
private MogoNaviListenerHandler() {
|
||||
}
|
||||
|
||||
public static MogoNaviListenerHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoNaviListenerHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoNaviListenerHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上层模块代理对象
|
||||
*/
|
||||
private IMogoNaviListener mDelegateListener = null;
|
||||
|
||||
@Override
|
||||
public void registerHostNaviListener( IMogoNaviListener listener ) {
|
||||
mDelegateListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterHostNaviListener() {
|
||||
mDelegateListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onInitNaviFailure() {
|
||||
if ( mDelegateListener != null ) {
|
||||
mDelegateListener.onInitNaviFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onInitNaviSuccess() {
|
||||
if ( mDelegateListener != null ) {
|
||||
mDelegateListener.onInitNaviSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
mDelegateListener.onNaviInfoUpdate( naviinfo );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onStartNavi() {
|
||||
if ( mDelegateListener != null ) {
|
||||
mDelegateListener.onStartNavi();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onStopNavi() {
|
||||
if ( mDelegateListener != null ) {
|
||||
mDelegateListener.onStopNavi();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user