[3.2.0][Opt]乘客屏调试面板增加高精地图离线缓存功能
This commit is contained in:
@@ -65,7 +65,9 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.logcatch.ILogViewListener
|
||||
import com.mogo.eagle.core.function.hmi.ui.logcatch.LogInfoView
|
||||
import com.mogo.eagle.core.function.hmi.ui.map.OfflineMapDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.SystemVersionView
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -76,6 +78,7 @@ import com.mogo.eagle.core.utilcode.mogo.permissions.BackgrounderPermission
|
||||
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.*
|
||||
import com.mogo.map.hdcache.IHdCacheListener
|
||||
import com.mogo.map.uicontroller.VisualAngleMode
|
||||
import com.mogo.map.uicontroller.VisualAngleMode.*
|
||||
import kotlinx.android.synthetic.main.view_debug_setting.view.*
|
||||
@@ -180,6 +183,9 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
private var isStarted = false
|
||||
|
||||
// 高精地图是否已缓存
|
||||
private var isHDCached = false
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_debug_setting, this, true)
|
||||
initView()
|
||||
@@ -571,6 +577,32 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
btn_cache_hd_map?.onClick {
|
||||
if (isHDCached) {
|
||||
ToastUtils.showShort(resources.getString(R.string.offline_had_downloaded))
|
||||
} else {
|
||||
if (CallerMapUIServiceManager.getCityCode().isNullOrEmpty()) {// 未拿到高德的cityCode
|
||||
if (mGnssInfo == null || (mGnssInfo!!.longitude <= 0.0 && mGnssInfo!!.latitude <= 0.0)) {// 未拿到高精的经纬度
|
||||
ToastUtils.showShort(resources.getString(R.string.location_try_again))
|
||||
} else {// 拿到了高精的经纬度
|
||||
cacheHDOfflineData(false)
|
||||
}
|
||||
} else {// 拿到高德的cityCode
|
||||
cacheHDOfflineData(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
ThreadUtils.getIoPool().execute {
|
||||
val isCached = CallerMapUIServiceManager.isCityDataCached()
|
||||
isHDCached = isCached
|
||||
UiThreadHandler.post {
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(${if (isCached) "已是最新版" else "待更新"}!)"
|
||||
}
|
||||
}
|
||||
btn_cache_hd_map.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改自车按钮(出租车、小巴车)
|
||||
@@ -2123,6 +2155,52 @@ internal class DebugSettingView @JvmOverloads constructor(
|
||||
Process.killProcess(Process.myPid())
|
||||
}
|
||||
|
||||
private fun cacheHDOfflineData(isGaoDe: Boolean) {
|
||||
var progss = 0
|
||||
if (isGaoDe) {// 拿到了高德地图的cityCode
|
||||
CallerMapUIServiceManager.cacheHDDataByCity(object : IHdCacheListener {
|
||||
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
|
||||
// 更新进度
|
||||
progss = progress.toInt()
|
||||
if (progss == 100) {
|
||||
isHDCached = true
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(已是最新版!)"
|
||||
} else {
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(进度:${progss}%)"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMapHdCacheResult(cityId: Int, state: Int) {
|
||||
if (state == 0) {// 失败
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(下载失败!)"
|
||||
ToastUtils.showShort("下载失败,请重试!")
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {// 只拿到了高精的经纬度
|
||||
mGnssInfo?.let { loc ->
|
||||
CallerMapUIServiceManager.cacheHDDataByCityByLonLat(object : IHdCacheListener {
|
||||
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
|
||||
progss = progress.toInt()
|
||||
if (progss == 100) {
|
||||
isHDCached = true
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(已是最新版!)"
|
||||
} else {
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(进度:${progss}%)"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMapHdCacheResult(cityId: Int, state: Int) {
|
||||
if (state == 0) {// 失败
|
||||
btn_cache_hd_map.text = "缓存高精离线地图(下载失败!)"
|
||||
ToastUtils.showShort("下载失败,请重试!")
|
||||
}
|
||||
}
|
||||
}, loc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun fwThreadClose() {
|
||||
refreshTraceInfo()
|
||||
}
|
||||
|
||||
@@ -1560,6 +1560,21 @@
|
||||
app:layout_constraintRight_toRightOf="@id/changesight_cross_btn"
|
||||
app:layout_constraintTop_toBottomOf="@id/changesight_cross_btn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cache_hd_map"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:gravity="center"
|
||||
android:text="缓存高精离线地图"
|
||||
android:padding="@dimen/dp_20"
|
||||
android:textSize="@dimen/dp_24"
|
||||
app:layout_constraintLeft_toRightOf="@id/reset_changesight"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/changesight_far_btn"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbChangeCurrentCarIcon"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -1084,7 +1084,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||||
}
|
||||
});
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheResult(i, state);
|
||||
}
|
||||
});
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1124,7 +1124,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||||
}
|
||||
});
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1139,7 +1139,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (hdCacheListener != null) {
|
||||
hdCacheListener.onMapHdCacheResult(i, state);
|
||||
}
|
||||
});
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user