Dismiss a Dialog Fragment from a GoogleMap onInfoWindowClick callback

Viewed 43

So I have a Dialog fragment with a google map populated with a bunch of markers. I was the user to be able to scroll the map clicking on markers to reveal the marker InfoWindow that will give info about the markers location. Once the user has found the location they would like I want them to be able to Click the marker infowindow to select said location. When I call dismiss() from the onInfoWindowClick() callback function my app freezes. if I move the dismiss() call to onMarkerClick() there is no problem and my dialog will dismiss?

Dialog Fragment Header

class MapViewDialog(private val stationList: List<List<String>>) : DialogFragment(),
    OnMapReadyCallback,
    GoogleMap.OnMarkerClickListener,
    GoogleMap.OnInfoWindowClickListener{

on click listeners

    override fun onMarkerClick(p0: Marker?): Boolean {
        //dismiss() *Placed Here it works fine But Not where I want it to Dismiss
        return false
    }

    override fun onInfoWindowClick(p0: Marker?) {           
            dismiss()  //Here it freezes the app          
    }    
}
0 Answers
Related