[2.14.0][Opt]升级高德地图版本新增对应功能

This commit is contained in:
chenfufeng
2023-02-20 12:02:44 +08:00
parent 36f49d3a51
commit 0f17b2185f
8 changed files with 66 additions and 9 deletions

View File

@@ -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成功
}

View File

@@ -358,4 +358,6 @@ public interface IMogoMapUIController {
* @return
*/
boolean isCityDataCached();
void cancelDownloadCacheData();
}

View File

@@ -58,6 +58,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;
@@ -1051,17 +1052,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);
}
});
}
}
});
}
@@ -1086,4 +1105,11 @@ public class AMapViewWrapper implements IMogoMapView,
}
return true;
}
@Override
public void cancelDownloadCacheData() {
if (mMapView.getMapAutoViewHelper() != null) {
mMapView.getMapAutoViewHelper().cancelCacheHDData();
}
}
}

View File

@@ -466,4 +466,11 @@ public class MogoMapUIController implements IMogoMapUIController {
}
return true;
}
@Override
public void cancelDownloadCacheData() {
if (mDelegate != null) {
mDelegate.cancelDownloadCacheData();
}
}
}

View File

@@ -405,4 +405,11 @@ public class AMapUIController implements IMogoMapUIController {
}
return true;
}
@Override
public void cancelDownloadCacheData() {
if (mClient != null) {
mClient.cancelDownloadCacheData();
}
}
}