opt
This commit is contained in:
@@ -144,17 +144,6 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
return new AppNavigatorPresenter(this);
|
||||
}
|
||||
|
||||
private void openSearchPanel() {
|
||||
mSearchProvider = (IMogoModuleProvider) ARouter.getInstance()
|
||||
.build(MogoModulePaths.PATH_MODULE_SEARCH)
|
||||
.navigation();
|
||||
final Fragment fragment = mSearchProvider.createFragment(getContext(), null);
|
||||
mMogoFragmentManager.push(new FragmentDescriptor.Builder().fragment(fragment)
|
||||
.tag(MogoModulePaths.PATH_FRAGMENT_SEARCH)
|
||||
.notifyMainModule(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
@@ -20,6 +20,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ import androidx.annotation.Keep;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -38,57 +37,6 @@ public class MogoModulePaths {
|
||||
public static void addModule( String path ) {
|
||||
throw new IllegalArgumentException( "this method can't be invoked." );
|
||||
}
|
||||
/**
|
||||
* 搜索页面模块实例化路径
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_MODULE_SEARCH= "/navi/search/ui";
|
||||
|
||||
/**
|
||||
* 搜索页面Activity实例化路径
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_MODULE_NAV_ACTIVITY= "/navi/search/ui/activity";
|
||||
|
||||
|
||||
/**
|
||||
* 搜索 fragment
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_FRAGMENT_SEARCH = "/navi/search";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 搜索 fragment
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_FRAGMENT_CHOOSE_PAHT = "/navi/search";
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 按类别搜索 fragment
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_FRAGMENT_SEARCH_CATEGORY = "/navi/search/category";
|
||||
|
||||
|
||||
/**
|
||||
* 设置 fragment
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_FRAGMENT_SETTING = "/navi/setting";
|
||||
|
||||
|
||||
/**
|
||||
* 设置家和公司 fragment
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_FRAGMENT_SETTING_HOME = "/navi/setting/home";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加卡片模块
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-10
|
||||
* <p>
|
||||
* 拦截器
|
||||
*/
|
||||
public interface Interrupter {
|
||||
|
||||
/**
|
||||
* 是否拦截
|
||||
* @return true - 拦截, false - 不拦截
|
||||
*/
|
||||
boolean interrupt();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-10
|
||||
* <p>
|
||||
* 地图视图中心点
|
||||
*/
|
||||
public class MapCenterPoint {
|
||||
|
||||
public final double x;
|
||||
public final double y;
|
||||
|
||||
public MapCenterPoint( double x, double y ) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-10
|
||||
* <p>
|
||||
* 地图中心点策略
|
||||
*/
|
||||
public class MapCenterPointStrategy {
|
||||
|
||||
private static final String TAG = "MapCenterPointStrategy";
|
||||
|
||||
private static Map< Integer, Map< Integer, MapCenterPoint > > sStrategies = new HashMap<>();
|
||||
|
||||
public static final MapCenterPoint DEFAULT = new MapCenterPoint( 0.677734D, 0.5733333D );
|
||||
|
||||
static {
|
||||
// 普通场景,使用高德内部值
|
||||
Map< Integer, MapCenterPoint > common = new HashMap<>();
|
||||
common.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.666666666D ) );
|
||||
common.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.666666666D ) );
|
||||
sStrategies.put( Scene.COMMON, common );
|
||||
|
||||
// 选点场景,定位中心点
|
||||
Map< Integer, MapCenterPoint > choosePoint = new HashMap<>();
|
||||
choosePoint.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
sStrategies.put( Scene.CHOOSE_POINT, choosePoint );
|
||||
|
||||
|
||||
// 导航场景,定位视图右下角偏下
|
||||
Map< Integer, MapCenterPoint > navi = new HashMap<>();
|
||||
navi.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.7734375D, 0.65D ) );
|
||||
navi.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.775521D, 0.6759259D ) );
|
||||
sStrategies.put( Scene.NAVI, navi );
|
||||
|
||||
|
||||
// 巡航场景,定位视图右下角偏下
|
||||
Map< Integer, MapCenterPoint > aimless = new HashMap<>();
|
||||
aimless.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.677734375D, 0.54D ) );
|
||||
aimless.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.6833333D ) );
|
||||
sStrategies.put( Scene.AIMLESS, aimless );
|
||||
|
||||
|
||||
// 规划路线,定位视图右边
|
||||
Map< Integer, MapCenterPoint > calculatePath = new HashMap<>();
|
||||
calculatePath.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.703125D, 0.6083333D ) );
|
||||
sStrategies.put( Scene.CALCULATE_PATH, calculatePath );
|
||||
|
||||
// 分类搜索,定位视图右边
|
||||
Map< Integer, MapCenterPoint > categorySearch = new HashMap<>();
|
||||
categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.596759D ) );
|
||||
sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch );
|
||||
}
|
||||
|
||||
public static void addScene( int scene, Map< Integer, MapCenterPoint > config ) {
|
||||
if ( sStrategies.containsKey( scene ) ) {
|
||||
Logger.w( TAG, "scene has already defined, append config..." );
|
||||
}
|
||||
if ( sStrategies.get( scene ) != null ) {
|
||||
sStrategies.get( scene ).putAll( config );
|
||||
} else {
|
||||
sStrategies.put( scene, config );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据场景触发地图视图改变
|
||||
*
|
||||
* @param controller
|
||||
* @param scene
|
||||
*/
|
||||
public static void setMapCenterPointByScene( IMogoMapUIController controller, int scene ) {
|
||||
if ( controller == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !sStrategies.containsKey( scene ) ) {
|
||||
Logger.w( TAG, "no strategy for scene: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
return;
|
||||
}
|
||||
Map< Integer, MapCenterPoint > points = sStrategies.get( scene );
|
||||
int car = CarSeries.getSeries();
|
||||
if ( !points.containsKey( car ) ) {
|
||||
Logger.w( TAG, "no strategy for series: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
return;
|
||||
}
|
||||
MapCenterPoint point = points.get( car );
|
||||
if ( point == null ) {
|
||||
Logger.w( TAG, "no strategy config for series: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
return;
|
||||
}
|
||||
controller.setPointToCenter( point.x, point.y );
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据场景触发地图视图改变
|
||||
*
|
||||
* @param controller
|
||||
* @param scene
|
||||
*/
|
||||
public static void setMapCenterPointBySceneAndDelay( final IMogoMapUIController controller, final int scene, long delay, final Interrupter interrupter ) {
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
if ( interrupter != null ) {
|
||||
if ( interrupter.interrupt() ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setMapCenterPointByScene( controller, scene );
|
||||
}, delay );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface Scene {
|
||||
|
||||
/**
|
||||
* 普通场景
|
||||
*/
|
||||
int COMMON = 0;
|
||||
|
||||
/**
|
||||
* 选点
|
||||
*/
|
||||
int CHOOSE_POINT = 1;
|
||||
|
||||
/**
|
||||
* 导航
|
||||
*/
|
||||
int NAVI = 2;
|
||||
|
||||
/**
|
||||
* 巡航
|
||||
*/
|
||||
int AIMLESS = 3;
|
||||
|
||||
/**
|
||||
* 路线规划
|
||||
*/
|
||||
int CALCULATE_PATH = 4;
|
||||
|
||||
/**
|
||||
* 分类搜索
|
||||
*/
|
||||
int CATEGORY_SEARCH = 5;
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -29,16 +26,14 @@ import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant;
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener;
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeRegister;
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener;
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.dialog.NaviNoticeDialog;
|
||||
@@ -55,16 +50,10 @@ import com.mogo.service.module.IMogoAddressManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.http.HEAD;
|
||||
|
||||
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE;
|
||||
|
||||
/**
|
||||
@@ -118,7 +107,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
/**
|
||||
* 搜索莫模块
|
||||
*/
|
||||
private IMogoModuleProvider mSearchProvider;
|
||||
private boolean mIsLock = true;
|
||||
private TextView ivMode;
|
||||
|
||||
@@ -145,22 +133,12 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mSearch = findViewById( R.id.module_entrance_id_search );
|
||||
|
||||
mSearch.setOnClickListener( view -> {
|
||||
setMarkerStatus( true );
|
||||
mSearchProvider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build( MogoModulePaths.PATH_MODULE_SEARCH )
|
||||
.navigation();
|
||||
final Fragment fragment = mSearchProvider.createFragment( getContext(), null );
|
||||
mMogoFragmentManager.push( new FragmentDescriptor.Builder().fragment( fragment )
|
||||
.tag( MogoModulePaths.PATH_FRAGMENT_SEARCH )
|
||||
.notifyMainModule( true )
|
||||
.build() );
|
||||
|
||||
mApis.getAddressManagerApi().goSearch();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_entrance_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
setMarkerStatus( true );
|
||||
mMogoAddressManager.goHome();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
|
||||
@@ -168,7 +146,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
mCompany = findViewById( R.id.module_entrance_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
setMarkerStatus( true );
|
||||
mMogoAddressManager.goCompany();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
|
||||
@@ -210,6 +187,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
NaviNoticeDialog naviNoticeDialog = new NaviNoticeDialog( getContext() );
|
||||
naviNoticeDialog.show();
|
||||
} else {
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mMApUIController, Scene.NAVI );
|
||||
mMApUIController.recoverLockMode();
|
||||
}
|
||||
}
|
||||
@@ -254,12 +232,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void setMarkerStatus( boolean show ) {
|
||||
mMogoStatusManager.setSearchUIShow( MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, show );
|
||||
}
|
||||
|
||||
|
||||
private static final String AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV";
|
||||
|
||||
@NonNull
|
||||
@@ -342,8 +314,10 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
ivMode.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
mMApUIController.setPointToCenter( 0.675926, 0.77552 );
|
||||
mMApUIController.changeMapMode( ivMode.isSelected() ? EnumMapUI.NorthUP_2D : EnumMapUI.CarUp_2D );
|
||||
MapCenterPointStrategy.setMapCenterPointBySceneAndDelay( mMApUIController, Scene.NAVI, 500, () -> {
|
||||
return !mMogoNavi.isNaviing();
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,8 +327,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
ivMode.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
mSpeedLimit.setVisibility( View.GONE );
|
||||
mMApUIController.setPointToCenter( 0.66145, 0.590688 );
|
||||
mMApUIController.changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mMApUIController, Scene.AIMLESS );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.main.cards.CardIntroduceConfigs;
|
||||
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||
import com.mogo.module.main.cards.HorizentalStackTransformer;
|
||||
@@ -261,7 +263,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
// 右移地图中心点
|
||||
mMogoMapUIController = mMogoMapService.getMapUIController();
|
||||
mMogoMapUIController.setPointToCenter( 0.66145, 0.590688 );
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mMogoMapUIController, Scene.AIMLESS );
|
||||
|
||||
// 开启定位
|
||||
startLocation();
|
||||
|
||||
@@ -34,4 +34,11 @@ public class AMapConstants {
|
||||
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED = 1f;
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED = 0.3f;
|
||||
|
||||
public static final String PATH_FRAGMENT_SEARCH = "PATH_FRAGMENT_SEARCH";
|
||||
public static final String PATH_FRAGMENT_CHOOSE_PATH = "PATH_FRAGMENT_CHOOSE_PATH";
|
||||
public static final String PATH_FRAGMENT_SEARCH_CATEGORY = "PATH_FRAGMENT_SEARCH_CATEGORY";
|
||||
public static final String PATH_FRAGMENT_SETTING = "PATH_FRAGMENT_SETTING";
|
||||
public static final String PATH_FRAGMENT_NAVI_SETTING = "PATH_FRAGMENT_NAVI_SETTING";
|
||||
public static final String PATH_FRAGMENT_SETTING_HOME = "PATH_FRAGMENT_SETTING_HOME";
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.analytics.IMogoAnalytics
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager
|
||||
import com.mogo.service.launcher.IMogoLauncher
|
||||
import com.mogo.service.map.IMogoMapService
|
||||
import com.mogo.service.module.IMogoRegisterCenter
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager
|
||||
@@ -28,24 +29,14 @@ import com.mogo.service.statusmanager.IMogoStatusManager
|
||||
object SearchServiceHolder{
|
||||
// 单例对象,要使用Application Context
|
||||
private lateinit var context: Context
|
||||
val fragmentManager: IMogoFragmentManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_FRAGMENT_MANAGER
|
||||
).navigation() as IMogoFragmentManager
|
||||
val mapService: IMogoMapService = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_SERVICES_MAP
|
||||
).navigation() as IMogoMapService
|
||||
val listenerCenter: IMogoRegisterCenter = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_REGISTER_CENTER
|
||||
).navigation() as IMogoRegisterCenter
|
||||
val statusManager: IMogoStatusManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_STATUS_MANAGER
|
||||
).navigation() as IMogoStatusManager
|
||||
val analyticsManager: IMogoAnalytics = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_UTILS_ANALYTICS
|
||||
).navigation() as IMogoAnalytics
|
||||
val guideShowProvider: IGuideShowProvider = ARouter.getInstance().build(
|
||||
GuideShowProviderConstant.GUIDE_SHOW_PROVIDER
|
||||
).navigation() as IGuideShowProvider
|
||||
|
||||
val fragmentManager: IMogoFragmentManager = ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation() as IMogoFragmentManager
|
||||
val mapService: IMogoMapService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation() as IMogoMapService
|
||||
val listenerCenter: IMogoRegisterCenter = ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation() as IMogoRegisterCenter
|
||||
val statusManager: IMogoStatusManager = ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation() as IMogoStatusManager
|
||||
val analyticsManager: IMogoAnalytics = ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation() as IMogoAnalytics
|
||||
val guideShowProvider: IGuideShowProvider = ARouter.getInstance().build(GuideShowProviderConstant.GUIDE_SHOW_PROVIDER).navigation() as IGuideShowProvider
|
||||
val mogoLauncher: IMogoLauncher = ARouter.getInstance().build(MogoServicePaths.PATH_LAUNCHER_API).navigation() as IMogoLauncher
|
||||
|
||||
var geoSearch: IMogoGeoSearch? = null
|
||||
fun init(context: Context) {
|
||||
@@ -86,10 +77,4 @@ object SearchServiceHolder{
|
||||
return geoSearch!!
|
||||
}
|
||||
|
||||
fun setMarkerStatus(show: Boolean) {
|
||||
statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, show
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,20 +2,25 @@ package com.mogo.module.navi.manager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.cp.AddressHelper
|
||||
import com.mogo.module.navi.dao.SearchPoiDao
|
||||
import com.mogo.module.navi.database.AppDataBase
|
||||
import com.mogo.module.navi.ui.search.CategorySearchFragment
|
||||
import com.mogo.module.navi.ui.search.ChoosePathFragment
|
||||
import com.mogo.module.navi.ui.search.SearchFragment
|
||||
import com.mogo.module.navi.ui.setting.NaviSettingFragment
|
||||
import com.mogo.module.navi.ui.setting.SettingAddressFragment
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@@ -27,124 +32,153 @@ import org.greenrobot.eventbus.EventBus
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object AddressManager {
|
||||
var homeAddress: SearchPoi? = null
|
||||
var companyAddress: SearchPoi? = null
|
||||
private lateinit var poiDao:SearchPoiDao
|
||||
fun goHome() {
|
||||
if (homeAddress == null) {
|
||||
pushSettingAddress(
|
||||
DataConstants.TYPE_HOME_ADDRESS
|
||||
)
|
||||
} else {
|
||||
var newInstance = ChoosePathFragment.newInstance(
|
||||
EntityConvertUtils.poi2MogoTip(
|
||||
homeAddress
|
||||
).point
|
||||
)
|
||||
SearchServiceHolder.push(
|
||||
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun goCompany() {
|
||||
if (companyAddress == null) {
|
||||
pushSettingAddress(
|
||||
DataConstants.TYPE_COMPANY_ADDRESS
|
||||
)
|
||||
} else {
|
||||
var newInstance =
|
||||
ChoosePathFragment.newInstance(
|
||||
EntityConvertUtils.poi2MogoTip(
|
||||
companyAddress
|
||||
).point
|
||||
val TAG: String = "AddressManager.kt"
|
||||
|
||||
var homeAddress: SearchPoi? = null
|
||||
var companyAddress: SearchPoi? = null
|
||||
private lateinit var poiDao: SearchPoiDao
|
||||
|
||||
fun hasHome(): Boolean {
|
||||
return homeAddress != null
|
||||
}
|
||||
|
||||
fun hasCompany(): Boolean {
|
||||
return companyAddress != null
|
||||
}
|
||||
|
||||
private fun choosePoint(type: Int){
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(SearchServiceHolder.getMapUIController(), Scene.CHOOSE_POINT)
|
||||
val builder = FragmentDescriptor.Builder()
|
||||
builder.fragment(SettingAddressFragment.newInstance(type))
|
||||
val build = builder.tag(AMapConstants.PATH_FRAGMENT_SETTING_HOME).build()
|
||||
SearchServiceHolder.fragmentManager.push(build)
|
||||
}
|
||||
|
||||
private lateinit var context: Context
|
||||
@SuppressLint("CheckResult")
|
||||
fun init(context: Context) {
|
||||
|
||||
this.context = context
|
||||
poiDao = AppDataBase.getDatabase(context).poiDao()
|
||||
poiDao.companyAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
companyAddress = t1[0]
|
||||
}
|
||||
}
|
||||
|
||||
poiDao.homeAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
homeAddress = t1[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun insert(searchPoi: SearchPoi) {
|
||||
|
||||
EventBus.getDefault().post(searchPoi)
|
||||
if (searchPoi.type == DataConstants.TYPE_COMPANY_ADDRESS) {
|
||||
companyAddress = searchPoi
|
||||
} else {
|
||||
homeAddress = searchPoi
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteHome(context: Context) {
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(homeAddress)
|
||||
homeAddress?.name = ""
|
||||
AddressHelper.notifyAddressChanged(1)
|
||||
|
||||
homeAddress = null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun deleteCompany(context: Context) {
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(companyAddress)
|
||||
companyAddress?.name = ""
|
||||
AddressHelper.notifyAddressChanged(0)
|
||||
|
||||
companyAddress = null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
/**
|
||||
* 回家
|
||||
*/
|
||||
fun goHome() {
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
if (homeAddress == null) {
|
||||
choosePoint(DataConstants.TYPE_HOME_ADDRESS)
|
||||
} else {
|
||||
calculatePath(EntityConvertUtils.poi2MogoTip(homeAddress).point)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 去公司
|
||||
*/
|
||||
fun goCompany() {
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
if (companyAddress == null) {
|
||||
choosePoint( DataConstants.TYPE_COMPANY_ADDRESS)
|
||||
} else {
|
||||
calculatePath(EntityConvertUtils.poi2MogoTip(companyAddress).point)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
fun goSearch() {
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
SearchServiceHolder.fragmentManager.push(
|
||||
FragmentDescriptor.Builder().fragment(SearchFragment())
|
||||
.tag(AMapConstants.PATH_FRAGMENT_SEARCH)
|
||||
.notifyMainModule(true)
|
||||
.build()
|
||||
)
|
||||
SearchServiceHolder.push(
|
||||
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun hasHome(): Boolean {
|
||||
return homeAddress != null
|
||||
}
|
||||
|
||||
fun hasCompany(): Boolean {
|
||||
return companyAddress != null
|
||||
}
|
||||
|
||||
private fun pushSettingAddress(type: Int) {
|
||||
|
||||
val builder = FragmentDescriptor.Builder()
|
||||
builder.fragment(SettingAddressFragment.newInstance(type))
|
||||
val build = builder.tag(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME)
|
||||
.build()
|
||||
SearchServiceHolder.fragmentManager.push(build)
|
||||
}
|
||||
|
||||
private lateinit var context: Context
|
||||
@SuppressLint("CheckResult") fun init(context: Context) {
|
||||
|
||||
this.context=context
|
||||
poiDao = AppDataBase.getDatabase(context)
|
||||
.poiDao()
|
||||
poiDao
|
||||
.companyAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
companyAddress = t1[0]
|
||||
}
|
||||
/**
|
||||
* 路径规划
|
||||
*/
|
||||
fun calculatePath(destination: MogoLatLng?) {
|
||||
destination?.let {
|
||||
var newInstance = ChoosePathFragment.newInstance(destination)
|
||||
SearchServiceHolder.push(newInstance, AMapConstants.PATH_FRAGMENT_CHOOSE_PATH)
|
||||
}
|
||||
|
||||
poiDao
|
||||
.homeAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
homeAddress = t1[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun insert(searchPoi: SearchPoi) {
|
||||
|
||||
EventBus.getDefault().post(searchPoi)
|
||||
if (searchPoi.type == DataConstants.TYPE_COMPANY_ADDRESS) {
|
||||
companyAddress = searchPoi
|
||||
} else {
|
||||
homeAddress = searchPoi
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteHome(context: Context){
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(homeAddress)
|
||||
homeAddress?.name=""
|
||||
AddressHelper.notifyAddressChanged( 1)
|
||||
fun categorySearch(category: String){
|
||||
val searchFragment = CategorySearchFragment.newInstance(category)
|
||||
SearchServiceHolder.fragmentManager.push(FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag(AMapConstants.PATH_FRAGMENT_SEARCH_CATEGORY)
|
||||
.notifyMainModule(true)
|
||||
.build())
|
||||
}
|
||||
|
||||
homeAddress=null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
fun goSettings(){
|
||||
val naviSettingFragment = NaviSettingFragment()
|
||||
SearchServiceHolder.fragmentManager.push(FragmentDescriptor.Builder().fragment(naviSettingFragment)
|
||||
.tag(AMapConstants.PATH_FRAGMENT_NAVI_SETTING)
|
||||
.notifyMainModule(true)
|
||||
.build())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun deleteCompany(context: Context){
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(companyAddress)
|
||||
companyAddress?.name=""
|
||||
AddressHelper.notifyAddressChanged( 0)
|
||||
|
||||
companyAddress=null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -12,6 +13,7 @@ import com.mogo.service.module.IMogoAddressManager;
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_ADDRESS_MANAGER )
|
||||
public class MogoAddressManager implements IMogoAddressManager {
|
||||
|
||||
@Override public void goHome() {
|
||||
AddressManager.INSTANCE.goHome();
|
||||
}
|
||||
@@ -20,7 +22,27 @@ public class MogoAddressManager implements IMogoAddressManager {
|
||||
AddressManager.INSTANCE.goCompany();
|
||||
}
|
||||
|
||||
@Override public void init(Context context) {
|
||||
@Override
|
||||
public void goSearch() {
|
||||
AddressManager.INSTANCE.goSearch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatePath( MogoLatLng destination ) {
|
||||
AddressManager.INSTANCE.calculatePath( destination );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void categorySearch( String category ) {
|
||||
AddressManager.INSTANCE.categorySearch( category );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goSettings() {
|
||||
AddressManager.INSTANCE.goSettings();
|
||||
}
|
||||
|
||||
@Override public void init( Context context) {
|
||||
AddressManager.INSTANCE.init(context);
|
||||
SearchServiceHolder.INSTANCE.init(context);
|
||||
SettingManager.INSTANCE.init(context);
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.constants.BroadcastMode;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.navi.constants.AMapConstants;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
import com.mogo.module.navi.ui.search.CategorySearchFragment;
|
||||
import com.mogo.module.navi.ui.search.SearchFragment;
|
||||
@@ -30,7 +31,7 @@ public class MogoSearchManager implements IMogoSearchManager {
|
||||
SearchFragment searchFragment = new SearchFragment();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager()
|
||||
.push(new FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag(MogoModulePaths.PATH_FRAGMENT_SEARCH)
|
||||
.tag( AMapConstants.PATH_FRAGMENT_SEARCH)
|
||||
.notifyMainModule(true)
|
||||
.build());
|
||||
}
|
||||
@@ -49,12 +50,7 @@ public class MogoSearchManager implements IMogoSearchManager {
|
||||
}
|
||||
|
||||
@Override public void showCategory(String keyword) {
|
||||
Fragment searchFragment = CategorySearchFragment.Companion.newInstance(keyword);
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager()
|
||||
.push(new FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag(MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY)
|
||||
.notifyMainModule(true)
|
||||
.build());
|
||||
AddressManager.INSTANCE.categorySearch( keyword );
|
||||
}
|
||||
|
||||
@Override public void init(Context context) {
|
||||
|
||||
@@ -1,109 +1,90 @@
|
||||
package com.mogo.module.navi.manager
|
||||
|
||||
import android.app.SearchManager
|
||||
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.utils.logger.Logger
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import com.mogo.map.navi.MogoNaviConfig
|
||||
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"
|
||||
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) {
|
||||
val lat: Double
|
||||
val lon: Double
|
||||
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 == 20009) {
|
||||
SearchServiceHolder.mogoLauncher.backToLauncher(context)
|
||||
gotoSearch()
|
||||
|
||||
if (key_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)
|
||||
|
||||
}
|
||||
showHome()
|
||||
|
||||
SearchServiceHolder.setMarkerStatus(true)
|
||||
var newInstance =
|
||||
ChoosePathFragment.newInstance(
|
||||
MogoLatLng(lat, lon)
|
||||
)
|
||||
SearchServiceHolder.push(
|
||||
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
} else if (key_type == 10021) {
|
||||
SearchServiceHolder.getNavi()
|
||||
.stopNavi()
|
||||
} else if (key_type == 20009) {
|
||||
showHome()
|
||||
SearchServiceHolder.setMarkerStatus(true)
|
||||
SearchServiceHolder.fragmentManager
|
||||
.clearAll()
|
||||
|
||||
val searchFragment = SearchFragment()
|
||||
SearchServiceHolder.fragmentManager
|
||||
.push(
|
||||
FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag(MogoModulePaths.PATH_FRAGMENT_SEARCH)
|
||||
.notifyMainModule(true)
|
||||
.build()
|
||||
)
|
||||
|
||||
} else if (key_type == 10005) {
|
||||
} else if (key_type == 10005) {
|
||||
|
||||
// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
|
||||
// * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6`
|
||||
// * `躲避收费和拥堵` |`7` `不走高速躲避收费和拥堵` |`8` `高速优先` |`20` `躲避拥堵且高速优先` |`24`
|
||||
// *
|
||||
var prefer = intent.getIntExtra("NAVI_ROUTE_PREFER", 0)
|
||||
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)
|
||||
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)
|
||||
|
||||
private fun showHome() {
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.addCategory(Intent.CATEGORY_HOME)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
val inputFilter = IntentFilter()
|
||||
inputFilter.addAction(AUTONAVI_STANDARD_BROADCAST_RECV)
|
||||
context.registerReceiver(mReceiver, inputFilter)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
package com.mogo.module.navi.ui
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.ui.base.BaseActivity
|
||||
|
||||
@Route(path = MogoModulePaths.PATH_MODULE_NAV_ACTIVITY)
|
||||
class NaviActivity : BaseActivity() {
|
||||
|
||||
|
||||
|
||||
@@ -72,27 +72,4 @@ public abstract class BaseFragment extends Fragment {
|
||||
Toast.makeText( mContext, msg, Toast.LENGTH_LONG ).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setMarkerStatus(boolean show){
|
||||
SearchServiceHolder.INSTANCE.getStatusManager().setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, show
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动地图中心点到屏幕中心
|
||||
*/
|
||||
protected void moveMapToCenter(){
|
||||
//SearchServiceHolder.INSTANCE.getMapUIController().setPointToCenter(0.5,0.5);
|
||||
}
|
||||
|
||||
//mMogoMapUIController.setPointToCenter( 0.66145, 0.590688 );
|
||||
/**
|
||||
* 移动地图中心点到屏幕右侧
|
||||
*/
|
||||
protected void moveMapToRight(){
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().setPointToCenter(0.66145, 0.661094);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,13 @@ import com.mogo.map.marker.MogoMarkerOptions
|
||||
import com.mogo.map.search.geo.MogoPoiItem
|
||||
import com.mogo.map.search.inputtips.MogoTip
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.manager.AddressManager
|
||||
import com.mogo.module.navi.ui.adapter.SearchCategoryAdapter
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.module.navi.uitls.BitmapUtils
|
||||
@@ -175,9 +179,6 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
category = arguments?.getString("category")
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, true
|
||||
)
|
||||
mSearchPresenter = CategoryPresenter(this)
|
||||
lifecycle.addObserver(mSearchPresenter)
|
||||
cmds = ArrayList<String>()
|
||||
@@ -223,8 +224,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
|
||||
private fun goPath() {
|
||||
mAdapter.currentItem?.let {
|
||||
var newInstance = ChoosePathFragment.newInstance(mAdapter.currentItem.point)
|
||||
SearchServiceHolder.push(newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT)
|
||||
AddressManager.calculatePath(mAdapter.currentItem.point)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,13 +279,11 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, false
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(category: String): Fragment {
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(SearchServiceHolder.getMapUIController(), Scene.CATEGORY_SEARCH)
|
||||
var bundle = Bundle()
|
||||
bundle.putString("category", category)
|
||||
var categorySerachFragment = CategorySearchFragment()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.navi.ui.search
|
||||
|
||||
import android.app.SearchManager
|
||||
import android.app.Service
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
@@ -14,15 +12,16 @@ import com.mogo.map.navi.IMogoNaviListener
|
||||
import com.mogo.map.navi.MogoCalculatePath
|
||||
import com.mogo.map.navi.MogoNaviInfo
|
||||
import com.mogo.map.navi.MogoTraffic
|
||||
import com.mogo.map.search.inputtips.MogoTip
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.BuildConfig
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.manager.SettingManager
|
||||
import com.mogo.module.navi.ui.adapter.CalculatePathAdapter
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.group_path
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.pb_path
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.rv_search_result
|
||||
@@ -35,263 +34,233 @@ import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
* 2020-01-09.
|
||||
*/
|
||||
class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallBack {
|
||||
override fun onCmdSelected(cmd: String?) {
|
||||
override fun onCmdSelected(cmd: String?) {
|
||||
|
||||
when (cmd) {
|
||||
"firstPath" -> {
|
||||
selectItem(0)
|
||||
startNavi()
|
||||
when (cmd) {
|
||||
"firstPath" -> {
|
||||
selectItem(0)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"secondPath" -> {
|
||||
selectItem(1)
|
||||
startNavi()
|
||||
}
|
||||
"secondPath" -> {
|
||||
selectItem(1)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"thirdPath" -> {
|
||||
selectItem(2)
|
||||
startNavi()
|
||||
}
|
||||
"thirdPath" -> {
|
||||
selectItem(2)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"startNavi" -> {
|
||||
startNavi()
|
||||
}
|
||||
"retry" -> {
|
||||
retry()
|
||||
}
|
||||
"cancel" -> {
|
||||
SearchServiceHolder.fragmentManager
|
||||
.clearAll()
|
||||
}
|
||||
}
|
||||
"startNavi" -> {
|
||||
startNavi()
|
||||
}
|
||||
"retry" -> {
|
||||
retry()
|
||||
}
|
||||
"cancel" -> {
|
||||
SearchServiceHolder.fragmentManager.clearAll()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun selectItem(index: Int) {
|
||||
|
||||
if (mAdapter.list.size > index) {
|
||||
selectPath(mAdapter.list[index])
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakSelectTimeOut(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onInitNaviFailure() {
|
||||
}
|
||||
|
||||
override fun onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
override fun onNaviInfoUpdate(naviinfo: MogoNaviInfo?) {
|
||||
}
|
||||
|
||||
override fun onStartNavi() {
|
||||
}
|
||||
|
||||
override fun onStopNavi() {
|
||||
}
|
||||
|
||||
override fun onCalculateSuccess() {
|
||||
var calculatedStrategies = SearchServiceHolder.getNavi()
|
||||
.calculatedStrategies
|
||||
if (calculatedStrategies != null && calculatedStrategies.size > 0) {
|
||||
mAdapter.setDatas(calculatedStrategies)
|
||||
mAdapter.selectTag = calculatedStrategies[0].tagId
|
||||
}
|
||||
AIAssist.getInstance(context)
|
||||
.speakTTSVoice(String.format("已为你规划处%d条路线,请选择", calculatedStrategies.size))
|
||||
pb_path.visibility = View.GONE
|
||||
group_path.visibility = View.GONE
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
|
||||
unregisterRetryVoice()
|
||||
|
||||
}
|
||||
|
||||
override fun onoCalculateFailed() {
|
||||
group_path.visibility = View.VISIBLE
|
||||
tv_navi_navi.text = "重试"
|
||||
pb_path.visibility = View.GONE
|
||||
|
||||
registerRetryVoice()
|
||||
|
||||
}
|
||||
|
||||
override fun onUpdateTraffic(traffic: MogoTraffic?) {
|
||||
}
|
||||
|
||||
private lateinit var mAdapter: CalculatePathAdapter
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_search_category
|
||||
}
|
||||
|
||||
val firstPath: String = "第一个"
|
||||
val secondPath: String = "第二个"
|
||||
val thirdPath: String = "第三个"
|
||||
val startNavi: String = "开始导航"
|
||||
|
||||
var mogoTip: MogoLatLng? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mogoTip = arguments?.getParcelable<MogoLatLng>(AMapConstants.KEY_PARCELABLE)
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT, true
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// 是否开启导航
|
||||
var isStartedNavi = false
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
|
||||
et_navi_search.setText(getString(R.string.choose_path))
|
||||
et_navi_search.isEnabled = false
|
||||
SearchServiceHolder.getNavi()
|
||||
.naviTo(mogoTip)
|
||||
|
||||
SearchServiceHolder.listenerCenter.registerMogoNaviListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT, this
|
||||
)
|
||||
|
||||
var arrayList = ArrayList<MogoCalculatePath>()
|
||||
mAdapter = CalculatePathAdapter(activity, arrayList)
|
||||
rv_search_result.layoutManager =
|
||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
rv_search_result.adapter = mAdapter
|
||||
tv_navi_navi.setOnClickListener {
|
||||
|
||||
if (group_path.visibility == View.VISIBLE) {
|
||||
retry()
|
||||
} else {
|
||||
startNavi()
|
||||
}
|
||||
}
|
||||
|
||||
SearchServiceHolder.getNavi()
|
||||
.setLineClickInteraction {
|
||||
mAdapter.setSelectTag(it)
|
||||
}
|
||||
|
||||
mAdapter.setOnClickListener {
|
||||
var item = it.getTag(R.id.tag_item) as MogoCalculatePath
|
||||
selectPath(item)
|
||||
}
|
||||
|
||||
// rv_search_result.scroto
|
||||
private fun selectItem(index: Int) {
|
||||
|
||||
if (mAdapter.list.size > index) {
|
||||
selectPath(mAdapter.list[index])
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakSelectTimeOut(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onInitNaviFailure() {
|
||||
}
|
||||
|
||||
override fun onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
override fun onNaviInfoUpdate(naviinfo: MogoNaviInfo?) {
|
||||
}
|
||||
|
||||
override fun onStartNavi() {
|
||||
}
|
||||
|
||||
override fun onStopNavi() {
|
||||
}
|
||||
|
||||
override fun onCalculateSuccess() {
|
||||
var calculatedStrategies = SearchServiceHolder.getNavi().calculatedStrategies
|
||||
if (calculatedStrategies != null && calculatedStrategies.size > 0) {
|
||||
mAdapter.setDatas(calculatedStrategies)
|
||||
mAdapter.selectTag = calculatedStrategies[0].tagId
|
||||
UiThreadHandler.postDelayed( {
|
||||
SearchServiceHolder.getNavi().itemClickInteraction.onItemClicked(calculatedStrategies[0].tagId)
|
||||
}, 500L)
|
||||
}
|
||||
AIAssist.getInstance(context).speakTTSVoice(String.format("已为你规划处%d条路线,请选择", calculatedStrategies.size))
|
||||
pb_path.visibility = View.GONE
|
||||
group_path.visibility = View.GONE
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
|
||||
unregisterRetryVoice()
|
||||
|
||||
}
|
||||
|
||||
SearchServiceHolder.getMarkerManger()
|
||||
.removeMarkers()
|
||||
override fun onoCalculateFailed() {
|
||||
group_path.visibility = View.VISIBLE
|
||||
tv_navi_navi.text = "重试"
|
||||
pb_path.visibility = View.GONE
|
||||
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand("firstPath", arrayOf<String>(firstPath), this)
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand("secondPath", arrayOf<String>(secondPath), this)
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand("thirdPath", arrayOf<String>(thirdPath), this)
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand("startNavi", arrayOf<String>(startNavi,"开始"), this)
|
||||
registerRetryVoice()
|
||||
|
||||
}
|
||||
|
||||
private fun registerRetryVoice() {
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand("retry", arrayOf<String>("重试"), this)
|
||||
}
|
||||
|
||||
private fun unregisterRetryVoice() {
|
||||
AIAssist.getInstance(context)
|
||||
.unregisterUnWakeupCommand("retry")
|
||||
|
||||
}
|
||||
|
||||
private fun retry() {
|
||||
SearchServiceHolder.getNavi()
|
||||
.naviTo(mogoTip)
|
||||
pb_path.visibility = View.VISIBLE
|
||||
group_path.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun startNavi() {
|
||||
if (TextUtils.isEmpty(mAdapter.selectTag)) {
|
||||
return
|
||||
}
|
||||
moveMapToRight()
|
||||
|
||||
SearchServiceHolder.getNavi()
|
||||
.startNavi(!SettingManager.isMonitor())
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.recoverLockMode()
|
||||
|
||||
if (SearchServiceHolder.guideShowProvider.isPlayingVideo()) {
|
||||
SearchServiceHolder.guideShowProvider.closeGuideShowView()
|
||||
}
|
||||
isStartedNavi = true
|
||||
SearchServiceHolder.fragmentManager.clearAll()
|
||||
}
|
||||
|
||||
private fun selectPath(item: MogoCalculatePath?) {
|
||||
item?.let {
|
||||
mAdapter.setSelectTag(item.tagId)
|
||||
SearchServiceHolder.getNavi()
|
||||
.itemClickInteraction.onItemClicked(item.tagId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
SearchServiceHolder.listenerCenter.unregisterMogoNaviListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT, false
|
||||
)
|
||||
if (!isStartedNavi) {
|
||||
SearchServiceHolder.getNavi()
|
||||
.clearCalculatePaths()
|
||||
}
|
||||
|
||||
|
||||
AIAssist.getInstance(context)
|
||||
.unregisterUnWakeupCommand("firstPath")
|
||||
AIAssist.getInstance(context)
|
||||
.unregisterUnWakeupCommand("secondPath")
|
||||
AIAssist.getInstance(context)
|
||||
.unregisterUnWakeupCommand("thirdPath")
|
||||
AIAssist.getInstance(context)
|
||||
.unregisterUnWakeupCommand("startNavi")
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(searchPoi: MogoLatLng): Fragment {
|
||||
var bundle = Bundle()
|
||||
bundle.putParcelable(AMapConstants.KEY_PARCELABLE, searchPoi)
|
||||
var choosePathFragment = ChoosePathFragment()
|
||||
choosePathFragment.arguments = bundle
|
||||
return choosePathFragment
|
||||
override fun onUpdateTraffic(traffic: MogoTraffic?) {
|
||||
}
|
||||
|
||||
private lateinit var mAdapter: CalculatePathAdapter
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_search_category
|
||||
}
|
||||
|
||||
val firstPath: String = "第一个"
|
||||
val secondPath: String = "第二个"
|
||||
val thirdPath: String = "第三个"
|
||||
val startNavi: String = "开始导航"
|
||||
|
||||
var mogoTip: MogoLatLng? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mogoTip = arguments?.getParcelable<MogoLatLng>(AMapConstants.KEY_PARCELABLE)
|
||||
|
||||
}
|
||||
|
||||
// 是否开启导航
|
||||
var isStartedNavi = false
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?) {
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
|
||||
et_navi_search.setText(getString(R.string.choose_path))
|
||||
et_navi_search.isEnabled = false
|
||||
SearchServiceHolder.getNavi()
|
||||
.naviTo(mogoTip)
|
||||
|
||||
SearchServiceHolder.listenerCenter.registerMogoNaviListener(AMapConstants.PATH_FRAGMENT_CHOOSE_PATH, this)
|
||||
|
||||
var arrayList = ArrayList<MogoCalculatePath>()
|
||||
mAdapter = CalculatePathAdapter(activity, arrayList)
|
||||
rv_search_result.layoutManager =
|
||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
rv_search_result.adapter = mAdapter
|
||||
tv_navi_navi.setOnClickListener {
|
||||
|
||||
if (group_path.visibility == View.VISIBLE) {
|
||||
retry()
|
||||
} else {
|
||||
startNavi()
|
||||
}
|
||||
}
|
||||
|
||||
SearchServiceHolder.getNavi().setLineClickInteraction {
|
||||
mAdapter.selectTag = it
|
||||
}
|
||||
|
||||
mAdapter.setOnClickListener {
|
||||
var item = it.getTag(R.id.tag_item) as MogoCalculatePath
|
||||
selectPath(item)
|
||||
}
|
||||
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("firstPath", arrayOf<String>(firstPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("secondPath", arrayOf<String>(secondPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("thirdPath", arrayOf<String>(thirdPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("startNavi", arrayOf<String>(startNavi, "开始"), this)
|
||||
|
||||
}
|
||||
|
||||
private fun registerRetryVoice() {
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("retry", arrayOf<String>("重试"), this)
|
||||
}
|
||||
|
||||
private fun unregisterRetryVoice() {
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("retry")
|
||||
|
||||
}
|
||||
|
||||
private fun retry() {
|
||||
SearchServiceHolder.getNavi().naviTo(mogoTip)
|
||||
pb_path.visibility = View.VISIBLE
|
||||
group_path.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun startNavi() {
|
||||
if (TextUtils.isEmpty(mAdapter.selectTag)) {
|
||||
return
|
||||
}
|
||||
// moveMapToRight()
|
||||
|
||||
SearchServiceHolder.getNavi().startNavi(!SettingManager.isMonitor())
|
||||
SearchServiceHolder.getMapUIController().recoverLockMode()
|
||||
|
||||
if (SearchServiceHolder.guideShowProvider.isPlayingVideo()) {
|
||||
SearchServiceHolder.guideShowProvider.closeGuideShowView()
|
||||
}
|
||||
isStartedNavi = true
|
||||
SearchServiceHolder.fragmentManager.clearAll()
|
||||
}
|
||||
|
||||
private fun selectPath(item: MogoCalculatePath?) {
|
||||
item?.let {
|
||||
mAdapter.setSelectTag(item.tagId)
|
||||
SearchServiceHolder.getNavi().itemClickInteraction.onItemClicked(item.tagId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
SearchServiceHolder.listenerCenter.unregisterMogoNaviListener(AMapConstants.PATH_FRAGMENT_CHOOSE_PATH)
|
||||
if (!isStartedNavi) {
|
||||
SearchServiceHolder.getNavi().clearCalculatePaths()
|
||||
}
|
||||
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("firstPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("secondPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("thirdPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("startNavi")
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(searchPoi: MogoLatLng): Fragment {
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(SearchServiceHolder.getMapUIController(), Scene.CALCULATE_PATH)
|
||||
var bundle = Bundle()
|
||||
bundle.putParcelable(AMapConstants.KEY_PARCELABLE, searchPoi)
|
||||
var choosePathFragment = ChoosePathFragment()
|
||||
choosePathFragment.arguments = bundle
|
||||
return choosePathFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.constants.AMapConstants;
|
||||
import com.mogo.module.navi.manager.AddressManager;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter;
|
||||
@@ -43,7 +44,6 @@ import java.util.List;
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_COMPANY}
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SEARCH)
|
||||
public class SearchFragment extends BaseSearchFragment
|
||||
implements SearchView, View.OnClickListener, IMogoVoiceCmdCallBack,
|
||||
FragmentStackTransactionListener {
|
||||
@@ -92,7 +92,6 @@ public class SearchFragment extends BaseSearchFragment
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
SearchServiceHolder.INSTANCE.getMarkerManger().removeMarkers();
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(false);
|
||||
moveMapToCenter();
|
||||
}
|
||||
|
||||
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
@@ -186,24 +185,18 @@ public class SearchFragment extends BaseSearchFragment
|
||||
goCategory(tag.getName());
|
||||
} else {
|
||||
mSearchPresenter.insert(searchPoi);
|
||||
SearchServiceHolder.INSTANCE.push(
|
||||
ChoosePathFragment.Companion.newInstance(tag.getPoint()),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
AddressManager.INSTANCE.calculatePath( tag.getPoint() );
|
||||
}
|
||||
}
|
||||
|
||||
private void goSetting() {
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager()
|
||||
.track("Navigation_button_setting", new HashMap<String, Object>());
|
||||
|
||||
push(new NaviSettingFragment(), MogoModulePaths.PATH_FRAGMENT_SETTING);
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_button_setting", new HashMap<String, Object>());
|
||||
AddressManager.INSTANCE.goSettings();
|
||||
}
|
||||
|
||||
private void goHistory(SearchPoi item) {
|
||||
MogoTip mogoTip = EntityConvertUtils.poi2MogoTip(item);
|
||||
SearchServiceHolder.INSTANCE.push(
|
||||
ChoosePathFragment.Companion.newInstance(mogoTip.getPoint()),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
AddressManager.INSTANCE.calculatePath( mogoTip.getPoint() );
|
||||
}
|
||||
|
||||
private static final String GO_HOME_CMD = "goHome";
|
||||
@@ -501,8 +494,7 @@ public class SearchFragment extends BaseSearchFragment
|
||||
}
|
||||
|
||||
private void goCategory(String text) {
|
||||
push(CategorySearchFragment.Companion.newInstance(text),
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY);
|
||||
AddressManager.INSTANCE.categorySearch( text );
|
||||
}
|
||||
|
||||
@Override public void onResume() {
|
||||
@@ -517,7 +509,7 @@ public class SearchFragment extends BaseSearchFragment
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(true);
|
||||
moveMapToRight();
|
||||
// moveMapToRight();
|
||||
unRegisterVoice();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@Route( path = MogoModulePaths.PATH_MODULE_SEARCH )
|
||||
public class SearchFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private SearchFragment mAppsFragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mAppsFragment = new SearchFragment();
|
||||
mAppsFragment.setArguments( data );
|
||||
return mAppsFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return MogoModulePaths.PATH_MODULE_SEARCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_NAVI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppPackage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SETTING)
|
||||
class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
|
||||
private var type: Int = 0
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.mogo.map.search.geo.MogoRegeocodeResult
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.common.adapter.MogoMapListenerAdapter
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.R.string
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils
|
||||
@@ -40,7 +42,6 @@ import kotlinx.android.synthetic.main.fragment_setting_address.tv_set_as_home
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SETTING_HOME)
|
||||
class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
override fun onRegeocodeSearched(regeocodeResult: MogoRegeocodeResult?) {
|
||||
et_navi_search.setText(regeocodeResult?.regeocodeAddress?.formatAddress)
|
||||
@@ -97,22 +98,14 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
style = arguments?.getInt(AMapConstants.KEY_SET_HOME_COMPONY) ?: DataConstants.TYPE_HOME_ADDRESS
|
||||
setMarkerStatus(true)
|
||||
SearchServiceHolder.listenerCenter.registerMogoMapListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, mapListener
|
||||
AMapConstants.PATH_FRAGMENT_SETTING_HOME, mapListener
|
||||
)
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.showMyLocation(false)
|
||||
SearchServiceHolder.getMapUIController().showMyLocation(false)
|
||||
|
||||
SearchServiceHolder.getGeoSearcher()
|
||||
.setGeoSearchListener(this)
|
||||
SearchServiceHolder.getGeoSearcher().setGeoSearchListener(this)
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, true
|
||||
)
|
||||
|
||||
SearchServiceHolder.getMarkerManger()
|
||||
.removeMarkers()
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
@@ -155,9 +148,8 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
|
||||
et_navi_search.isEnabled = false
|
||||
et_navi_search.setText(getString(string.drag_map_to_choose))
|
||||
var location = SearchServiceHolder.getMapUIController()
|
||||
.windowCenterLocation
|
||||
moveMapToCenter()
|
||||
var location = SearchServiceHolder.getMapUIController().windowCenterLocation
|
||||
|
||||
UiThreadHandler.postDelayed({
|
||||
if (!isAdded) {
|
||||
return@postDelayed
|
||||
@@ -170,10 +162,9 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
.anchor(0.5f, 1f)
|
||||
.longitude(location?.lng ?: 0.0)
|
||||
addMarker = SearchServiceHolder.getMarkerManger()
|
||||
.addMarker(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
.addMarker(AMapConstants.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
|
||||
var locationPointInScreen = SearchServiceHolder.getMapUIController()
|
||||
.getLocationPointInScreen(location)
|
||||
var locationPointInScreen = SearchServiceHolder.getMapUIController().getLocationPointInScreen(location)
|
||||
addMarker?.setPositionByPixels(locationPointInScreen)
|
||||
}, 500L)
|
||||
}
|
||||
@@ -190,31 +181,14 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
// setMarkerStatus(true)
|
||||
// SearchServiceHolder.getMapUIController()
|
||||
// .showMyLocation(true)
|
||||
SearchServiceHolder.listenerCenter.unregisterMogoMapListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME
|
||||
AMapConstants.PATH_FRAGMENT_SETTING_HOME
|
||||
)
|
||||
addMarker?.destroy()
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, false
|
||||
)
|
||||
|
||||
if (SearchServiceHolder.fragmentManager.stackSize == 0) {
|
||||
moveMapToRight()
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.showMyLocation(true)
|
||||
}
|
||||
|
||||
// moveMapToRight()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -36,6 +34,8 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.service.carinfo.CarStateInfo;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
@@ -966,19 +966,18 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( size == 0 ) {
|
||||
mUiController.showMyLocation( !mNavi.isNaviing() );
|
||||
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_BACK );
|
||||
// 控制SearchUIShow 打点逻辑
|
||||
mStatusManager.setSearchUIShow( TAG, false );
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
mStatusManager.setSearchUIShow( TAG, false );
|
||||
}
|
||||
if ( mNavi.isNaviing() ) {
|
||||
mUiController.setPointToCenter( 0.675926, 0.77552 );
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mUiController, Scene.NAVI );
|
||||
} else {
|
||||
mUiController.setPointToCenter( 0.66145, 0.661094 );
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mUiController, Scene.AIMLESS );
|
||||
}
|
||||
mUiController.recoverLockMode();
|
||||
} else {
|
||||
mUiController.showMyLocation( false );
|
||||
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this );
|
||||
mStatusManager.setSearchUIShow( TAG, true );
|
||||
mUiController.setPointToCenter( 0.5, 0.5 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
@@ -8,6 +9,32 @@ import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
*/
|
||||
public interface IMogoAddressManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 回家
|
||||
*/
|
||||
void goHome();
|
||||
|
||||
/**
|
||||
* 去公司
|
||||
*/
|
||||
void goCompany();
|
||||
|
||||
/**
|
||||
* 打开搜索
|
||||
*/
|
||||
void goSearch();
|
||||
|
||||
/**
|
||||
* 规划路线
|
||||
*
|
||||
* @param destination 目的地
|
||||
*/
|
||||
void calculatePath( MogoLatLng destination );
|
||||
|
||||
/**
|
||||
* 分类搜索
|
||||
*/
|
||||
void categorySearch(String category);
|
||||
|
||||
void goSettings();
|
||||
}
|
||||
|
||||
@@ -84,6 +84,12 @@ public interface IMogoStatusManager extends IProvider {
|
||||
*/
|
||||
boolean isAIAssistReady();
|
||||
|
||||
/**
|
||||
* 求助状态
|
||||
* @return
|
||||
*/
|
||||
boolean isSeekHelping();
|
||||
|
||||
/**
|
||||
* 设置小智语音UI状态
|
||||
*
|
||||
@@ -166,6 +172,13 @@ public interface IMogoStatusManager extends IProvider {
|
||||
*/
|
||||
void setAIAssistReady( String tag, boolean ready );
|
||||
|
||||
/**
|
||||
* 设置求助状态
|
||||
* @param tag
|
||||
* @param seekHelping
|
||||
*/
|
||||
void setSeekHelping(String tag, boolean seekHelping);
|
||||
|
||||
/**
|
||||
* 注册监听
|
||||
*
|
||||
|
||||
@@ -59,5 +59,10 @@ public enum StatusDescriptor {
|
||||
/**
|
||||
* 小智语音状态
|
||||
*/
|
||||
AI_ASSIST_READY;
|
||||
AI_ASSIST_READY,
|
||||
|
||||
/**
|
||||
* 求助状态
|
||||
*/
|
||||
SEEK_HELPING;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,12 @@ public class MogoStatusManager implements IMogoStatusManager {
|
||||
return get_bool_val( StatusDescriptor.AI_ASSIST_READY );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSeekHelping() {
|
||||
return get_bool_val( StatusDescriptor.SEEK_HELPING );
|
||||
}
|
||||
|
||||
private boolean get_bool_val( StatusDescriptor descriptor ) {
|
||||
Boolean val = mStatus.get( descriptor );
|
||||
return val == null ? false : val;
|
||||
@@ -177,6 +183,13 @@ public class MogoStatusManager implements IMogoStatusManager {
|
||||
recordStatusModifier( tag, StatusDescriptor.AI_ASSIST_READY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeekHelping( String tag, boolean seekHelping ) {
|
||||
mStatus.put( StatusDescriptor.SEEK_HELPING, seekHelping );
|
||||
invokeStatusChangedListener( StatusDescriptor.SEEK_HELPING, seekHelping );
|
||||
recordStatusModifier( tag, StatusDescriptor.SEEK_HELPING );
|
||||
}
|
||||
|
||||
private void invokeStatusChangedListener( StatusDescriptor descriptor, boolean status ) {
|
||||
if ( mListeners.containsKey( descriptor ) ) {
|
||||
Iterator< IMogoStatusChangedListener > iterator = mListeners.get( descriptor ).iterator();
|
||||
|
||||
Reference in New Issue
Block a user