package com.mapzen.tangram;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.FrameLayout;

public class MapView extends FrameLayout {

    protected GLSurfaceView glSurfaceView;
    protected AsyncTask<Void, Void, MapController> getMapTask;

    public MapView(Context context) {

        super(context);

        configureGLSurfaceView();

    }

    public MapView(Context context, AttributeSet attrs) {

        super(context, attrs);

        configureGLSurfaceView();

    }

    public interface OnMapReadyCallback {

        void onMapReady(MapController mapController);

    }

    /**
     * Construct a MapController asynchronously; may only be called from the UI thread
     * @param listener The object to receive the resulting MapController in a callback;
     * the callback will be made on the UI thread
     * @param sceneFilePath Location of the YAML scene file within the asset bundle
     */
    public void getMapAsync(final OnMapReadyCallback listener, final String sceneFilePath) {

        final Context context = getContext();

        getMapTask = new AsyncTask<Void, Void, MapController>() {

            @Override
            protected MapController doInBackground(Void... params) {
                return new MapController(context, sceneFilePath);
            }

            @Override
            protected void onPostExecute(MapController map) {
                map.setView(glSurfaceView);
                addView(glSurfaceView);
                listener.onMapReady(map);
            }

        }.execute();

    }

    protected void configureGLSurfaceView() {

        glSurfaceView = new GLSurfaceView(getContext());
        glSurfaceView.setEGLContextClientVersion(2);
        glSurfaceView.setPreserveEGLContextOnPause(true);
        glSurfaceView.setEGLConfigChooser(new ConfigChooser(8, 8, 8, 0, 16, 0));

    }

    public void onCreate(Bundle savedInstanceState) {

    }

    public void onResume() {

    }

    public void onPause() {

    }

    public void onDestroy() {

        if (getMapTask != null) {
            getMapTask.cancel(true);
        }

    }

    public void onLowMemory() {

    }

}

@@ -614,46 +614,319 @@
     
-public interface OnMapReadyCallback %7B%0A
+/**%0A     * Interface for receiving a %7B@code MapController%7D once it is ready to be used%0A     */%0A    public interface OnMapReadyCallback %7B%0A%0A        /**%0A         * Called when the map is ready to be used%0A         * @param mapController A non-null %7B@code MapController%7D instance for this %7B@code MapView%7D%0A         */
 %0A   
@@ -1011,16 +1011,23 @@
 truct a 
+%7B@code 
 MapContr
@@ -1031,16 +1031,17 @@
 ntroller
+%7D
  asynchr
@@ -1101,24 +1101,24 @@
  @param 
-listener
+callback
  The obj
@@ -1370,24 +1370,24 @@
 allback 
-listener
+callback
 , final 
@@ -1885,16 +1885,16 @@
     
-listener
+callback
 .onM
@@ -2263,138 +2263,566 @@
     
-public void onCreate(Bundle savedInstanceState) %7B%0A%0A    %7D%0A%0A    public void onResume() %7B%0A%0A    %7D%0A%0A    public void onPause() %7B%0A%0A    %7D%0A
+/**%0A     * You must call this method from the parent Activity/Fragment's corresponding method.%0A     */%0A    public void onCreate(Bundle savedInstanceState) %7B%0A%0A    %7D%0A%0A    /**%0A     * You must call this method from the parent Activity/Fragment's corresponding method.%0A     */%0A    public void onResume() %7B%0A%0A    %7D%0A%0A    /**%0A     * You must call this method from the parent Activity/Fragment's corresponding method.%0A     */%0A    public void onPause() %7B%0A%0A    %7D%0A%0A    /**%0A     * You must call this method from the parent Activity/Fragment's corresponding method.%0A     */
 %0A   
@@ -2930,32 +2930,139 @@
       %7D%0A%0A    %7D%0A%0A
+    /**%0A     * You must call this method from the parent Activity/Fragment's corresponding method.%0A     */%0A
     public void 

Add javadoc to MapView