[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

@@ -81,6 +81,9 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
}
okView?.setOnClickListener {
if (isLoading) {
CallerMapUIServiceManager.cancelDownloadCacheData()
}
dismiss()
}
}
@@ -90,6 +93,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)
}
}
})
}
@@ -131,6 +140,7 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
@SuppressLint("UseCompatLoadingForDrawables")
private fun showNewContent(isLoading: Boolean, isSuccess: Boolean) {
this.isLoading = isLoading
change2NewStyle()
when {
isLoading -> {

View File

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

View File

@@ -46,4 +46,8 @@ object CallerMapUIServiceManager {
fun getGDLocationServer(context: Context): IMogoGDLocationClient?{
return serviceProvider?.getGDLocationServer(context)
}
fun cancelDownloadCacheData() {
serviceProvider?.mapUIController?.cancelDownloadCacheData()
}
}

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