Skip to content

Commit

Permalink
Fix #189: Delay auto-zoom to after layout (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob authored May 6, 2024
1 parent 1bc1ebd commit c1d9e25
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver;
import android.widget.Toast;

import com.google.android.gms.common.api.Status;
Expand Down Expand Up @@ -228,7 +229,18 @@ private void setupSearch(Fragment searchFragment) {
@Override public void onMapReady(@NonNull GoogleMap map) {
RangeMapActivity.this.map = map;
MapUtils.setMyLocationEnabledIfPossible(RangeMapActivity.this, map);
zoomFullLondon();
View view = mapFragment.requireView();
if (view.isLaidOut()) {
zoomFullLondon();
} else {
view.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override public void onGlobalLayout() {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
zoomFullLondon();
}
});
}
updateToolbarVisibility();
class MapInteractorListener implements OnMapClickListener, OnMarkerClickListener, OnMapLongClickListener {
private Marker currentMarker;
Expand Down

0 comments on commit c1d9e25

Please sign in to comment.