|
4 | 4 | import android.graphics.Canvas;
|
5 | 5 | import android.graphics.PointF;
|
6 | 6 | import android.graphics.SurfaceTexture;
|
| 7 | +import android.os.Build; |
7 | 8 | import android.os.Bundle;
|
8 | 9 | import android.support.annotation.CallSuper;
|
9 | 10 | import android.support.annotation.IntDef;
|
|
21 | 22 | import android.view.TextureView;
|
22 | 23 | import android.view.View;
|
23 | 24 | import android.view.ViewGroup;
|
| 25 | +import android.view.ViewTreeObserver; |
24 | 26 | import android.widget.FrameLayout;
|
25 | 27 | import android.widget.ImageView;
|
26 | 28 | import android.widget.ZoomButtonsController;
|
@@ -122,6 +124,18 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
|
122 | 124 | // add accessibility support
|
123 | 125 | setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
|
124 | 126 | setWillNotDraw(false);
|
| 127 | + |
| 128 | + getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { |
| 129 | + @Override |
| 130 | + public void onGlobalLayout() { |
| 131 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
| 132 | + getViewTreeObserver().removeOnGlobalLayoutListener(this); |
| 133 | + } else { |
| 134 | + getViewTreeObserver().removeGlobalOnLayoutListener(this); |
| 135 | + } |
| 136 | + initialiseDrawingSurface(mapboxMapOptions.getTextureMode()); |
| 137 | + } |
| 138 | + }); |
125 | 139 | }
|
126 | 140 |
|
127 | 141 | private void initialiseMap() {
|
@@ -553,9 +567,6 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
|
553 | 567 | if (isInEditMode()) {
|
554 | 568 | return;
|
555 | 569 | }
|
556 |
| - if (visibility == View.VISIBLE && nativeMapView == null) { |
557 |
| - initialiseDrawingSurface(mapboxMapOptions.getTextureMode()); |
558 |
| - } |
559 | 570 |
|
560 | 571 | if (mapZoomButtonController != null && nativeMapView != null) {
|
561 | 572 | mapZoomButtonController.setVisible(visibility == View.VISIBLE);
|
|
0 commit comments