@@ -118,6 +118,7 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
118
118
myLocationView = (MyLocationView ) view .findViewById (R .id .userLocationView );
119
119
attrView = (ImageView ) view .findViewById (R .id .attributionView );
120
120
logoView = (ImageView ) view .findViewById (R .id .logoView );
121
+ mapZoomButtonController = new MapZoomButtonController (new ZoomButtonsController (this ));
121
122
122
123
// add accessibility support
123
124
setContentDescription (context .getString (R .string .mapbox_mapActionDescription ));
@@ -166,7 +167,7 @@ private void initialiseMap() {
166
167
mapKeyListener = new MapKeyListener (transform , trackingSettings , uiSettings );
167
168
168
169
MapZoomControllerListener zoomListener = new MapZoomControllerListener (mapGestureDetector , uiSettings , transform );
169
- mapZoomButtonController = new MapZoomButtonController ( this , uiSettings , zoomListener );
170
+ mapZoomButtonController . bind ( uiSettings , zoomListener );
170
171
171
172
// inject widgets with MapboxMap
172
173
compassView .setMapboxMap (mapboxMap );
@@ -542,9 +543,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) {
542
543
@ CallSuper
543
544
protected void onDetachedFromWindow () {
544
545
super .onDetachedFromWindow ();
545
- if (mapZoomButtonController != null ) {
546
- mapZoomButtonController .setVisible (false );
547
- }
546
+ mapZoomButtonController .setVisible (false );
548
547
}
549
548
550
549
// Called when view is hidden and shown
@@ -553,11 +552,12 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
553
552
if (isInEditMode ()) {
554
553
return ;
555
554
}
555
+
556
556
if (visibility == View .VISIBLE && nativeMapView == null ) {
557
557
initialiseDrawingSurface (mapboxMapOptions .getTextureMode ());
558
558
}
559
559
560
- if (mapZoomButtonController != null && nativeMapView != null ) {
560
+ if (nativeMapView != null ) {
561
561
mapZoomButtonController .setVisible (visibility == View .VISIBLE );
562
562
}
563
563
}
0 commit comments