httpdns change
This commit is contained in:
@@ -132,10 +132,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
//设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作
|
||||
clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ"
|
||||
|
||||
// todo 使用旧链路
|
||||
// clientConfig.setUseOriginSocket(true);
|
||||
clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation {
|
||||
override fun getCurrentLocation(): HttpDnsSimpleLocation? {
|
||||
override fun getCurrentLocation(): HttpDnsSimpleLocation {
|
||||
val envConfig = EnvChangeManager.getEnvConfig()
|
||||
if (envConfig != null) {
|
||||
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
|
||||
@@ -147,13 +145,20 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
mogoLocation = locationClient.lastKnowLocation
|
||||
}
|
||||
val httpDnsSimpleLocation =
|
||||
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0
|
||||
) {
|
||||
HttpDnsSimpleLocation(
|
||||
mogoLocation.cityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
|
||||
if(mogoLocation.cityCode.isNullOrEmpty() && !GDLocationClient.getInstance(context).lastCityCode.isNullOrEmpty()){
|
||||
HttpDnsSimpleLocation(
|
||||
GDLocationClient.getInstance(context).lastCityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
}else{
|
||||
HttpDnsSimpleLocation(
|
||||
mogoLocation.cityCode,
|
||||
mogoLocation.latitude,
|
||||
mogoLocation.longitude
|
||||
)
|
||||
}
|
||||
} else {
|
||||
val ciyCode =
|
||||
SharedPrefsMgr.getInstance(
|
||||
@@ -178,7 +183,6 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
|
||||
// e.printStackTrace();
|
||||
HttpDnsSimpleLocation("010", 1.0, 1.0)
|
||||
}
|
||||
//CallerLogger.INSTANCE.d(M_HMI + TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
}
|
||||
return httpDnsSimpleLocation
|
||||
}
|
||||
|
||||
@@ -643,6 +643,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
/**
|
||||
* 设置转向灯和刹车灯
|
||||
*
|
||||
* @param type :车尾灯类型 time: 闪烁时间 最小500ms 小于500ms 默认为500ms
|
||||
* @param time
|
||||
*/
|
||||
@@ -748,9 +749,11 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
sysLocation.setSpeed(location.getSpeed());
|
||||
|
||||
// 将有效经纬度暂存本地,提供给下一次的Http-DNS使用,防止首次请求位置获取不到
|
||||
if (location.getLat() > 0) {
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
||||
if (location.getLat() > 0 && location.getLon() > 0) {
|
||||
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
||||
}
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
|
||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||
@@ -1000,7 +1003,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
bean.setAcceleration(gnssInfo.getAcceleration());
|
||||
bean.setAlt(gnssInfo.getAltitude());
|
||||
bean.setSystemTime(Double.valueOf(gnssInfo.getSystemTime()).longValue());
|
||||
bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime()*1000).longValue());
|
||||
bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
|
||||
bean.setLon(gnssInfo.getLongitude());
|
||||
bean.setLat(gnssInfo.getLatitude());
|
||||
bean.setGnss_speed(((float) gnssInfo.getGnssSpeed()));
|
||||
@@ -1053,7 +1056,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getRoadAngle(Double lon,Double lat,float angle) {
|
||||
public Double getRoadAngle(Double lon, Double lat, float angle) {
|
||||
return MapDataApi.INSTANCE.getRoadRectInfo(lon, lat, angle).getAngle();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
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;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
|
||||
public class GDLocationClient implements AMapLocationListener {
|
||||
|
||||
@@ -26,6 +28,7 @@ public class GDLocationClient implements AMapLocationListener {
|
||||
|
||||
//声明LocationClient对象
|
||||
private final AMapLocationClient mLocationClient;
|
||||
private String mCityCode;
|
||||
|
||||
private GDLocationClient(Context context) {
|
||||
mLocationClient = new AMapLocationClient(context);
|
||||
@@ -50,11 +53,15 @@ public class GDLocationClient implements AMapLocationListener {
|
||||
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);
|
||||
if (cityCode != null && !cityCode.isEmpty()) {
|
||||
mCityCode = aMapLocation.getCityCode();
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
|
||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastCityCode() {
|
||||
return mCityCode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user