List of usage examples for android.view SurfaceView getHolder
public SurfaceHolder getHolder()
From source file:com.chrulri.droidoflife.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//ww w . j a v a 2 s . c om getSupportActionBar().setDisplayShowHomeEnabled(false); settingsCache = SettingsActivity.loadSettings(this); SurfaceView view = (SurfaceView) findViewById(R.id.main_surfaceView); surface = view.getHolder(); restartRuntime(); view.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable iteration task for manual mode if (iterationTask != null) { iterationTask.cancel(false); iterationTask = null; } else { doIteration(); } refreshTitle(); } }); surface.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { doRender(); } @Override public void surfaceCreated(SurfaceHolder holder) { doRender(); } @Override public void surfaceDestroyed(SurfaceHolder holder) { // ignore } }); refreshTitle(); // Manual // TODO show manual }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
@Override public void onPause() { if (handler != null) { handler.quitSynchronously();/* w w w .ja v a 2s. c om*/ handler = null; } inactivityTimer.onPause(); ambientLightManager.stop(); cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = this.surfaceView; SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } super.onPause(); }
From source file:com.google.zxing.demo.CaptureActivity.java
@Override protected void onPause() { if (handler != null) { handler.quitSynchronously();//from w ww .j a v a2s . c om 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(); }
From source file:com.google.zxing.demo.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); handler = null;//w ww. ja va2s . c o m lastResult = null; resetStatusView(); beepManager.updatePrefs(); // ambientLightManager.start(cameraManager); inactivityTimer.onResume(); sourceUrl = null; // scanFromWebPageManager = null; decodeFormats = null; characterSet = null; SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); } }
From source file:com.coinomi.wallet.ui.ScanActivity.java
@Override protected void onResume() { super.onResume(); cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND); cameraThread.start();/*from w ww . j ava 2 s. c o m*/ cameraHandler = new Handler(cameraThread.getLooper()); final SurfaceView surfaceView = (SurfaceView) findViewById(R.id.scan_activity_preview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); if (!hasCameraPermission()) { askCameraPermission(); } else { openCamera(); } }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
@Override public void onResume() { super.onResume(); if (runCamera && hasSurface) { startCameraCampure();// w ww . j a v a2s . c o m } else if (runCamera) { SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.cameraView); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(BarCodeFragment.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
public void stopCameraCapture() { if (handler != null) { handler.quitSynchronously();/*from ww w.ja va2s. c om*/ handler = null; } cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.cameraView); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(BarCodeFragment.this); } cameraActive = false; }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
public void startCameraCampure() { cameraManager = new CameraManager(getActivity().getApplicationContext()); viewfinderView.setCameraManager(cameraManager); handler = null;// w ww . ja v a 2 s . c o m resetStatusView(); runCamera = true; SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.cameraView); SurfaceHolder surfaceHolder = surfaceView.getHolder(); hasSurface = true; if (hasSurface) { initCamera(surfaceHolder, viewfinderView); } else { surfaceHolder.addCallback(BarCodeFragment.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } decodeFormats = null; characterSet = null; cameraActive = true; }
From source file:com.fillerino.wallet.ui.ScanActivity.java
@Override protected void onResume() { super.onResume(); cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND); cameraThread.start();/*from w w w. j av a 2 s. co m*/ cameraHandler = new Handler(cameraThread.getLooper()); final SurfaceView surfaceView = (SurfaceView) findViewById(com.fillerino.wallet.R.id.scan_activity_preview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); if (!hasCameraPermission()) { askCameraPermission(); } else { openCamera(); } }
From source file:com.luyaozhou.recognizethisforglass.ViewFinder.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_preview); // Set up the camera preview user interface getWindow().setFormat(PixelFormat.UNKNOWN); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.camerapreview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(new SurfaceHolderCallback()); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // keep screen on }