This commit is contained in:
wangcongtao
2020-04-13 09:52:40 +08:00
parent da875fc233
commit 45e480cefa
28 changed files with 768 additions and 756 deletions

View File

@@ -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";
/**
* 添加卡片模块

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -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 );
}
}

View File

@@ -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;
}