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

The following examples show how to use android.view.SurfaceHolder#removeCallback() . 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: CaptureActivity.java    From ZXing-Orient with 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 2
Source File: CaptureActivity.java    From BarcodeEye with 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 3
Source File: CaptureActivity.java    From barcodescanner-lib-aar with 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 4
Source File: LocalPlayer.java    From V.FlyoutTest with 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 5
Source File: CameraActivity.java    From moVirt with 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 6
Source File: CaptureActivity.java    From weex with 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 7
Source File: BarCodeScannerFragment.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
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 8
Source File: CameraPreview.java    From Viewer with 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 9
Source File: LocalPlayer.java    From media-samples with 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 10
Source File: CaptureActivity.java    From ZXing-Standalone-library with 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 11
Source File: LocalPlayer.java    From android-MediaRouter with 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 12
Source File: CaptureActivity.java    From android-mrz-reader with Apache License 2.0 6 votes vote down vote up
@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 13
Source File: DecoderActivity.java    From android-quick-response-code with Apache License 2.0 6 votes vote down vote up
@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 14
Source File: CaptureActivity.java    From CodeScaner with 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 15
Source File: CaptureActivity.java    From ScanZxing with 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 16
Source File: CaptureActivity.java    From FoodOrdering with 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 17
Source File: CaptureActivity.java    From android-apps with 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 File: CaptureActivity.java    From reacteu-app with 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 File: QREader.java    From qreader with Apache License 2.0 4 votes vote down vote up
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
  surfaceCreated = false;
  stop();
  surfaceHolder.removeCallback(this);
}
 
Example 20
Source File: CameraPreview.java    From IDCardCamera with Apache License 2.0 4 votes vote down vote up
public void surfaceDestroyed(SurfaceHolder holder) {
    holder.removeCallback(this);
    //回收释放资源
    release();
}