Skip to content

Commit

Permalink
fix: null pointer exception in ClusterRenderer when continuously upda…
Browse files Browse the repository at this point in the history
…ting cluster item values (#623)

* fix : view to be nullable

* fix : put else condition when view.parent is null draw blank bitmap

* Update maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt

Co-authored-by: Zongle Wang <[email protected]>

* Update maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt

Co-authored-by: Zongle Wang <[email protected]>

---------

Co-authored-by: Zongle Wang <[email protected]>
  • Loading branch information
mohammad-firmansyah and Goooler authored Jan 24, 2025
1 parent f48f421 commit a150235
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ internal class ComposeUiClusterRenderer<T : ClusterItem>(
/* 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)
val viewParent =
view.parent as? ViewGroup ?: return Bitmap.createBitmap(20, 20, Bitmap.Config.ARGB_8888)
.let(BitmapDescriptorFactory::fromBitmap)
view.measure(
View.MeasureSpec.makeMeasureSpec(viewParent.width, View.MeasureSpec.AT_MOST),
View.MeasureSpec.makeMeasureSpec(viewParent.height, View.MeasureSpec.AT_MOST),
Expand Down

0 comments on commit a150235

Please sign in to comment.