[2.14.0][Opt]升级高德地图版本新增对应功能
This commit is contained in:
@@ -23,9 +23,9 @@ ext {
|
||||
// amapnavi3dmap : "com.amap.api:navi-3dmap:8.0.1_3dmap8.0.1",
|
||||
// amapsearch : "com.amap.api:search:7.9.0",
|
||||
// amaplocation : "com.amap.api:location:5.5.0",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:8.0.1_3dmap8.0.1",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.3.1",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:9.5.1_3dmap9.5.0",
|
||||
amapsearch : "com.amap.api:search:9.5.0",
|
||||
amaplocation : "com.amap.api:location:6.2.0",
|
||||
// json 转换
|
||||
gson : "com.google.code.gson:gson:2.8.4",
|
||||
// 内存泄漏检测
|
||||
|
||||
@@ -84,6 +84,9 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
|
||||
}
|
||||
|
||||
okView?.setOnClickListener {
|
||||
if (isLoading) {
|
||||
CallerMapUIServiceManager.cancelDownloadCacheData()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -93,6 +96,12 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
|
||||
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
|
||||
updateProgress(progress.toInt())
|
||||
}
|
||||
|
||||
override fun onMapHdCacheResult(cityId: Int, state: Int) {
|
||||
if (state == 0) {// 失败
|
||||
showNewContent(isLoading = false, false)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -134,6 +143,7 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private fun showNewContent(isLoading: Boolean, isSuccess: Boolean) {
|
||||
this.isLoading = isLoading
|
||||
change2NewStyle()
|
||||
when {
|
||||
isLoading -> {
|
||||
|
||||
@@ -60,7 +60,6 @@ dependencies {
|
||||
|
||||
implementation rootProject.ext.dependencies.mogocustommap
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
implementation rootProject.ext.dependencies.amaplocation
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
|
||||
@@ -51,4 +51,8 @@ object CallerMapUIServiceManager {
|
||||
fun isCityDataCached(): Boolean {
|
||||
return serviceProvider?.mapUIController?.isCityDataCached ?: true
|
||||
}
|
||||
|
||||
fun cancelDownloadCacheData() {
|
||||
serviceProvider?.mapUIController?.cancelDownloadCacheData()
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,6 @@ package com.mogo.map.hdcache
|
||||
|
||||
interface IHdCacheListener {
|
||||
fun onMapHdCacheProgress(cityId: Int, progress: Double)
|
||||
|
||||
fun onMapHdCacheResult(cityId: Int, state: Int)// 0失败,1成功
|
||||
}
|
||||
@@ -348,4 +348,6 @@ public interface IMogoMapUIController {
|
||||
* @return
|
||||
*/
|
||||
boolean isCityDataCached();
|
||||
|
||||
void cancelDownloadCacheData();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ dependencies {
|
||||
// 高精地图
|
||||
implementation rootProject.ext.dependencies.mogocustommap
|
||||
// 高德地图
|
||||
api rootProject.ext.dependencies.amaplocation
|
||||
// api rootProject.ext.dependencies.amaplocation
|
||||
api rootProject.ext.dependencies.amapnavi3dmap
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.mogo.map.utils.ResIdCache;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapStyleListener;
|
||||
@@ -1183,17 +1184,35 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
Integer id = HDMapUtils.getHDCityCode(gdCityCode);
|
||||
if (id != null) {
|
||||
hdCacheListener = listener;
|
||||
mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, (cityId, progress) -> {
|
||||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||||
}
|
||||
} else {
|
||||
UiThreadHandler.post(() -> {
|
||||
mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, new OnHdDataDownByCityListener() {
|
||||
@Override
|
||||
public void onMapHDDataCacheProgressByCity(int cityId, double progress) {
|
||||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
UiThreadHandler.post(() -> {
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapHDDataCacheStateByCity(int i, int state) {// 0失败,1成功
|
||||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheResult(i, state);
|
||||
}
|
||||
} else {
|
||||
UiThreadHandler.post(() -> {
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheResult(i, state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1218,4 +1237,11 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDownloadCacheData() {
|
||||
if (mMapView.getMapAutoViewHelper() != null) {
|
||||
mMapView.getMapAutoViewHelper().cancelCacheHDData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,4 +458,11 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDownloadCacheData() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.cancelDownloadCacheData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,26 +27,34 @@ public class GDLocationClient implements AMapLocationListener {
|
||||
}
|
||||
|
||||
//声明LocationClient对象
|
||||
private final AMapLocationClient mLocationClient;
|
||||
private AMapLocationClient mLocationClient;
|
||||
private String mCityCode;
|
||||
|
||||
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);
|
||||
AMapLocationClient.updatePrivacyShow(context, true, true);
|
||||
AMapLocationClient.updatePrivacyAgree(context, true);
|
||||
try {
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mLocationClient.startLocation();
|
||||
if(mLocationClient != null){
|
||||
mLocationClient.startLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -391,4 +391,11 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDownloadCacheData() {
|
||||
if (mClient != null) {
|
||||
mClient.cancelDownloadCacheData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user