There are 2 buttons A and B, when you click on A., a certain b.OnClickListener is launched.
What are the consequences of this approach? Leaks did not notice ....
Button button=new Button(this); button.setOnClickListener(v -> { mapFragment.getMapAsync(googleMap -> { System.out.println("TEST"); }); }); @pavlofff , you probably did not understand what I want to know). I don’t know about GC. But I am studying MVP now and have encountered a problem when using Google Maps. I found a theme in SO like my GoogleMap MVP task. I decided to try the code. The code is working, but it is not clear how it works. When you rotate the screen. Throws a NullPointer error in addMarkersOnMap .
I solved this problem and moved mapFragment.getMapAsync(googleMap -> to addMarkersOnMap . When you turn, everything works well and nothing is caused. Only the data is added to the map.
The addMarkersOnMap method addMarkersOnMap called several times. It can be called 10 times with an interval of 2 seconds, for example. Therefore, I want to know if it is right to do so. If not, what alternative way to find, to solve my problem.