Example usage for android.view SurfaceHolder setType

List of usage examples for android.view SurfaceHolder setType

Introduction

In this page you can find the example usage for android.view SurfaceHolder setType.

Prototype

@Deprecated
public void setType(int type);

Source Link

Document

Sets the surface's type.

Usage

From source file:com.google.android.cameraview.SurfaceViewPreview.java

SurfaceViewPreview(Context context, ViewGroup parent) {
    final View view = View.inflate(context, R.layout.surface_view, parent);
    mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view);
    final SurfaceHolder holder = mSurfaceView.getHolder();
    //noinspection deprecation
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(new SurfaceHolder.Callback() {
        @Override//from   w  w w  . j  a v  a  2 s  . c o m
        public void surfaceCreated(SurfaceHolder h) {
        }

        @Override
        public void surfaceChanged(SurfaceHolder h, int format, int width, int height) {
            setSize(width, height);
            if (!ViewCompat.isInLayout(mSurfaceView)) {
                dispatchSurfaceChanged();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder h) {
            setSize(0, 0);
        }
    });
}

From source file:com.octopepper.mediapickerinstagram.commons.cameraview.api9.SurfaceViewPreview.java

public SurfaceViewPreview(Context context, ViewGroup parent) {
    final View view = View.inflate(context, R.layout.surface_view, parent);
    mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view);
    final SurfaceHolder holder = mSurfaceView.getHolder();
    //noinspection deprecation
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(new SurfaceHolder.Callback() {
        @Override/*from  w  ww.  ja v  a 2s  . co  m*/
        public void surfaceCreated(SurfaceHolder h) {
        }

        @Override
        public void surfaceChanged(SurfaceHolder h, int format, int width, int height) {
            setSize(width, height);
            if (!ViewCompat.isInLayout(mSurfaceView)) {
                dispatchSurfaceChanged();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder h) {
            setSize(0, 0);
        }
    });
}

From source file:com.brotherpowers.cameraview.SurfaceViewPreview.java

SurfaceViewPreview(Context context, ViewGroup parent) {
    final View view = View.inflate(context, R.layout.surface_view, parent);
    mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view);

    final SurfaceHolder holder = mSurfaceView.getHolder();
    //noinspection deprecation
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(new SurfaceHolder.Callback() {
        @Override//from w ww  .j  a v a2s .  c  o m
        public void surfaceCreated(SurfaceHolder h) {

        }

        @Override
        public void surfaceChanged(SurfaceHolder h, int format, int width, int height) {
            setSize(width, height);
            if (!ViewCompat.isInLayout(mSurfaceView)) {
                dispatchSurfaceChanged();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder h) {

            setSize(0, 0);
        }
    });

}

From source file:io.mariachi.allianzvision.camera.api9.SurfaceViewPreview.java

public SurfaceViewPreview(Context context, ViewGroup parent) {
    final View view = View.inflate(context, R.layout.surface_view, parent);
    mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view);
    final SurfaceHolder holder = mSurfaceView.getHolder();
    //noinspection deprecation
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(new SurfaceHolder.Callback() {
        @Override//from  w  ww  . jav a  2s . c  o  m
        public void surfaceCreated(SurfaceHolder h) {

        }

        @Override
        public void surfaceChanged(SurfaceHolder h, int format, int width, int height) {
            setSize(width, height);
            if (!ViewCompat.isInLayout(mSurfaceView)) {
                dispatchSurfaceChanged();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder h) {
            setSize(0, 0);
        }
    });

}

From source file:org.artoolkit.ar.samples.nftBook.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);

    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {//from  w w w.  ja va2 s . c o  m
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        nftBookActivity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}

From source file:org.artoolkit.ar.samples.ARNativeES1.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);

    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {//from   w  ww .ja  v  a  2 s  . c o  m
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        ARNativeES1Activity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}

From source file:org.artoolkit.ar.samples.ARNativeOSG.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);

    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {//w w  w .  j  av  a2s  . com
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        ARNativeOSGActivity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}

From source file:org.artoolkit.ar.samples.ARNative.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);

    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {/*from w  w  w .ja va2 s .com*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        ARNativeActivity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}

From source file:com.mobiuso.argo.ARModule.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);

    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {/*from   w  ww.  jav  a 2 s  . c o  m*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        ARMovieActivity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}

From source file:org.artoolkit.ar.samples.nftSimple.CameraSurface.java

@SuppressWarnings("deprecation")
public CameraSurface(Context context) {
    super(context);
    Log.i(TAG, "CameraSurface(): ctor called");
    Activity activityRef = (Activity) context;

    try {//from   w  ww .ja  v a2s  .com
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef,
                    Manifest.permission.CAMERA)) {
                mustAskPermissionFirst = true;
                if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
                    // Will drop in here if user denied permissions access camera before.
                    // Or no uses-permission CAMERA element is in the
                    // manifest file. Must explain to the end user why the app wants
                    // permissions to the camera devices.
                    Toast.makeText(activityRef.getApplicationContext(),
                            "App requires access to camera to be granted", Toast.LENGTH_SHORT).show();
                }
                // Request permission from the user to access the camera.
                Log.i(TAG, "CameraSurface(): must ask user for camera access permission");
                activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA },
                        nftSimpleActivity.REQUEST_CAMERA_PERMISSION_RESULT);
                return;
            }
        }
    } catch (Exception ex) {
        Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage());
        return;
    }

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10.
}