From b8be78442018d96fc95504c26a0aaced47438cd8 Mon Sep 17 00:00:00 2001 From: jiaguofeng Date: Tue, 26 Sep 2023 10:25:42 +0800 Subject: [PATCH] =?UTF-8?q?[map-sdk]=E4=BF=AE=E6=94=B9=E9=94=9A=E7=82=B9?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=B5=84=E6=BA=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../map/sdk/open/location/MyLocationStyle.kt | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/open/location/MyLocationStyle.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/open/location/MyLocationStyle.kt index c7bf674f14..c0acb1a24b 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/open/location/MyLocationStyle.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/open/location/MyLocationStyle.kt @@ -125,20 +125,20 @@ class MyLocationStyle( } @Synchronized - private fun drawCar(bitmap: Bitmap) { + private fun drawCar(bitmap: Bitmap): Boolean { if (CompileConfig.DEBUG) { Log.i(TAG, "markerop---selfop--drawCar:start") } if (mMarker != null) { mMarker?.setIcon(bitmap) - return + return true } if ((mMapController?.isSurfaceCreated()) == true) { if (executeFlag.get()) { - return + return false } if (mMarker != null) { - return + return false } executeFlag.set(true) val lon = mLonLat.lon @@ -154,16 +154,19 @@ class MyLocationStyle( if (CompileConfig.DEBUG) { Log.i(TAG, "autoop--selfop--markerop--drawCar:${mMarker?.getId()}") } + return true } catch (e: Exception) { mMarker = null + return false } finally { executeFlag.set(false) } } + return false } - private fun draw3DCar(resId: Int) { + private fun draw3DCar(resId: Int): Boolean{ if (CompileConfig.DEBUG) { Log.i( TAG, @@ -196,17 +199,17 @@ class MyLocationStyle( } carId = resId - return + return true } if ((mMapController?.isSurfaceCreated()) ?: false) { if (CompileConfig.DEBUG) { Log.i(TAG, "markerop---selfop--draw3DCar:start:mapView SurfaceCreated") } if (executeFlag.get()) { - return + return false } if (mMarker != null) { - return + return false } executeFlag.set(true) val lon = mLonLat.lon @@ -238,15 +241,18 @@ class MyLocationStyle( "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()},${resId},${options.getMarkerIconName()}" ) } + return true } catch (e: Exception) { if (CompileConfig.DEBUG) { Log.e(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()}", e) } mMarker = null + return false } finally { executeFlag.set(false) } } + return false } fun setLonLat(lonLat: LonLat, angle: Double) { @@ -339,7 +345,7 @@ class MyLocationStyle( mMarker?.setScale(scale) } - fun myLocationIcon(carResId: Int, is3D: Boolean): MyLocationStyle { + fun myLocationIcon(carResId: Int, is3D: Boolean): Boolean { mMapController?.getClerk()?.add("$is3D,$carResId") if (CompileConfig.DEBUG) { Log.i( @@ -352,22 +358,23 @@ class MyLocationStyle( this.is3D = is3D if (is3D) { this.car3DResId = carResId - draw3DCar(carResId) + return draw3DCar(carResId) } else { this.carResId = carResId val bitmap = BitmapFactory.decodeResource(mContext?.resources, carResId) + carId = carResId bitmap?.let { if (this.myLocationIcon != null) { this.myLocationIcon?.recycle() this.myLocationIcon = null } - drawCar(it) + return drawCar(it) } - carId = carResId + } } - return this + return false } fun myLocationIcon(carResId: Int): MyLocationStyle {