dev
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package com.mogo.module.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.AppUtils;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-17.
|
||||
*/
|
||||
public class MapBroadCastHelper implements IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "MapBroadCastHelper";
|
||||
|
||||
private static volatile MapBroadCastHelper sInstance;
|
||||
private static final String ACTION_NAV_SEND = "AUTONAVI_STANDARD_BROADCAST_SEND";
|
||||
private static final int STATUS_NAV_FRONT = 3;
|
||||
private static final int STATUS_NAV_BACKGROUND = 4;
|
||||
private static final int STATUS_NAV_START = 8;
|
||||
private static final int STATUS_NAV_STOP = 9;
|
||||
private Context mContext;
|
||||
|
||||
private MapBroadCastHelper( Context context ) {
|
||||
this.mContext = context;
|
||||
IMogoServiceApis api = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context );
|
||||
api.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.AI_ASSIST_READY, this );
|
||||
}
|
||||
|
||||
public static MapBroadCastHelper getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MapBroadCastHelper.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MapBroadCastHelper( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
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" );
|
||||
}
|
||||
|
||||
|
||||
public void notifyXizhiNavStatus( int status ) {
|
||||
Intent intent = new Intent( ACTION_NAV_SEND );
|
||||
intent.putExtra( "KEY_TYPE", 10019 );
|
||||
intent.putExtra( "EXTRA_STATE", status );
|
||||
intent.putExtra( "SOURCE_APP", mContext.getPackageName() );
|
||||
mContext.sendBroadcast( intent );
|
||||
Log.v( "MapBroadCastHelper", "NavStatus=" + status );
|
||||
}
|
||||
|
||||
public void mapFrount() {
|
||||
notifyXizhiNavStatus( STATUS_NAV_FRONT );
|
||||
}
|
||||
|
||||
public void mapBackground() {
|
||||
notifyXizhiNavStatus( STATUS_NAV_BACKGROUND );
|
||||
}
|
||||
|
||||
public void startNavi() {
|
||||
notifyXizhiNavStatus( STATUS_NAV_START );
|
||||
}
|
||||
|
||||
public void stopNavi() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,7 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
if ( mMogoMapView != null ) {
|
||||
mMogoMapView.onPause();
|
||||
}
|
||||
MapBroadCastHelper.getInstance( getContext() ).mapBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,6 +90,7 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
if ( mMogoMapView != null ) {
|
||||
mMogoMapView.onResume();
|
||||
}
|
||||
MapBroadCastHelper.getInstance( getContext() ).mapFrount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,9 @@ import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.commons.voice.VoicePreemptType;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener2;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.MapControlResult;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
@@ -23,12 +26,15 @@ import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
@@ -44,7 +50,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class MapPresenter extends Presenter< MapView > implements
|
||||
IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack {
|
||||
IMogoVoiceCmdCallBack,
|
||||
IMogoNaviListener2 {
|
||||
|
||||
private static final String TAG = "MapPresenter";
|
||||
private static final String AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV";
|
||||
@@ -53,12 +60,15 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
private IMogoSearchManager mSearchManager;
|
||||
private IMogoRefreshStrategyController mRefreshStrategyController;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoRegisterCenter mRegisterCenter;
|
||||
private IMogoLauncher mLauncher;
|
||||
|
||||
public MapPresenter( MapView view ) {
|
||||
super( view );
|
||||
initBroadcast();
|
||||
}
|
||||
private BroadcastReceiver broadcastReceiver;
|
||||
|
||||
private BroadcastReceiver broadcastReceiver;
|
||||
|
||||
/**
|
||||
* opera type为0:0 实时路况开;1实时路况关 type为1:0 放大地图; 1缩小地图 type为2:0切换2d车上; 1切换2d北上;2切换3d车上支持
|
||||
@@ -116,17 +126,17 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
boolean extra_endurance_data =
|
||||
intent.getBooleanExtra( "EXTRA_ENDURANCE_DATA", false );
|
||||
if ( extra_endurance_data ) {
|
||||
mView.getUIController().recoverLockMode();
|
||||
onContinueNavigation();
|
||||
}
|
||||
} else if ( key_type == 10006 ) {
|
||||
|
||||
int extra_is_show = intent.getIntExtra( "EXTRA_IS_SHOW", 0 );
|
||||
|
||||
if (extra_is_show == 0) {
|
||||
if ( extra_is_show == 0 ) {
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mView.getUIController().displayOverview();
|
||||
} else {
|
||||
mView.getUIController().recoverLockMode();
|
||||
onContinueNavigation();
|
||||
}
|
||||
} else if ( key_type == 10005 ) {
|
||||
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
|
||||
@@ -160,6 +170,24 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
getContext().registerReceiver( broadcastReceiver, inputFilter );
|
||||
}
|
||||
|
||||
/**
|
||||
* 继续导航
|
||||
*/
|
||||
private void onContinueNavigation(){
|
||||
if ( mStatusManager.isMainPageOnResume() ) {
|
||||
mView.getUIController().recoverLockMode();
|
||||
} else {
|
||||
mLauncher.backToLauncher( getContext() );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
try {
|
||||
mView.getUIController().recoverLockMode();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 2_000L );
|
||||
}
|
||||
}
|
||||
|
||||
private void zoomMap( boolean zoomIn ) {
|
||||
boolean isLocked = mMogoMapService.getMapUIController().isCarLocked();
|
||||
MapControlResult result = mView.getUIController().changeZoom( zoomIn );
|
||||
@@ -195,6 +223,9 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
mSearchManager = apis.getSearchManagerApi();
|
||||
mRefreshStrategyController = apis.getRefreshStrategyControllerApi();
|
||||
mStatusManager = apis.getStatusManagerApi();
|
||||
mRegisterCenter = apis.getRegisterCenterApi();
|
||||
mRegisterCenter.registerMogoNaviListener( TAG, this );
|
||||
mLauncher = apis.getLauncherApi();
|
||||
|
||||
IMogoNavi mogoNavi = mMogoMapService.getNavi( getContext() );
|
||||
mogoNavi.setCalculatePathDisplayBounds( new Rect(
|
||||
@@ -217,10 +248,11 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
unregisterVoiceCmd();
|
||||
}
|
||||
|
||||
@Override public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
if (broadcastReceiver != null) {
|
||||
getContext().unregisterReceiver(broadcastReceiver);
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
if ( broadcastReceiver != null ) {
|
||||
getContext().unregisterReceiver( broadcastReceiver );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +362,7 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
mView.getUIController().displayOverview();
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE:
|
||||
mView.getUIController().recoverLockMode();
|
||||
onContinueNavigation();
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_CAR_UP_MODE_UN_WAKEUP:
|
||||
case VoiceConstants.CMD_MAP_CAR_UP_MODE:
|
||||
@@ -383,4 +415,54 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveDestination() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndEmulatorNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
MapBroadCastHelper.getInstance( getContext() ).notifyXiaozhi( naviinfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
MapBroadCastHelper.getInstance( getContext() ).startNavi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
MapBroadCastHelper.getInstance( getContext() ).stopNavi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic( MogoTraffic traffic ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user