summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java
blob: ab129188521ff155336085dfe8fe39d0845c3f18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
  }
}