Skip to content

Commit

Permalink
fix: fixed NPE on OnMapAndViewReadyListener
Browse files Browse the repository at this point in the history
  • Loading branch information
kikoso committed Nov 29, 2022
1 parent 9d990d4 commit d27695e
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ class OnMapAndViewReadyListener(

private fun registerListeners() {
// View layout.
if (mapView?.width != 0 && mapView?.height != 0) {
// View has already completed layout.
isViewReady = true
} else {
// Map has not undergone layout, register a View observer.
mapView.viewTreeObserver.addOnGlobalLayoutListener(this)
mapView?.let {
if (it.width != 0 && it.height != 0) {
// View has already completed layout.
isViewReady = true
} else {
// Map has not undergone layout, register a View observer.
it.viewTreeObserver.addOnGlobalLayoutListener(this)
}
}

// GoogleMap. Note if the GoogleMap is already ready it will still fire the callback later.
mapFragment.getMapAsync(this)
}
Expand Down

0 comments on commit d27695e

Please sign in to comment.