Java Code Examples for android.view.SurfaceView#setVisibility()

The following examples show how to use android.view.SurfaceView#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_remote);

    mSurfaceView = (SurfaceView) findViewById(R.id.remote_player_surface);
    mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
    mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);

    if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) {
        mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
        mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    } else
        mSubtitlesSurfaceView.setVisibility(View.GONE);
    VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
    if (activity == null) {
        Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
        return;
    }

    Log.i(TAG, "Secondary display created");
}
 
Example 2
Source File: MainActivity.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
public void updateMotionPreferences() {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);

    if (mCam != null) {
        mCam.updateFromPreferences(prefs);
    }

    if (mMotionDetector != null) {
        mMotionDetector.updateFromPreferences(prefs);
    }

    SurfaceView motionView = findViewById(R.id.motionView);
    boolean showPreview = prefs.getBoolean(Constants.PREF_MOTION_DETECTION_PREVIEW, false);

    if (showPreview && mCam != null && mCam.canBeUsed()) {
        ViewGroup.LayoutParams params = motionView.getLayoutParams();
        params.height = 480;
        params.width = 640;
        motionView.setLayoutParams(params);

        motionView.setVisibility(View.VISIBLE);
    } else {
        motionView.setVisibility(View.INVISIBLE);
    }
}
 
Example 3
Source File: QrScannerActivity.java    From QrModule with Apache License 2.0 6 votes vote down vote up
protected void setUpSurfaceAndSound() {
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    surfaceView.setVisibility(View.VISIBLE);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(QrScannerActivity.this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
 
Example 4
Source File: CameraPreview.java    From retroboy with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
public CameraPreview(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);
	
	// Default filter
	_filter = new YuvFilter(480, 360, 0, true, true);
	
	// Dummy view to make sure that Camera actually delivers preview frames
	_dummy = new SurfaceView(context);
	_dummy.setVisibility(INVISIBLE);
	_dummy.getHolder().addCallback(new DummySurfaceCallback());
	_dummy.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	addView(_dummy, 1, 1);

	// Install a SurfaceHolder.Callback so we get notified when the surface is created and destroyed.
	_surface = new SurfaceView(context);
	_holder = _surface.getHolder();
	_holder.addCallback(new PreviewSurfaceCallback());
	_holder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
	addView(_surface);
}
 
Example 5
Source File: OpenNoteCameraView.java    From react-native-documentscanner-android with MIT License 5 votes vote down vote up
public void turnCameraOn() {
    mSurfaceView = (SurfaceView) mView.findViewById(R.id.surfaceView);
    mSurfaceHolder = this.getHolder();
    mSurfaceHolder.addCallback(this);
    mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    mSurfaceView.setVisibility(SurfaceView.VISIBLE);
}
 
Example 6
Source File: CompositorSurfaceManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public SurfaceState(Context context, int format, SurfaceHolder.Callback2 callback) {
    surfaceView = new SurfaceView(context);
    surfaceView.setZOrderMediaOverlay(true);
    surfaceView.setVisibility(View.INVISIBLE);
    surfaceHolder().setFormat(format);
    surfaceHolder().addCallback(callback);

    // Set this to UNKNOWN until we get a format back.
    this.format = PixelFormat.UNKNOWN;
}
 
Example 7
Source File: CameraActivity.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the camera handler.
 */
private void setCameraHandler() {
	SurfaceView camera1View = findViewById(R.id.camera1_preview);
	TextureView camera2View = findViewById(R.id.camera2_preview);
	if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && isCamera2()) {
		mCameraHandler = new Camera2Handler(this, (FrameLayout) findViewById(R.id.camera_preview_frame), camera2View, mOnPictureTakenHandler);
		camera1View.setVisibility(GONE);
		camera2View.setVisibility(VISIBLE);
	}
	else {
		mCameraHandler = new Camera1Handler((FrameLayout) findViewById(R.id.camera_preview_frame), camera1View, mOnPictureTakenHandler);
		camera1View.setVisibility(VISIBLE);
		camera2View.setVisibility(GONE);
	}
}
 
Example 8
Source File: DocumentScannerActivity.java    From Document-Scanner with GNU General Public License v3.0 3 votes vote down vote up
public void turnCameraOn() {
    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);

    mSurfaceHolder = mSurfaceView.getHolder();

    mSurfaceHolder.addCallback(this);
    mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    mSurfaceView.setVisibility(SurfaceView.VISIBLE);
}