diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java new file mode 100644 index 0000000000..ab12918852 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java @@ -0,0 +1,39 @@ +package com.mapbox.mapboxsdk.maps.renderer.textureview; + +import android.content.Context; +import android.support.annotation.Nullable; +import android.util.AttributeSet; +import android.view.TextureView; + +/** + * {@link android.view.TextureView} extension that notifies a listener when the view is attached to the window, + * which is the point we can create the GL thread. Refs #13601 + */ +public class MapboxTextureView extends TextureView { + + private OnViewAttachedListener listener; + + public MapboxTextureView(Context context) { + super(context); + } + + public MapboxTextureView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setOnViewAttachedListener(@Nullable OnViewAttachedListener listener) { + this.listener = listener; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (listener != null) { + listener.onViewAttached(); + } + } + + public interface OnViewAttachedListener { + void onViewAttached(); + } +} |