From 077f0466d1138f9b59ec13a94a83df8b12548e94 Mon Sep 17 00:00:00 2001 From: "mohammad.firmansyah" Date: Mon, 2 Sep 2024 11:34:52 +0700 Subject: [PATCH] fix : view to be nullable --- .../maps/android/compose/clustering/ClusterRenderer.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt index 9e7859761..c1e902da0 100644 --- a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt +++ b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt @@ -168,11 +168,11 @@ internal class ComposeUiClusterRenderer( } } - private fun renderViewToBitmapDescriptor(view: AbstractComposeView): BitmapDescriptor { + private fun renderViewToBitmapDescriptor(view: AbstractComposeView?): BitmapDescriptor { /* AndroidComposeView triggers LayoutNode's layout phase in the View draw phase, so trigger a draw to an empty canvas to force that */ - view.draw(fakeCanvas) - val viewParent = (view.parent as ViewGroup) + view?.draw(fakeCanvas) + val viewParent = (view?.parent as ViewGroup) view.measure( View.MeasureSpec.makeMeasureSpec(viewParent.width, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(viewParent.height, View.MeasureSpec.AT_MOST), @@ -186,7 +186,6 @@ internal class ComposeUiClusterRenderer( bitmap.applyCanvas { view.draw(this) } - return BitmapDescriptorFactory.fromBitmap(bitmap) }