This commit is contained in:
wangcongtao
2020-04-29 16:22:51 +08:00
parent 0e5b7c5788
commit 25730077a6
5 changed files with 122 additions and 161 deletions

2
.idea/misc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -271,7 +271,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
@Override
public void onIntentReceived( String intentStr, Intent intent ) {
int key_type = intent.getIntExtra( "KEY_TYPE", 0 );
int type = intent.getIntExtra( "EXTRA_TYPE", -1 );
int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 );
if ( key_type == 10027 ) {

View File

@@ -15,8 +15,10 @@ import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.commons.voice.VoicePreemptType;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.navi.IMogoNaviListener2;
import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.uicontroller.EnumMapUI;
@@ -80,81 +82,68 @@ public class MapPresenter extends Presenter< MapView > implements
public void onReceive( Context context, Intent intent ) {
String action = intent.getAction();
Logger.d( TAG, "action = %s", action );
if ( TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) {
int key_type = intent.getIntExtra( "KEY_TYPE", 0 );
int type = intent.getIntExtra( "EXTRA_TYPE", -1 );
int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 );
Logger.d( "NaviManager", "key_type" + key_type );
if ( key_type == 10027 ) {
if ( type == 0 ) {
mView.getUIController().setTrafficEnabled( opera_type == 0 );
} else if ( type == 1 ) {
zoomMap( opera_type == 0 );
} else if ( type == 2 ) {
mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent );
if ( opera_type == 0 ) {
mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
} else if ( opera_type == 1 ) {
mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
} else if ( opera_type == 2 ) {
mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
}
}
} else if ( key_type == 10048 ) {
//* @param type 0:自动; 1白天; 2黑夜
int day_night_mode = intent.getIntExtra( "EXTRA_DAY_NIGHT_MODE", -1 );
if ( day_night_mode == 0 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night );
} else if ( day_night_mode == 1 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
} else if ( day_night_mode == 2 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
}
//intent.setAction("AUTONAVI_STANDARD_BROADCAST_RECV");
//intent.putExtra("KEY_TYPE", 10049);
//intent.putExtra("EXTRA_ENDURANCE_DATA", continueNavi);
//继续导航
} else if ( key_type == 10049 ) {
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 );
// if ( extra_is_show == 0 ) {
// onDisplayOverview();
// } else {
// onContinueNavigation();
// }
} else if ( key_type == 10005 ) {
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
} else if ( key_type == 20009 ) {
onOpenNavi();
if ( !TextUtils.equals( action, AUTONAVI_STANDARD_BROADCAST_RECV ) ) {
return;
}
int key_type = intent.getIntExtra( "KEY_TYPE", 0 );
int type = intent.getIntExtra( "EXTRA_TYPE", -1 );
int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 );
Logger.d( TAG, "key_type" + key_type );
if ( key_type == 10027 ) {
if ( type == 0 ) {
onChangeTrafficMode( opera_type );
} else if ( type == 1 ) {
zoomMap( opera_type == 0 );
} else if ( type == 2 ) {
mMogoIntentManager.invoke( AUTONAVI_STANDARD_BROADCAST_RECV, intent );
onChangeCameraMode( opera_type );
}
///**
// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
// * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6`
// * `躲避收费和拥堵` |`7` `不走高速躲避收费和拥堵` |`8` `高速优先` |`20` `躲避拥堵且高速优先` |`24`
// *
// * @param context
// * @param type
// */
//public static void setUserPreference(Context context, int type) {
// Intent intent = new Intent();
// intent.setAction("AUTONAVI_STANDARD_BROADCAST_RECV");
// intent.putExtra("KEY_TYPE", 10005);
// intent.putExtra("NAVI_ROUTE_PREFER", type);
// context.sendBroadcast(intent);
} else if ( key_type == 10048 ) {
//0自动; 1白天; 2黑夜;
int day_night_mode = intent.getIntExtra( "EXTRA_DAY_NIGHT_MODE", -1 );
onChangeDayNightMode( day_night_mode );
//继续导航
} else if ( key_type == 10049 ) {
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 );
//if ( extra_is_show == 0 ) {
// onDisplayOverview();
//} else {
// onContinueNavigation();
//}
//
} else if ( key_type == 10005 ) {
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
} else if ( key_type == 20009 ) {
onOpenNavi();
} else if ( key_type == 10038 || key_type == 10007 ) {
mLauncher.backToLauncher( getContext() );
onChoosePath( intent, key_type );
} else if ( key_type == 10021 ) {
onStopNaviInternal();
} else if ( key_type == 10005 ) {
// 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
// 避免收费 | 1
// 多策略算路 | 2
// 不走高速 | 3
// 躲避拥堵 | 4
// 不走高速且避免收费 | 5
// 不走高速且躲避拥堵 | 6
// 躲避收费和拥堵 | 7
// 不走高速躲避收费和拥堵 | 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 );
}
}
@@ -165,6 +154,66 @@ public class MapPresenter extends Presenter< MapView > implements
getContext().registerReceiver( broadcastReceiver, inputFilter );
}
/**
* 切换交通态势模式
*
* @param mode
*/
private void onChangeTrafficMode( int mode ) {
mView.getUIController().setTrafficEnabled( mode == 0 );
}
/**
* 切换地图视图朝向模式
*/
private void onChangeCameraMode( int mode ) {
if ( mode == 0 ) {
mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
} else if ( mode == 1 ) {
mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
} else if ( mode == 2 ) {
mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
}
}
/**
* 切换白天黑夜模式
*
* @param mode
*/
private void onChangeDayNightMode( int mode ) {
if ( mode == 0 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night );
} else if ( mode == 1 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
} else if ( mode == 2 ) {
mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
}
}
private void onStopNaviInternal() {
mMogoMapService.getNavi( getContext() ).stopNavi();
}
/**
* 唤醒指令导航去哪里
*/
private void onChoosePath( Intent intent, int type ) {
double lat;
double lon;
if ( type == 10007 ) {
lat = intent.getDoubleExtra( "ENTRY_LAT", 0.0 );
lon = intent.getDoubleExtra( "ENTRY_LON", 0.0 );
} else {
lat = intent.getDoubleExtra( "LAT", 0.0 );
lon = intent.getDoubleExtra( "LON", 0.0 );
}
mMogoAddressManager.calculatePath( new MogoLatLng( lat, lon ) );
}
/**
* 继续导航
*/

View File

@@ -46,6 +46,5 @@ public class MogoAddressManager implements IMogoAddressManager {
AddressManager.INSTANCE.init(context);
SearchServiceHolder.INSTANCE.init(context);
SettingManager.INSTANCE.init(context);
NaviManager.INSTANCE.init(context);
}
}

View File

@@ -1,86 +0,0 @@
package com.mogo.module.navi.manager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.text.TextUtils
import com.mogo.map.MogoLatLng
import com.mogo.map.navi.MogoNaviConfig
import com.mogo.module.common.MogoModulePaths
import com.mogo.module.navi.constants.SearchServiceHolder
import com.mogo.module.navi.ui.search.ChoosePathFragment
import com.mogo.module.navi.ui.search.SearchFragment
import com.mogo.service.fragmentmanager.FragmentDescriptor
import com.mogo.utils.logger.Logger
/**
*@author zyz
* 2020-01-18.
*/
object NaviManager {
private lateinit var mReceiver: BroadcastReceiver
private val AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV"
fun init(context: Context) {
mReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action
if (TextUtils.equals(action, AUTONAVI_STANDARD_BROADCAST_RECV)) {
val key_type = intent.getIntExtra("KEY_TYPE", 0)
Logger.d("NaviManager", "key_type" + key_type, null)
if (key_type == 10038 || key_type == 10007) {
SearchServiceHolder.mogoLauncher.backToLauncher(context)
choosePath(intent, key_type)
} else if (key_type == 10021) {
SearchServiceHolder.getNavi().stopNavi()
} else if (key_type == 10005) {
// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
// * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6`
// * `躲避收费和拥堵` |`7` `不走高速躲避收费和拥堵` |`8` `高速优先` |`20` `躲避拥堵且高速优先` |`24`
// *
var prefer = intent.getIntExtra("NAVI_ROUTE_PREFER", 0)
var avoidSpeed = MogoNaviConfig().congestion(prefer == 4)
.cost(prefer == 1 || prefer == 7)
.highSpeed(prefer == 20)
.avoidSpeed(prefer == 3)
SearchServiceHolder.getNavi().reCalculateRoute(avoidSpeed)
}
}
}
/**
* 打开地图
*/
private fun gotoSearch() {
AddressManager.goSearch()
}
/**
* 唤醒指令导航去哪里
*/
private fun choosePath(intent: Intent, type: Int) {
val lat: Double
val lon: Double
if (type == 10007) {
lat = intent.getDoubleExtra("ENTRY_LAT", 0.0)
lon = intent.getDoubleExtra("ENTRY_LON", 0.0)
} else {
lat = intent.getDoubleExtra("LAT", 0.0)
lon = intent.getDoubleExtra("LON", 0.0)
}
AddressManager.calculatePath(MogoLatLng(lat, lon))
}
}
val inputFilter = IntentFilter()
inputFilter.addAction(AUTONAVI_STANDARD_BROADCAST_RECV)
context.registerReceiver(mReceiver, inputFilter)
}
}