@@ -4,12 +4,6 @@ import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.location.Location;
|
||||
|
||||
//import com.amap.api.maps.LocationSource;
|
||||
//import com.amap.api.maps.model.Polyline;
|
||||
//import com.amap.api.navi.AMapNavi;
|
||||
//import com.amap.api.navi.enums.AimLessMode;
|
||||
//import com.amap.api.navi.enums.NaviType;
|
||||
//import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.impl.custom.AMapWrapper;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
@@ -20,7 +14,6 @@ import com.mogo.map.navi.MogoNaviConfig;
|
||||
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,10 +35,6 @@ public class NaviClient implements IMogoNavi {
|
||||
private final Context mContext;
|
||||
|
||||
private MapAutoViewHelper mAMapNavi;
|
||||
// private final NaviListenerAdapter mAMapNaviListener;
|
||||
|
||||
|
||||
// private final AimlessModeListenerAdapter mAimlessModeListener;
|
||||
|
||||
/**
|
||||
* 导航策略配置
|
||||
@@ -67,26 +56,18 @@ public class NaviClient implements IMogoNavi {
|
||||
*/
|
||||
private boolean mAimlessStatus;
|
||||
|
||||
private NaviClient( Context context ) {
|
||||
private NaviClient(Context context) {
|
||||
mCarLocation.setLongitude(116.97000);
|
||||
mCarLocation.setLatitude(39.97000);
|
||||
mContext = context;
|
||||
mAMapNavi = AMapWrapper.getAMap();
|
||||
// mAMapNavi.setEmulatorNaviSpeed( 120 );
|
||||
// mAMapNavi.setUseInnerVoice( false, true );
|
||||
// mAMapNaviListener = new NaviListenerAdapter( context, mAMapNavi, this );
|
||||
// mAimlessModeListener = new AimlessModeListenerAdapter() {
|
||||
// };
|
||||
// mAMapNavi.addAMapNaviListener( mAMapNaviListener );
|
||||
// mAMapNavi.addAimlessModeListener( mAimlessModeListener );
|
||||
// mAimlessModeStatus = SharedPrefsMgr.getInstance( mContext ).getBoolean( KEY_AIMLESS_STATUS, false );
|
||||
}
|
||||
|
||||
public static NaviClient getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( NaviClient.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new NaviClient( context );
|
||||
public static NaviClient getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (NaviClient.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new NaviClient(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,134 +79,83 @@ public class NaviClient implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint ) {
|
||||
naviTo( endPoint, mMogoNaviConfig );
|
||||
public void naviTo(MogoLatLng endPoint) {
|
||||
naviTo(endPoint, mMogoNaviConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) {
|
||||
naviTo( endPoint, null, config );
|
||||
public void naviTo(MogoLatLng endPoint, MogoNaviConfig config) {
|
||||
naviTo(endPoint, null, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) {
|
||||
naviTo( endPoint, wayPoints, mMogoNaviConfig );
|
||||
public void naviTo(MogoLatLng endPoint, List<MogoLatLng> wayPoints) {
|
||||
naviTo(endPoint, wayPoints, mMogoNaviConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) {
|
||||
if ( !checkAMapNavi() ) {
|
||||
public void naviTo(MogoLatLng endPoint, List<MogoLatLng> wayPoints, MogoNaviConfig config) {
|
||||
if (!checkAMapNavi()) {
|
||||
return;
|
||||
}
|
||||
Logger.i( TAG, "开始规划路径" );
|
||||
Logger.i(TAG, "开始规划路径");
|
||||
mMogoNaviConfig = config;
|
||||
if ( mMogoNaviConfig == null ) {
|
||||
if (mMogoNaviConfig == null) {
|
||||
mMogoNaviConfig = new MogoNaviConfig();
|
||||
}
|
||||
// int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() );
|
||||
// List< NaviLatLng > naviWayPoints = null;
|
||||
// if ( wayPoints != null && !wayPoints.isEmpty() ) {
|
||||
// naviWayPoints = new ArrayList<>( wayPoints.size() );
|
||||
// for ( MogoLatLng wayPoint : wayPoints ) {
|
||||
// naviWayPoints.add( ObjectUtils.fromMogoAsNavi( wayPoint ) );
|
||||
// }
|
||||
// } else {
|
||||
// naviWayPoints = new ArrayList<>();
|
||||
// }
|
||||
// mAMapNavi.calculateDriveRoute(
|
||||
// new ArrayList( Arrays.asList( ObjectUtils.fromMogoAsNavi( endPoint ) ) ),
|
||||
// naviWayPoints,
|
||||
// strategy
|
||||
// );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reCalculateRoute( MogoNaviConfig config ) {
|
||||
if ( !checkAMapNavi() ) {
|
||||
public void reCalculateRoute(MogoNaviConfig config) {
|
||||
if (!checkAMapNavi()) {
|
||||
return;
|
||||
}
|
||||
mMogoNaviConfig = config;
|
||||
if ( mMogoNaviConfig == null ) {
|
||||
if (mMogoNaviConfig == null) {
|
||||
mMogoNaviConfig = new MogoNaviConfig();
|
||||
}
|
||||
// int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() );
|
||||
// mAMapNavi.reCalculateRoute( strategy );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopNavi() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// mAMapNaviListener.stopNavi();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startNavi( boolean isRealNavi ) {
|
||||
// if ( mAMapNaviListener.isStopped() ) {
|
||||
// return;
|
||||
// }
|
||||
// mIsRealNavi = isRealNavi;
|
||||
// stopAimlessMode();
|
||||
// boolean isNaving = isNaviing();
|
||||
// boolean result = mAMapNavi.startNavi( isRealNavi ? NaviType.GPS : NaviType.EMULATOR );
|
||||
// if ( isNaving && !result ) {
|
||||
// // 如果正在导航,又重新规划路线,startNavi 不会成功,不会重新回调 #onStartNavi
|
||||
// MogoNaviListenerHandler.getInstance().onStartNavi();
|
||||
// AMapMessageManager.getInstance().postNaviStarted();
|
||||
// }
|
||||
// Logger.d( TAG, "start navi status: %s", result );
|
||||
public void startNavi(boolean isRealNavi) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaviing() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// return mAMapNaviListener.isNaviing();
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoCalculatePath > getCalculatedStrategies() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// return mAMapNaviListener.getCalculateStrategies();
|
||||
// }
|
||||
public List<MogoCalculatePath> getCalculatedStrategies() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoLatLng > getCalculatedPathPos() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// return mAMapNaviListener.getCalculatedPathPos();
|
||||
// }
|
||||
public List<MogoLatLng> getCalculatedPathPos() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// return mAMapNaviListener.getItemClickInteraction();
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction lineClickInteraction ) {
|
||||
// do not impl.
|
||||
public void setLineClickInteraction(OnCalculatePathItemClickInteraction lineClickInteraction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCalculatePaths() {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// mAMapNaviListener.clearCalculatePaths();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCalculatePathDisplayBounds( Rect bounds ) {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// mAMapNaviListener.setCalculatePathDisplayBounds( bounds );
|
||||
// }
|
||||
public void setCalculatePathDisplayBounds(Rect bounds) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,20 +164,20 @@ public class NaviClient implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBroadcastMode( int mode ) {
|
||||
return false;//mAMapNavi.setBroadcastMode( mode );
|
||||
public boolean setBroadcastMode(int mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoLatLng > getNaviPathCoordinates() {
|
||||
public List<MogoLatLng> getNaviPathCoordinates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCarLocation() {
|
||||
if ( mCarLocation != null ) {
|
||||
synchronized ( mCarLocation ) {
|
||||
return new MogoLatLng( mCarLocation.getLatitude(), mCarLocation.getLongitude() );
|
||||
if (mCarLocation != null) {
|
||||
synchronized (mCarLocation) {
|
||||
return new MogoLatLng(mCarLocation.getLatitude(), mCarLocation.getLongitude());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -259,100 +189,76 @@ public class NaviClient implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener ) {
|
||||
public void registerCarLocationChangedListener(IMogoCarLocationChangedListener2 listener) {
|
||||
// do not impl.
|
||||
}
|
||||
|
||||
// -- end
|
||||
|
||||
public void syncCarLocation( Location location ) {
|
||||
public void syncCarLocation(Location location) {
|
||||
mCarLocation = location;
|
||||
if ( MogoCarLocationChangedListenerRegister.getInstance().getListener() != null ) {
|
||||
MogoCarLocationChangedListenerRegister.getInstance().getListener().onCarLocationChanged2( location );
|
||||
if (MogoCarLocationChangedListenerRegister.getInstance().getListener() != null) {
|
||||
MogoCarLocationChangedListenerRegister.getInstance().getListener().onCarLocationChanged2(location);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAMapNavi() {
|
||||
mAMapNavi = AMapWrapper.getAMap();
|
||||
if ( mAMapNavi == null ) {
|
||||
Logger.e( TAG, "自研导航实例为空!!!" );
|
||||
if (mAMapNavi == null) {
|
||||
Logger.e(TAG, "自研导航实例为空!!!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isRealNavi() {
|
||||
return mIsRealNavi;
|
||||
}
|
||||
|
||||
public void handleClickedPolyline( Polyline polyline ) {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// mAMapNaviListener.handleClickedPolyline( polyline );
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAimlessMode() {
|
||||
// if ( mAimlessModeStatus && !isNaviing() ) {
|
||||
// mAMapNavi.startAimlessMode( AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED );
|
||||
// mAimlessStatus = true;
|
||||
// Logger.d( TAG, "开启巡航成功" );
|
||||
// } else {
|
||||
// mAimlessStatus = false;
|
||||
// Logger.d( TAG, "开启巡航失败" );
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopAimlessMode() {
|
||||
// mAMapNavi.stopAimlessMode();
|
||||
// mAimlessStatus = false;
|
||||
// Logger.d( TAG, "关闭巡航成功" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAimlessModeStatus( boolean open ) {
|
||||
public void setAimlessModeStatus(boolean open) {
|
||||
this.mAimlessModeStatus = open;
|
||||
SharedPrefsMgr.getInstance( mContext ).putBoolean( KEY_AIMLESS_STATUS, open );
|
||||
if ( open ) {
|
||||
if ( !mAimlessStatus ) {
|
||||
SharedPrefsMgr.getInstance(mContext).putBoolean(KEY_AIMLESS_STATUS, open);
|
||||
if (open) {
|
||||
if (!mAimlessStatus) {
|
||||
startAimlessMode();
|
||||
}
|
||||
} else {
|
||||
if ( mAimlessStatus ) {
|
||||
if (mAimlessStatus) {
|
||||
stopAimlessMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview( Rect bounds ) {
|
||||
// if ( mAMapNaviListener != null ) {
|
||||
// mAMapNaviListener.displayOverview( bounds );
|
||||
// }
|
||||
public void displayOverview(Rect bounds) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseExtraGPSData( boolean use ) {
|
||||
Logger.d( TAG, "设置外部gps源状态 %s", use );
|
||||
mAMapNavi.setIsUseExtraGPSData( use );
|
||||
AMapWrapper.getAMap().setMyLocationEnabled( true );
|
||||
public void setUseExtraGPSData(boolean use) {
|
||||
Logger.d(TAG, "设置外部gps源状态 %s", use);
|
||||
mAMapNavi.setIsUseExtraGPSData(use);
|
||||
AMapWrapper.getAMap().setMyLocationEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtraGPSData( double lon, double lat, float speed, float accuracy, float bearing, long timestamp ) {
|
||||
if ( !mAMapNavi.getIsUseExtraGPSData() ) {
|
||||
Logger.d( TAG, "拒绝外部GPS数据" );
|
||||
public void setExtraGPSData(double lon, double lat, float speed, float accuracy, float bearing, long timestamp) {
|
||||
if (!mAMapNavi.getIsUseExtraGPSData()) {
|
||||
Logger.d(TAG, "拒绝外部GPS数据");
|
||||
return;
|
||||
}
|
||||
Location location = new Location( "外部GPS源" );
|
||||
location.setLongitude( lon );
|
||||
location.setLatitude( lat );
|
||||
location.setSpeed( speed );
|
||||
location.setAccuracy( accuracy );
|
||||
location.setBearing( bearing );
|
||||
location.setTime( timestamp );
|
||||
Location location = new Location("外部GPS源");
|
||||
location.setLongitude(lon);
|
||||
location.setLatitude(lat);
|
||||
location.setSpeed(speed);
|
||||
location.setAccuracy(accuracy);
|
||||
location.setBearing(bearing);
|
||||
location.setTime(timestamp);
|
||||
//type字段传1时代表WGS84坐标
|
||||
mAMapNavi.setExtraGPSData( 2, location );
|
||||
mAMapNavi.setExtraGPSData(2, location);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user