Java Code Examples for android.view.SurfaceHolder#removeCallback()

The following examples show how to use android.view.SurfaceHolder#removeCallback() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: media-samples   File: LocalPlayer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void release() {
    super.release();

    // dismiss presentation display
    if (mPresentation != null) {
        Log.i(TAG, "Dismissing presentation because the activity is no longer visible.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // remove surface holder callback
    SurfaceHolder holder = mSurfaceView.getHolder();
    holder.removeCallback(this);

    // hide the surface view when SurfaceViewPlayer is destroyed
    mSurfaceView.setVisibility(View.GONE);
    mLayout.setVisibility(View.GONE);
}
 
Example 2
Source Project: FoodOrdering   File: CaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    inactivityTimer.onPause();
    beepManager.close();
    cameraManager.closeDriver();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
 
Example 3
Source Project: ScanZxing   File: CaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    inactivityTimer.onPause();
    beepManager.close();
    cameraManager.closeDriver();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
 
Example 4
Source Project: CodeScaner   File: CaptureActivity.java    License: MIT License 6 votes vote down vote up
@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();
}
 
Example 5
@Override
protected void onPause() {
    super.onPause();
    Log.v(TAG, "onPause()");

    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }

    cameraManager.closeDriver();

    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
}
 
Example 6
@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
    }

    // Stop using the camera, to avoid conflicting with other camera-based apps
    cameraManager.closeDriver();

    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
 
Example 7
Source Project: android-MediaRouter   File: LocalPlayer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void release() {
    super.release();

    // dismiss presentation display
    if (mPresentation != null) {
        Log.i(TAG, "Dismissing presentation because the activity is no longer visible.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // remove surface holder callback
    SurfaceHolder holder = mSurfaceView.getHolder();
    holder.removeCallback(this);

    // hide the surface view when SurfaceViewPlayer is destroyed
    mSurfaceView.setVisibility(View.GONE);
    mLayout.setVisibility(View.GONE);
}
 
Example 8
@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();
}
 
Example 9
Source Project: ZXing-Orient   File: CaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }


    cameraManager.setTorch(false);
    super.onPause();
}
 
Example 10
Source Project: Viewer   File: CameraPreview.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Pause scanning and the camera preview. Typically this should be called from the Activity's
 * onPause() method.
 *
 * Call from UI thread only.
 */
public void pause() {
    // This must be safe to call multiple times.
    Util.validateMainThread();
    Log.d(TAG, "pause()");

    if (cameraInstance != null) {
        cameraInstance.close();
        cameraInstance = null;
        previewActive = false;
    }
    if (currentSurfaceSize == null) {
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(surfaceCallback);
    }

    this.containerSize = null;
    this.previewSize = null;
    this.previewFramingRect = null;
    rotationListener.stop();

    fireState.previewStopped();
}
 
Example 11
public void stopScan() {
  if (cameraManager == null) {
    Log.e(TAG, "stopScan: scan already stopped");
    return;
  }

  if (handler != null) {
    handler.quitSynchronously();
    handler = null;
  }

  inactivityTimer.onPause();
  ambientLightManager.stop();
  beepManager.close();
  cameraManager.closeDriver();
  cameraManager = null;

  if (!hasSurface) {
    SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.removeCallback(this);
  }
}
 
Example 12
Source Project: weex   File: CaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 13
Source Project: moVirt   File: CameraActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    cameraManager.closeDriver();
    beepManager.close();
    inactivityTimer.onPause();
    ambientLightManager.stop();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.camera_preview);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
 
Example 14
Source Project: V.FlyoutTest   File: LocalPlayer.java    License: MIT License 6 votes vote down vote up
@Override
public void release() {
    super.release();

    // dismiss presentation display
    if (mPresentation != null) {
        Log.i(TAG, "Dismissing presentation because the activity is no longer visible.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // remove surface holder callback
    SurfaceHolder holder = mSurfaceView.getHolder();
    holder.removeCallback(this);

    // hide the surface view when SurfaceViewPlayer is destroyed
    mSurfaceView.setVisibility(View.GONE);
    mLayout.setVisibility(View.GONE);
}
 
Example 15
Source Project: barcodescanner-lib-aar   File: CaptureActivity.java    License: MIT License 6 votes vote down vote up
@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();
}
 
Example 16
Source Project: BarcodeEye   File: CaptureActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    if (mHandler != null) {
        mHandler.quitSynchronously();
        mHandler = null;
    }
    mInactivityTimer.onPause();
    mAmbientLightManager.stop();
    mCameraManager.closeDriver();
    if (!mHasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
 
Example 17
Source Project: android-apps   File: CaptureActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onPause() {
  if (handler != null) {
    handler.quitSynchronously();
    handler = null;
  }
  inactivityTimer.onPause();
  cameraManager.closeDriver();
  if (!hasSurface) {
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.removeCallback(this);
  }
  super.onPause();
}
 
Example 18
Source Project: reacteu-app   File: CaptureActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onPause() {
  if (handler != null) {
    handler.quitSynchronously();
    handler = null;
  }
  inactivityTimer.onPause();
  cameraManager.closeDriver();
  if (!hasSurface) {
    SurfaceView surfaceView = (SurfaceView) findViewById(fakeR.getId("id", "preview_view"));
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.removeCallback(this);
  }
  super.onPause();
}
 
Example 19
Source Project: IDCardCamera   File: CameraPreview.java    License: Apache License 2.0 4 votes vote down vote up
public void surfaceDestroyed(SurfaceHolder holder) {
    holder.removeCallback(this);
    //回收释放资源
    release();
}
 
Example 20
Source Project: qreader   File: QREader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
  surfaceCreated = false;
  stop();
  surfaceHolder.removeCallback(this);
}