From 866196841fa6affb26325463c37f8d90e2d64e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=A3=8E=E5=90=B9=E8=BF=87=E7=9A=84=E5=A4=8F?= =?UTF-8?q?=E5=A4=A9?= Date: Mon, 26 Jun 2023 17:26:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E8=85=BE=E8=AE=AF=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E3=80=81=E9=AB=98=E5=BE=B7=E5=9C=B0=E5=9B=BE=E3=80=81?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E5=9C=B0=E5=9B=BESDK=E5=88=B0=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=EF=BC=9B=20=E9=92=88=E5=AF=B9MapVie?= =?UTF-8?q?w=E5=8D=95=E7=8B=AC=E5=81=9AonDispose=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 4 ++-- README.md | 6 +++--- baidu-map-compose/build.gradle | 2 +- .../src/main/java/com/melody/map/baidu_compose/BDMap.kt | 4 ++++ gd-map-compose/build.gradle | 2 +- .../src/main/java/com/melody/map/gd_compose/GDMap.kt | 4 ++++ gradle_map.properties | 2 +- sample-baidu/build.gradle | 8 ++++---- .../myapplication/repo/DragDropSelectPointRepository.kt | 6 +++--- tencent-map-compose/build.gradle | 2 +- .../src/main/java/com/melody/map/tencent_compose/TXMap.kt | 4 ++++ 11 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2a31e33..ba172b0 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -52,8 +52,8 @@ jobs: artifactErrorsFailBuild: true body: | ### 功能更新 - - 升级高德地图、百度地图SDK到最新版本 - - Compose升级至1.3.3稳定版本 + - 升级腾讯地图、高德地图、百度地图SDK到最新版本 + - 针对MapView单独做onDispose处理 token: ${{ secrets.github_token }} commit: master # tag名称 diff --git a/README.md b/README.md index c0f2c86..8b32bd3 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ OmniMap Compose 🗺 ------- - + - + - +
gd_composeMaven Centralgd_composeMaven Central
tencent_composeMaven Centraltencent_composeMaven Central
baidu_composeMaven Centralbaidu_composeMaven Central
diff --git a/baidu-map-compose/build.gradle b/baidu-map-compose/build.gradle index 2318e5d..bfbff3a 100644 --- a/baidu-map-compose/build.gradle +++ b/baidu-map-compose/build.gradle @@ -46,5 +46,5 @@ dependencies { implementation "androidx.compose.ui:ui:$compose_version" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' // 地图组件 - api 'com.baidu.lbsyun:BaiduMapSDK_Map:7.5.7.1' + api 'com.baidu.lbsyun:BaiduMapSDK_Map:7.5.8' } \ No newline at end of file diff --git a/baidu-map-compose/src/main/java/com/melody/map/baidu_compose/BDMap.kt b/baidu-map-compose/src/main/java/com/melody/map/baidu_compose/BDMap.kt index 00e073c..8bd570c 100644 --- a/baidu-map-compose/src/main/java/com/melody/map/baidu_compose/BDMap.kt +++ b/baidu-map-compose/src/main/java/com/melody/map/baidu_compose/BDMap.kt @@ -156,6 +156,10 @@ private fun MapLifecycle(mapView: MapView) { onDispose { lifecycle.removeObserver(mapLifecycleObserver) + } + } + DisposableEffect(mapView) { + onDispose { // fix memory leak mapView.onDestroy() mapView.removeAllViews() diff --git a/gd-map-compose/build.gradle b/gd-map-compose/build.gradle index eaeba02..e49a458 100644 --- a/gd-map-compose/build.gradle +++ b/gd-map-compose/build.gradle @@ -46,7 +46,7 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' // 高德地图3d - api 'com.amap.api:3dmap:9.6.2' + api 'com.amap.api:3dmap:9.7.0' // 高德地图:搜索相关API,路径规划需要用到这里面的类 api "com.amap.api:search:9.5.0" } \ No newline at end of file diff --git a/gd-map-compose/src/main/java/com/melody/map/gd_compose/GDMap.kt b/gd-map-compose/src/main/java/com/melody/map/gd_compose/GDMap.kt index e1b49af..3e65a1c 100644 --- a/gd-map-compose/src/main/java/com/melody/map/gd_compose/GDMap.kt +++ b/gd-map-compose/src/main/java/com/melody/map/gd_compose/GDMap.kt @@ -164,6 +164,10 @@ private fun MapLifecycle(mapView: MapView) { onDispose { lifecycle.removeObserver(mapLifecycleObserver) context.unregisterComponentCallbacks(callbacks) + } + } + DisposableEffect(mapView) { + onDispose { // fix memory leak mapView.onDestroy() mapView.removeAllViews() diff --git a/gradle_map.properties b/gradle_map.properties index 9b6534a..3bb2d25 100644 --- a/gradle_map.properties +++ b/gradle_map.properties @@ -10,4 +10,4 @@ MIN_SDK_VERSION = 21 HUAWEI_MIN_SDK_VERSION = 24 # publish maven central library version_name -LIB_VERSION_NAME = 1.0.2 \ No newline at end of file +LIB_VERSION_NAME = 1.0.3 \ No newline at end of file diff --git a/sample-baidu/build.gradle b/sample-baidu/build.gradle index d2aa55f..743d48b 100644 --- a/sample-baidu/build.gradle +++ b/sample-baidu/build.gradle @@ -76,12 +76,12 @@ dependencies { implementation project(path: ':sample-ui-components') implementation project(path: ':baidu-map-compose') // 基础库 - implementation 'com.baidu.lbsyun:base:7.5.7.1' + implementation 'com.baidu.lbsyun:base:7.5.8' // 定位组件 - implementation "com.baidu.lbsyun:BaiduMapSDK_Location:9.4.0" + implementation "com.baidu.lbsyun:BaiduMapSDK_Location:9.4.5" // 检索组件 - implementation 'com.baidu.lbsyun:BaiduMapSDK_Search:7.5.7.1' + implementation 'com.baidu.lbsyun:BaiduMapSDK_Search:7.5.8' // 工具组件 - implementation 'com.baidu.lbsyun:BaiduMapSDK_Util:7.5.7.1' + implementation 'com.baidu.lbsyun:BaiduMapSDK_Util:7.5.8' } \ No newline at end of file diff --git a/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/repo/DragDropSelectPointRepository.kt b/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/repo/DragDropSelectPointRepository.kt index ad8ba70..40bdcc7 100644 --- a/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/repo/DragDropSelectPointRepository.kt +++ b/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/repo/DragDropSelectPointRepository.kt @@ -31,7 +31,6 @@ import com.tencent.lbssearch.`object`.param.Geo2AddressParam import com.tencent.lbssearch.`object`.param.SearchParam import com.tencent.lbssearch.`object`.result.Geo2AddressResultObject import com.tencent.lbssearch.`object`.result.SearchResultObject -import com.tencent.map.tools.net.http.HttpResponseListener import com.tencent.tencentmap.mapsdk.maps.model.LatLng import kotlinx.coroutines.suspendCancellableCoroutine @@ -122,7 +121,8 @@ object DragDropSelectPointRepository { .setPageSize(20) .setPolicy(Geo2AddressParam.PoiOptions.POLICY_DEFAULT) ) - tencentSearch.geo2address(geo2AddressParam, object: HttpResponseListener { + tencentSearch.geo2address(geo2AddressParam, object: + com.tencent.lbssearch.httpresponse.HttpResponseListener { override fun onSuccess(p0: Int, arg1: BaseObject?) { val obj = arg1 as? Geo2AddressResultObject? if (null == obj?.result) { @@ -148,7 +148,7 @@ object DragDropSelectPointRepository { val nearBy = SearchParam.Nearby(latLng, 1000) //圆形范围搜索, autoExtend(false) => 设置搜索范围不扩大,这里传true,扩大搜索范围 val searchParam = SearchParam(addressName, SearchParam.Region(cityName).autoExtend(true)).pageSize(20).boundary(nearBy) - search.search(searchParam,object: HttpResponseListener{ + search.search(searchParam,object: com.tencent.lbssearch.httpresponse.HttpResponseListener{ override fun onSuccess(arg0: Int, arg1: BaseObject?) { val obj = arg1 as? SearchResultObject? if (obj?.data == null) { diff --git a/tencent-map-compose/build.gradle b/tencent-map-compose/build.gradle index 29bb085..9860f19 100644 --- a/tencent-map-compose/build.gradle +++ b/tencent-map-compose/build.gradle @@ -47,7 +47,7 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' // 地图库 - api 'com.tencent.map:tencent-map-vector-sdk:5.0.0' + api 'com.tencent.map:tencent-map-vector-sdk:5.1.0' // 地图组件库,包括小车平移、点聚合等组件功能。 api 'com.tencent.map:sdk-utilities:1.0.9.1' } \ No newline at end of file diff --git a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/TXMap.kt b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/TXMap.kt index a6cb8e8..6dc5404 100644 --- a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/TXMap.kt +++ b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/TXMap.kt @@ -150,6 +150,10 @@ private fun MapLifecycle(mapView: MapView) { onDispose { lifecycle.removeObserver(mapLifecycleObserver) + } + } + DisposableEffect(mapView) { + onDispose { // fix memory leak mapView.onDestroy() mapView.removeAllViews()