Skip to content

Commit

Permalink
fix: fixed NPE on OnMapAndViewReadyListener (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
kikoso committed Dec 23, 2022
1 parent 8b6d096 commit 71f1f67
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 71f1f67

Please sign in to comment.