This commit is contained in:
wangcongtao
2020-06-05 12:19:13 +08:00
parent 075ca7d3a9
commit 44ec5cdcfe
15 changed files with 317 additions and 79 deletions

View File

@@ -6,6 +6,7 @@ import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
@@ -46,14 +47,17 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
}
public void notifyXiaozhi( MogoNaviInfo naviinfo ) {
// Intent intent = new Intent( ACTION_NAV_SEND );
// intent.putExtra( "KEY_TYPE", 10001 );
// intent.putExtra( "NEXT_ROAD_NAME", naviinfo.getNextRoadName() );
// intent.putExtra( "ROUTE_REMAIN_TIME_AUTO", naviinfo.getVoiceRetainTime() );
// intent.putExtra( "ROUTE_REMAIN_DIS_AUTO", naviinfo.getVoiceRetainDistance() );
// intent.putExtra( "ICON", naviinfo.getIconResId() );
// mContext.sendBroadcast( intent );
// Log.v( "MapBroadCastHelper", "action=" + ACTION_NAV_SEND + " NaviInfo" );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
Intent intent = new Intent( ACTION_NAV_SEND );
intent.putExtra( "KEY_TYPE", 10001 );
intent.putExtra( "NEXT_ROAD_NAME", naviinfo.getNextRoadName() );
intent.putExtra( "ROUTE_REMAIN_TIME_AUTO", naviinfo.getVoiceRetainTime() );
intent.putExtra( "ROUTE_REMAIN_DIS_AUTO", naviinfo.getVoiceRetainDistance() );
intent.putExtra( "ICON", naviinfo.getIconResId() );
mContext.sendBroadcast( intent );
Log.v( "MapBroadCastHelper", "action=" + ACTION_NAV_SEND + " NaviInfo" );
}
@@ -67,30 +71,30 @@ public class MapBroadCastHelper implements IMogoStatusChangedListener {
}
public void mapFrount() {
// notifyXizhiNavStatus( STATUS_NAV_FRONT );
notifyXizhiNavStatus( STATUS_NAV_FRONT );
}
public void mapBackground() {
// notifyXizhiNavStatus( STATUS_NAV_BACKGROUND );
notifyXizhiNavStatus( STATUS_NAV_BACKGROUND );
}
public void startNavi() {
// notifyXizhiNavStatus( STATUS_NAV_START );
notifyXizhiNavStatus( STATUS_NAV_START );
}
public void stopNavi() {
// notifyXizhiNavStatus( STATUS_NAV_STOP );
notifyXizhiNavStatus( STATUS_NAV_STOP );
}
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.AI_ASSIST_READY ) {
if ( isTrue ) {
// if ( AppUtils.isApplicationBroughtToBackground( mContext ) ) {
// mapBackground();
// } else {
// mapFrount();
// }
if ( AppUtils.isApplicationBroughtToBackground( mContext ) ) {
mapBackground();
} else {
mapFrount();
}
}
}
}

View File

@@ -23,6 +23,7 @@ import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.module.common.map.CustomNaviInterrupter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.intent.IMogoIntentListener;
@@ -116,10 +117,13 @@ public class MapPresenter extends Presenter< MapView > implements
onChangeDayNightMode( day_night_mode );
//继续导航
} else if ( key_type == 10049 ) {
// boolean extra_endurance_data = intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
// if ( extra_endurance_data ) {
// onContinueNavigation();
// }
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
boolean extra_endurance_data = intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
if ( extra_endurance_data ) {
onContinueNavigation();
}
} else if ( key_type == 10006 ) {
// 避免冲突,会同时发送两个广播,这里不操作。
//int extra_is_show = intent.getIntExtra( "EXTRA_IS_SHOW", 0 );
@@ -131,12 +135,21 @@ public class MapPresenter extends Presenter< MapView > implements
} else if ( key_type == 10005 ) {
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
} else if ( key_type == 20009 ) {
// onOpenNavi();
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
onOpenNavi();
} else if ( key_type == 10038 || key_type == 10007 ) {
// mLauncher.backToLauncher( getContext() );
// onChoosePath( intent, key_type );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
mLauncher.backToLauncher( getContext() );
onChoosePath( intent, key_type );
} else if ( key_type == 10021 ) {
// onStopNaviInternal();
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
onStopNaviInternal();
} else if ( key_type == 10005 ) {
// 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
// 避免收费 | 1
@@ -149,12 +162,15 @@ public class MapPresenter extends Presenter< MapView > implements
// 不走高速躲避收费和拥堵 | 8
// 高速优先 | 20
// 躲避拥堵且高速优先 | 24
// int prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", 0 );
// MogoNaviConfig config = new MogoNaviConfig().congestion( prefer == 4 )
// .cost( prefer == 1 || prefer == 7 )
// .highSpeed( prefer == 20 )
// .avoidSpeed( prefer == 3 );
// mMogoMapService.getNavi( getContext() ).reCalculateRoute( config );
if ( CustomNaviInterrupter.getInstance().interrupt() ) {
return;
}
int prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", 0 );
MogoNaviConfig config = new MogoNaviConfig().congestion( prefer == 4 )
.cost( prefer == 1 || prefer == 7 )
.highSpeed( prefer == 20 )
.avoidSpeed( prefer == 3 );
mMogoMapService.getNavi( getContext() ).reCalculateRoute( config );
}
}
@@ -279,16 +295,18 @@ public class MapPresenter extends Presenter< MapView > implements
private void zoomMap( boolean zoomIn ) {
boolean isLocked = mMogoMapService.getMapUIController().isCarLocked();
MapControlResult result = mView.getUIController().changeZoom( zoomIn );
// if ( result == MapControlResult.TARGET ) {
// UiThreadHandler.postDelayed( () -> {
// if ( zoomIn ) {
// AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最大", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
// } else {
// AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最小", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
// }
// }, 1_000L ); // 避免小智障播放完毕之前播报
// return;
// }
if (! CustomNaviInterrupter.getInstance().interrupt() ) {
if ( result == MapControlResult.TARGET ) {
UiThreadHandler.postDelayed( () -> {
if ( zoomIn ) {
AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最大", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
} else {
AIAssist.getInstance( getContext() ).speakTTSVoice( "地图已是最小", VoicePreemptType.PREEMPT_TYPE_NEXT, null );
}
}, 1_000L ); // 避免小智障播放完毕之前播报
return;
}
}
if ( isLocked ) {
// 保持锁车状态
UiThreadHandler.postDelayed( () -> {