Search in sources :

Example 76 with SurfaceView

use of android.view.SurfaceView in project android_frameworks_base by DirtyUnicorns.

the class MffContext method createDummySurfaceView.

@SuppressWarnings("deprecation")
private SurfaceView createDummySurfaceView(Context context) {
    // This is only called on Gingerbread devices, so deprecation warning is unnecessary.
    SurfaceView dummySurfaceView = new SurfaceView(context);
    dummySurfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    // If we have an activity for this context we'll add the SurfaceView to it (as a 1x1 view
    // in the top-left corner). If not, we warn the user that they may need to add one manually.
    Activity activity = findActivityForContext(context);
    if (activity != null) {
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1, 1);
        activity.addContentView(dummySurfaceView, params);
    } else {
        Log.w("MffContext", "Could not find activity for dummy surface! Consider specifying " + "your own SurfaceView!");
    }
    return dummySurfaceView;
}
Also used : ViewGroup(android.view.ViewGroup) Activity(android.app.Activity) SurfaceView(android.view.SurfaceView)

Example 77 with SurfaceView

use of android.view.SurfaceView in project XobotOS by xamarin.

the class ViewManager method requestLayout.

/**
     * This should only be called from the UI thread.
     */
private void requestLayout(ChildView v) {
    int width = mWebView.contentToViewDimension(v.width);
    int height = mWebView.contentToViewDimension(v.height);
    int x = mWebView.contentToViewX(v.x);
    int y = mWebView.contentToViewY(v.y);
    AbsoluteLayout.LayoutParams lp;
    ViewGroup.LayoutParams layoutParams = v.mView.getLayoutParams();
    if (layoutParams instanceof AbsoluteLayout.LayoutParams) {
        lp = (AbsoluteLayout.LayoutParams) layoutParams;
        lp.width = width;
        lp.height = height;
        lp.x = x;
        lp.y = y;
    } else {
        lp = new AbsoluteLayout.LayoutParams(width, height, x, y);
    }
    // apply the layout to the view
    v.mView.setLayoutParams(lp);
    if (v.mView instanceof SurfaceView) {
        final SurfaceView sView = (SurfaceView) v.mView;
        if (sView.isFixedSize() && mZoomInProgress) {
            /* If we're already fixed, and we're in a zoom, then do nothing
                   about the size. Just wait until we get called at the end of
                   the zoom session (with mZoomInProgress false) and we'll
                   fixup our size then.
                 */
            return;
        }
        /* Compute proportional fixed width/height if necessary.
             *
             * NOTE: plugins (e.g. Flash) must not explicitly fix the size of
             * their surface. The logic below will result in unexpected behavior
             * for the plugin if they attempt to fix the size of the surface.
             */
        int fixedW = width;
        int fixedH = height;
        if (fixedW > MAX_SURFACE_DIMENSION || fixedH > MAX_SURFACE_DIMENSION) {
            if (v.width > v.height) {
                fixedW = MAX_SURFACE_DIMENSION;
                fixedH = v.height * MAX_SURFACE_DIMENSION / v.width;
            } else {
                fixedH = MAX_SURFACE_DIMENSION;
                fixedW = v.width * MAX_SURFACE_DIMENSION / v.height;
            }
        }
        if (fixedW * fixedH > MAX_SURFACE_AREA) {
            float area = MAX_SURFACE_AREA;
            if (v.width > v.height) {
                fixedW = (int) Math.sqrt(area * v.width / v.height);
                fixedH = v.height * fixedW / v.width;
            } else {
                fixedH = (int) Math.sqrt(area * v.height / v.width);
                fixedW = v.width * fixedH / v.height;
            }
        }
        if (fixedW != width || fixedH != height) {
            // if we get here, either our dimensions or area (or both)
            // exeeded our max, so we had to compute fixedW and fixedH
            sView.getHolder().setFixedSize(fixedW, fixedH);
        } else if (!sView.isFixedSize() && mZoomInProgress) {
            // just freeze where we were (view size) until we're done with
            // the zoom progress
            sView.getHolder().setFixedSize(sView.getWidth(), sView.getHeight());
        } else if (sView.isFixedSize() && !mZoomInProgress) {
            /* The changing of visibility is a hack to get around a bug in
                 * the framework that causes the surface to revert to the size
                 * it was prior to being fixed before it redraws using the
                 * values currently in its layout.
                 *
                 * The surface is destroyed when it is set to invisible and then
                 * recreated at the new dimensions when it is made visible. The
                 * same destroy/create step occurs without the change in
                 * visibility, but then exhibits the behavior described in the
                 * previous paragraph.
                 */
            if (sView.getVisibility() == View.VISIBLE) {
                sView.setVisibility(View.INVISIBLE);
                sView.getHolder().setSizeFromLayout();
                // setLayoutParams() only requests the layout. If we set it
                // to VISIBLE now, it will use the old dimension to set the
                // size. Post a message to ensure that it shows the new size.
                mWebView.mPrivateHandler.post(new Runnable() {

                    public void run() {
                        sView.setVisibility(View.VISIBLE);
                    }
                });
            } else {
                sView.getHolder().setSizeFromLayout();
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) AbsoluteLayout(android.widget.AbsoluteLayout) SurfaceView(android.view.SurfaceView)

Example 78 with SurfaceView

use of android.view.SurfaceView in project XobotOS by xamarin.

the class PluginFullScreenHolder method setContentView.

public void setContentView(View contentView) {
    // Create a FrameLayout that will contain the plugin's view
    mLayout = new CustomFrameLayout(mWebView.getContext());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    mLayout.addView(contentView, layoutParams);
    mLayout.setVisibility(View.VISIBLE);
    // by the ViewManager when it is re-attached to the WebView.
    if (contentView instanceof SurfaceView) {
        final SurfaceView sView = (SurfaceView) contentView;
        if (sView.isFixedSize()) {
            sView.getHolder().setSizeFromLayout();
        }
    }
    mContentView = contentView;
}
Also used : FrameLayout(android.widget.FrameLayout) SurfaceView(android.view.SurfaceView)

Example 79 with SurfaceView

use of android.view.SurfaceView in project QRCode by 5peak2me.

the class CaptureActivity method onPause.

@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    inactivityTimer.onPause();
    ambientLightManager.stop();
    beepManager.close();
    // 关闭摄像头
    cameraManager.closeDriver();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.capture_preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Example 80 with SurfaceView

use of android.view.SurfaceView in project zxing by zxing.

the class CaptureActivity method onPause.

@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    inactivityTimer.onPause();
    ambientLightManager.stop();
    beepManager.close();
    cameraManager.closeDriver();
    //historyManager = null; // Keep for onActivityResult
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Aggregations

SurfaceView (android.view.SurfaceView)93 SurfaceHolder (android.view.SurfaceHolder)45 View (android.view.View)24 SurfaceTexture (android.graphics.SurfaceTexture)16 Surface (android.view.Surface)13 Button (android.widget.Button)12 Intent (android.content.Intent)11 FrameLayout (android.widget.FrameLayout)11 Bitmap (android.graphics.Bitmap)8 TextView (android.widget.TextView)8 FileOutputStream (java.io.FileOutputStream)8 MotionEvent (android.view.MotionEvent)6 ViewGroup (android.view.ViewGroup)6 ImageView (android.widget.ImageView)6 OnClickListener (android.view.View.OnClickListener)5 CameraManager (com.google.zxing.client.android.camera.CameraManager)5 Activity (android.app.Activity)4 PendingIntent (android.app.PendingIntent)4 IntentFilter (android.content.IntentFilter)4 UsbDevice (android.hardware.usb.UsbDevice)4