fix bug and add gd loc

This commit is contained in:
zhongchao
2022-08-17 11:58:52 +08:00
parent 136d968005
commit e7637c9540
4 changed files with 81 additions and 12 deletions

View File

@@ -38,6 +38,7 @@ import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.ProcessUtils
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.map.location.GDLocationClient
import com.mogo.module.common.constants.HostConst
import com.rousetime.android_startup.AndroidStartup
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
@@ -74,12 +75,17 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
this.context = context
if (ProcessUtils.isMainProcess(context)) {
initGDLoc()
initHttpDns()
initCloudClientConfig()
}
return true
}
private fun initGDLoc() {
GDLocationClient.getInstance(context).start()
}
/**
* 初始化 HttpDNS ,这里会通过一个接口获取所有鹰眼中使用的微服务域名以及端口号
* 后续的网络请求会通过 HttpDnsInterceptor 进行拦截替换
@@ -242,10 +248,10 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
linkCode = CHAIN_LINK_CLOUD_SHOW,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED,
paramIndexes = [0],
paramIndexes = [0,1],
clientPkFileName = "sn"
)
override fun onAddressChanged(address: Map<String, String>?) {
override fun onAddressChanged(cityCode: String, address: Map<String, String>?) {
val dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(
host,
HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP

View File

@@ -63,23 +63,23 @@ SERVICE_CHAIN_VERSION=1.1.0
LOGLIB_VERSION=1.3.31
######## MogoAiCloudSDK Version ########
# 网络请求LOGLIB_VERSION
MOGO_NETWORK_VERSION=1.4.3.8
MOGO_NETWORK_VERSION=1.4.3.17
# 鉴权
MOGO_PASSPORT_VERSION=1.4.3.8
MOGO_PASSPORT_VERSION=1.4.3.17
# 常链接
MOGO_SOCKET_VERSION=1.4.3.8
MOGO_SOCKET_VERSION=1.4.3.17
# 数据采集
MOGO_REALTIME_VERSION=1.4.3.8
MOGO_REALTIME_VERSION=1.4.3.17
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.4.3.8
MOGO_TANLU_VERSION=1.4.3.17
# 直播推流
MOGO_LIVE_VERSION=1.4.3.8
MOGO_LIVE_VERSION=1.4.3.17
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.4.3.8
MOGO_TRAFFICLIVE_VERSION=1.4.3.17
# 定位服务
MOGO_LOCATION_VERSION=1.4.3.8
MOGO_LOCATION_VERSION=1.4.3.17
# 远程通讯模块
MOGO_TELEMATIC_VERSION=1.4.3.8
MOGO_TELEMATIC_VERSION=1.4.3.17
######## MogoAiCloudSDK Version ########
# 自研地图
MAP_SDK_VERSION=2.4.0.1
@@ -155,7 +155,7 @@ MOGO_OCH_TAXI_VERSION=2.0.66
# mogoAiCloud sdk services
MOGO_AICLOUD_SERVICES_SDK_VERSION=2.1.16.10
# v2x-sdk
MOGO_V2X_SDK_VERSION=1.4.3.8
MOGO_V2X_SDK_VERSION=1.4.3.17
################# 旧版本架构模块版本 #################

View File

@@ -48,6 +48,9 @@ dependencies {
kapt rootProject.ext.dependencies.aroutercompiler
// 高精地图
implementation rootProject.ext.dependencies.mogocustommap
// 高德地图
api rootProject.ext.dependencies.amaplocation
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogo_core_utils
implementation rootProject.ext.dependencies.mogomapapi

View File

@@ -0,0 +1,60 @@
package com.mogo.map.location;
import android.content.Context;
import android.util.Log;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
public class GDLocationClient implements AMapLocationListener {
private volatile static GDLocationClient gdLocationClient;
private static final byte[] obj = new byte[0];
public static GDLocationClient getInstance(Context context) {
if (gdLocationClient == null) {
synchronized (obj) {
if (gdLocationClient == null) {
gdLocationClient = new GDLocationClient(context);
}
}
}
return gdLocationClient;
}
//声明LocationClient对象
private final AMapLocationClient mLocationClient;
private GDLocationClient(Context context) {
mLocationClient = new AMapLocationClient(context);
//初始化定位参数
//声明mLocationOption对象
AMapLocationClientOption mLocationOption = new AMapLocationClientOption();
//设置定位监听
mLocationClient.setLocationListener(this);
//设置定位模式为高精度模式Battery_Saving为低功耗模式Device_Sensors是仅设备模式
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//设置定位间隔,单位毫秒,默认为2000ms
mLocationOption.setInterval(1000);
//设置定位参数
mLocationClient.setLocationOption(mLocationOption);
}
public void start() {
mLocationClient.startLocation();
}
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
String cityCode = aMapLocation.getCityCode();
if (cityCode == null || cityCode.isEmpty()) {
Log.e("0817arrow", "gd city code is null");
} else {
Log.e("0817arrow", "gd city code is :" + cityCode);
}
}
}
}