Example usage for android.view SurfaceView toString

List of usage examples for android.view SurfaceView toString

Introduction

In this page you can find the example usage for android.view SurfaceView toString.

Prototype

public String toString() 

Source Link

Usage

From source file:org.artoolkit.ar.unity.UnityARPlayerActivity.java

@Override
protected void onResume() {
    Log.i(TAG, "onResume()");

    super.onResume();

    ////from  ww w.ja va  2s .c  o  m
    // Wrap the Unity application's view and the camera preview in a FrameLayout;
    //

    //View focusView = getCurrentFocus(); // Save the focus, in case we inadvertently change it.
    //Log.i(TAG, "Focus view is " + focusView.toString() + ".");

    ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
    unityView = (ViewGroup) decorView.getChildAt(0);
    if (unityView == null) {
        Log.e(TAG, "Error: Could not find top view.");
        return;
    }
    //Log.i(TAG, "Top view is " + unityView.toString() + ".");

    // Create a placeholder for us to insert the camera preview capture object to the
    // view hierarchy.
    previewInserter = new FrameLayout(this);
    decorView.removeView(unityView); // We must remove the root view from its parent before we can add it somewhere else.
    decorView.addView(previewInserter);

    //focusView.requestFocus(); // Restore focus.

    // Create the camera preview.
    previewView = new CameraSurface(this);
    previewInserter.addView(previewView, new LayoutParams(128, 128));

    // Now add Unity view back in.
    // In order to ensure that Unity's view covers the camera preview each time onResume
    // is called, find the SurfaceView inside the Unity view hierachy, and
    // set the media overlay mode on it. Add the Unity view AFTER adding the previewView.
    SurfaceView sv = findSurfaceView(unityView);
    if (sv == null) {
        Log.w(TAG, "No SurfaceView found in Unity view hierarchy.");
    } else {
        Log.i(TAG, "Found SurfaceView " + sv.toString() + ".");
        sv.setZOrderMediaOverlay(true);
    }
    previewInserter.addView(unityView);
}