diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index f8dd7bd27d..582699cdbf 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -515,6 +515,10 @@ class MoGoHmiFragment : MvpFragment(), statusBarView?.updateMfStatus(tag, status) } + override fun updateHDDataCacheStatus(isCached: Boolean) { + toolsView?.updateHDDataCacheStatus(isCached) + } + /** * 设置 红绿灯 代理View */ @@ -1591,7 +1595,6 @@ class MoGoHmiFragment : MvpFragment(), } } - override fun setTurnLightFunction(isOpen: Boolean) { HmiBuildConfig.isShowTurnLightView = isOpen } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/map/OfflineMapDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/map/OfflineMapDialog.kt new file mode 100644 index 0000000000..aa62c470b2 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/map/OfflineMapDialog.kt @@ -0,0 +1,170 @@ +package com.mogo.eagle.core.function.hmi.ui.map + +import android.annotation.SuppressLint +import android.content.Context +import android.view.View +import android.widget.ImageView +import android.widget.ProgressBar +import android.widget.TextView +import androidx.annotation.MainThread +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat +import androidx.core.content.res.ResourcesCompat +import androidx.core.view.marginTop +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog +import com.mogo.map.hdcache.IHdCacheListener +import me.jessyan.autosize.utils.AutoSizeUtils + +/** + * 离线地图缓存 + */ +class OfflineMapDialog(context: Context): BaseFloatDialog(context) { + + private var roundRootLayout: ConstraintLayout? = null + private var offlineTitleView: TextView? = null + private var leftView: TextView? = null + private var rightView: TextView? = null + private var okView: TextView? = null + private var vertLineView: View? = null + private var horizontalLineView: View? = null + private var cacheTipView: TextView? = null + + private var progressBar: ProgressBar? = null + private var downloadPercentView: TextView? = null + private var downloadResultImg: ImageView? = null + + private var isLoading = false + private var isConfirm = true + private var isRetry = false + + init { + setContentView(R.layout.dialog_offline_map) + setCanceledOnTouchOutside(true) + + initView() + } + + private fun initView() { + roundRootLayout = findViewById(R.id.roundRootLayout) + offlineTitleView = findViewById(R.id.tv_cache_title) + progressBar = findViewById(R.id.progressBar) + downloadPercentView = findViewById(R.id.tvDownloadProgress) + leftView = findViewById(R.id.tv_cache_confirm) + rightView = findViewById(R.id.tv_cache_cancel) + okView = findViewById(R.id.tv_cache_ok) + vertLineView = findViewById(R.id.view_vertical_line) + horizontalLineView = findViewById(R.id.view_horizontal_line) + cacheTipView = findViewById(R.id.tv_cache_tips) + downloadResultImg = findViewById(R.id.iv_download_Status) + + leftView?.setOnClickListener { + when { + isConfirm -> { + cacheHDOfflineData() + showNewContent(isLoading = true, false) + } + else -> { + dismiss() + } + } + } + + rightView?.setOnClickListener { + when { + isRetry -> { + cacheHDOfflineData() + } + else -> { + dismiss() + } + } + } + + okView?.setOnClickListener { + dismiss() + } + } + + private fun cacheHDOfflineData() { + CallerMapUIServiceManager.cacheHDDataByCity(object : IHdCacheListener { + override fun onMapHdCacheProgress(cityId: Int, progress: Double) { + updateProgress(progress.toInt()) + } + }) + } + + @SuppressLint("SetTextI18n") + private fun updateProgress(progress: Int) { + if (this@OfflineMapDialog.isShowing) { + progressBar?.let { + if (it.visibility == View.VISIBLE) { + it.progress = if (progress in 1..5) 5 else progress + } + } + downloadPercentView?.text = "$progress%" + if (progress == 100) { + showNewContent(isLoading = false, true) + CallerHmiManager.updateHDDataCacheStatus(true) + } + } + } + + private fun change2NewStyle() { + roundRootLayout?.layoutParams?.width = AutoSizeUtils.dp2px(context, 1110f) + roundRootLayout?.layoutParams?.height = AutoSizeUtils.dp2px(context, 668f) + + val titleParams = offlineTitleView?.layoutParams as ConstraintLayout.LayoutParams + titleParams.topMargin = AutoSizeUtils.dp2px(context, 51f) + + val horizontalLineParams = horizontalLineView?.layoutParams as ConstraintLayout.LayoutParams + horizontalLineParams.topMargin = AutoSizeUtils.dp2px(context, 374f) + + progressBar?.visibility = View.VISIBLE + downloadPercentView?.visibility = View.VISIBLE + okView?.visibility = View.VISIBLE + + vertLineView?.visibility = View.GONE + leftView?.visibility = View.GONE + rightView?.visibility = View.GONE + cacheTipView?.visibility = View.INVISIBLE + } + + @SuppressLint("UseCompatLoadingForDrawables") + private fun showNewContent(isLoading: Boolean, isSuccess: Boolean) { + change2NewStyle() + when { + isLoading -> { + okView?.text = context.resources.getString(R.string.cancel) + offlineTitleView?.text = context.resources.getString(R.string.offline_downloading) + downloadResultImg?.visibility = View.GONE + } + else -> { + downloadResultImg?.visibility = View.VISIBLE + when { + isSuccess -> { + okView?.visibility = View.VISIBLE + okView?.text = context.resources.getString(R.string.ok_tip) + offlineTitleView?.text = context.resources.getString(R.string.offline_download_success) + progressBar?.visibility = View.GONE + downloadPercentView?.visibility = View.GONE + downloadResultImg?.background = ContextCompat.getDrawable(context, R.drawable.download_success_icon) + } + else -> { + offlineTitleView?.text = context.resources.getString(R.string.offline_download_failure) + okView?.visibility = View.GONE + progressBar?.visibility = View.GONE + downloadPercentView?.visibility = View.GONE + leftView?.visibility = View.VISIBLE + rightView?.visibility = View.VISIBLE + vertLineView?.visibility = View.VISIBLE + rightView?.text = context.resources.getString(R.string.retry) + downloadResultImg?.background = ContextCompat.getDrawable(context, R.drawable.download_fail_icon) + } + } + } + } + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt index 7bc486bb84..aced13e3b1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt @@ -201,6 +201,9 @@ class AutoPilotAndCheckView @JvmOverloads constructor( systemVersionView?.showAdUpgradeStatus(ipcUpgradeStateInfo) } + fun updateHDDataCacheStatus(isCached: Boolean) { + systemVersionView?.updateHDDataCacheStatus(isCached) + } override fun onAttachedToWindow() { super.onAttachedToWindow() diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt index 8044145aff..41a04ccee5 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt @@ -1,26 +1,21 @@ package com.mogo.eagle.core.function.hmi.ui.widget -import android.app.NotificationManager import android.content.Context import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout -import androidx.core.app.NotificationCompat import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo import com.mogo.eagle.core.data.bindingcar.AdUpgradeStateHelper import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingCarListener -import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerManager import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager -import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showUpgradeDialog +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.ui.map.OfflineMapDialog import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI import com.mogo.eagle.core.utilcode.util.AppUtils @@ -142,6 +137,12 @@ class SystemVersionView @JvmOverloads constructor( } + ivHDCache.setOnClickListener { + OfflineMapDialog(context).show() + } + + updateHDDataCacheStatus(CallerMapUIServiceManager.isCityDataCached()) + if(AdUpgradeStateHelper.isConfirmUpgrade()){ //将角标改为“下载中” ivAdStatus?.setImageResource(R.drawable.icon_downloading) @@ -246,6 +247,16 @@ class SystemVersionView @JvmOverloads constructor( } + fun updateHDDataCacheStatus(isCached: Boolean) { + if (isCached) { + ivHDCacheStatus?.setImageResource(R.drawable.icon_latest_version) + ivHDCache.isEnabled = false + } else { + ivHDCacheStatus?.setImageResource(R.drawable.icon_be_updated) + ivHDCache.isEnabled = true + } + } + /** * 展示当前鹰眼版本 */ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_fail_icon.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_fail_icon.png new file mode 100644 index 0000000000..809d7ee414 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_fail_icon.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_success_icon.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_success_icon.png new file mode 100644 index 0000000000..f6f1197a93 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/download_success_icon.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_be_updated.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_be_updated.png new file mode 100644 index 0000000000..b9268797cf Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_be_updated.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_hd_map.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_hd_map.png new file mode 100644 index 0000000000..ccbe7ffd56 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_hd_map.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/progressbar_corner_bg.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/progressbar_corner_bg.xml new file mode 100644 index 0000000000..753149f4ea --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/progressbar_corner_bg.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_offline_map.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_offline_map.xml new file mode 100644 index 0000000000..6ae72b0a13 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/dialog_offline_map.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_system_version.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_system_version.xml index ce0064ad18..3972c865ff 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_system_version.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_system_version.xml @@ -82,7 +82,6 @@ android:visibility="gone" /> - + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml index 333b277f12..dc18d3181a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/color.xml @@ -74,4 +74,5 @@ #FF282F62 #FFFFFF + #E63B4577 \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml index 90c260be7e..3ef5be5b45 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml @@ -53,4 +53,11 @@ 是否绑定车机? 蘑菇星云 + 离线地图缓存提醒 + 是否缓存最新版本离线地图? + 离线地图下载中 + 离线地图下载成功 + 离线地图下载失败 + 确定 + 重试 diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt index eb8e799ed2..122866ef06 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt @@ -312,4 +312,5 @@ interface IMoGoWaringProvider : IMoGoHmiViewProxy { */ fun updateMfStatus(tag: String, status: Boolean) + fun updateHDDataCacheStatus(isCached: Boolean) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt index 1c8aa2182e..38c385b3e9 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt @@ -498,6 +498,7 @@ object CallerHmiManager : CallerBase() { waringProviderApi?.updateMfStatus(tag, status) } - - + fun updateHDDataCacheStatus(isCached: Boolean) { + waringProviderApi?.updateHDDataCacheStatus(isCached) + } } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapUIServiceManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapUIServiceManager.kt index 2c2698f641..571b02d4b9 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapUIServiceManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapUIServiceManager.kt @@ -5,6 +5,7 @@ import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.map.IMogoMapService import com.mogo.eagle.core.function.api.map.marker.IMogoMarkerService import com.mogo.eagle.core.function.call.base.CallerBase +import com.mogo.map.hdcache.IHdCacheListener import com.mogo.map.listener.IMogoHosListenerRegister import com.mogo.map.location.IMogoLocationClient import com.mogo.map.marker.IMogoMarkerManager @@ -42,4 +43,12 @@ object CallerMapUIServiceManager { fun getMarkerService(): IMogoMarkerService? { return serviceProvider?.markerService } + + fun cacheHDDataByCity(listener: IHdCacheListener) { + serviceProvider?.mapUIController?.cacheHDDataByCity(listener) + } + + fun isCityDataCached(): Boolean { + return serviceProvider?.mapUIController?.isCityDataCached ?: true + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 05094db3c7..8dcee00caa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -85,7 +85,7 @@ MOGO_LOCATION_VERSION=1.4.3.32 MOGO_TELEMATIC_VERSION=1.4.3.32 ######## MogoAiCloudSDK Version ######## # 自研地图 -MAP_SDK_VERSION=2.9.0.14_test_06 +MAP_SDK_VERSION=2.10.0.2 MAP_SDK_OPERATION_VERSION=1.1.4.1 # websocket WEBSOCKET_VERSION=1.1.7 diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt new file mode 100644 index 0000000000..4761e40fff --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt @@ -0,0 +1,5 @@ +package com.mogo.map.hdcache + +interface IHdCacheListener { + fun onMapHdCacheProgress(cityId: Int, progress: Double) +} \ No newline at end of file diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 09ebf694d4..eaa04ac0c6 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -10,6 +10,7 @@ import androidx.annotation.RawRes; import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.map.hdcache.IHdCacheListener; import org.json.JSONObject; @@ -340,4 +341,11 @@ public interface IMogoMapUIController { */ void setAllGesturesEnabled(boolean isEnable); + void cacheHDDataByCity(IHdCacheListener listener); + + /** + * 当前城市离线数据是否已缓存 + * @return + */ + boolean isCityDataCached(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java index e1266b96c7..6e65bd6ca2 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java @@ -26,6 +26,7 @@ import android.util.Log; import android.view.MotionEvent; import android.view.View; +import androidx.annotation.MainThread; import androidx.annotation.NonNull; import com.mogo.commons.constants.SharedPrefsConstants; @@ -46,7 +47,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.mogo.toast.TipToast; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.map.hdcache.IHdCacheListener; import com.mogo.map.listener.MogoMapListenerHandler; +import com.mogo.map.location.GDLocationClient; import com.mogo.map.navi.MogoCarLocationChangedListenerRegister; import com.mogo.map.uicontroller.CarCursorOption; import com.mogo.map.uicontroller.EnumMapUI; @@ -54,6 +57,7 @@ import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; import com.mogo.map.uicontroller.VisualAngleMode; +import com.mogo.map.utils.HDMapUtils; import com.mogo.map.utils.MogoMapUtils; import com.mogo.map.utils.ObjectUtils; import com.mogo.map.utils.ResIdCache; @@ -70,6 +74,7 @@ import com.zhidaoauto.map.sdk.open.abs.log.ILog; import com.zhidaoauto.map.sdk.open.camera.CameraPosition; import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory; import com.zhidaoauto.map.sdk.open.camera.LatLngBounds; +import com.zhidaoauto.map.sdk.open.data.CityInfo; import com.zhidaoauto.map.sdk.open.data.MapDataApi; import com.zhidaoauto.map.sdk.open.location.LocationClient; import com.zhidaoauto.map.sdk.open.location.LocationListener; @@ -126,6 +131,7 @@ public class AMapViewWrapper implements IMogoMapView, private boolean mIsDelayed = false; private final LocationListener mGpsLocationListener = location -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(ObjectUtils.fromLocation(location), 0, true); + private IHdCacheListener hdCacheListener; public AMapViewWrapper(MapAutoView mMapView) { CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--AMapViewWrapper: init"); @@ -1169,4 +1175,47 @@ public class AMapViewWrapper implements IMogoMapView, mMapView.getMapAutoViewHelper().setAllGesturesEnabled(isEnable); } } + + @Override + public void cacheHDDataByCity(IHdCacheListener listener) { + if (mMapView.getMapAutoViewHelper() != null) { + String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode(); + 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(() -> { + if (hdCacheListener != null) { + hdCacheListener.onMapHdCacheProgress(cityId, progress * 100); + } + }); + } + }); + } + } + } + + @Override + public boolean isCityDataCached() { + if (mMapView.getMapAutoViewHelper() != null) { + String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode(); + Integer id = HDMapUtils.getHDCityCode(gdCityCode); + if (id != null) { + List cityInfoList = mMapView.getMapAutoViewHelper().getAllCityCode(); + if (cityInfoList != null) { + for (CityInfo cityInfo : cityInfoList) { + if (id == cityInfo.getCityCode()) { + return cityInfo.isCache; + } + } + } + } + } + return true; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index 431623fe4e..edda8cd20b 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -3,14 +3,13 @@ package com.mogo.map; import android.graphics.Point; import android.graphics.Rect; import android.location.Location; -import android.util.Log; import android.view.View; import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.map.hdcache.IHdCacheListener; import com.mogo.map.uicontroller.CarCursorOption; -import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; @@ -444,4 +443,19 @@ public class MogoMapUIController implements IMogoMapUIController { mDelegate.setAllGesturesEnabled(isEnable); } } + + @Override + public void cacheHDDataByCity(IHdCacheListener listener) { + if (mDelegate != null) { + mDelegate.cacheHDDataByCity(listener); + } + } + + @Override + public boolean isCityDataCached() { + if (mDelegate != null) { + return mDelegate.isCityDataCached(); + } + return true; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java index 7b75cd8e64..7a4d26ad38 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java @@ -8,6 +8,7 @@ import android.view.View; import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.map.hdcache.IHdCacheListener; import com.zhidaoauto.map.sdk.open.MapAutoApi; import org.json.JSONObject; @@ -375,4 +376,19 @@ public class AMapUIController implements IMogoMapUIController { mClient.setAllGesturesEnabled(isEnable); } } + + @Override + public void cacheHDDataByCity(IHdCacheListener listener) { + if (mClient != null) { + mClient.cacheHDDataByCity(listener); + } + } + + @Override + public boolean isCityDataCached() { + if (mClient != null) { + return mClient.isCityDataCached(); + } + return true; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/utils/HDMapUtils.kt b/libraries/mogo-map/src/main/java/com/mogo/map/utils/HDMapUtils.kt new file mode 100644 index 0000000000..b15a5c2704 --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/utils/HDMapUtils.kt @@ -0,0 +1,27 @@ +package com.mogo.map.utils + +object HDMapUtils { + private val cityCodeMap by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { + val map = HashMap() + map["0831"] = 5115// 宜宾市 + map["0512"] = 3205// 苏州市 + map["0872"] = 5329// 大理市 + map["0711"] = 4207// 鄂州市 + map["028"] = 5101// 成都市 + map["0931"] = 6201// 兰州市 + map["0535"] = 3706// 烟台市 + map["027"] = 4201// 武汉市 + map["010"] = 1101// 北京市 + map["0734"] = 4304// 衡阳市 + map + } + + /** + * gdCityCode: 高德CityCode + * return: 高精地图CityCode + */ + @JvmStatic + fun getHDCityCode(gdCityCode: String?): Int? { + return cityCodeMap[gdCityCode] + } +} \ No newline at end of file