List of usage examples for android.view SurfaceHolder setType
@Deprecated public void setType(int type);
From source file:com.welcu.android.zxingfragmentlib.BarCodeScannerFragment.java
/** * Initializes the camera and viewfinderView. *///www. j a v a 2s. c o m public void startScan() { if (cameraManager != null) { Log.e(TAG, "startScan: scan already started."); return; } // 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(this.getActivity().getApplication(), getView()); viewfinderView = (ViewfinderView) getView().findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); handler = null; lastResult = null; SurfaceView surfaceView = (SurfaceView) getView().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); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } if (customFramingRect != null) { cameraManager.setManualFramingRect(customFramingRect); } beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); decodeFormats = null; characterSet = null; }
From source file:co.jlabs.cersei_retailer.zxingfragmentlib.BarCodeScannerFragment.java
public void startScan() { if (cameraManager != null) { Log.e(TAG, "Camera startScan: scan already started."); return;// ww w. ja va 2 s . c om } // 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(this.getActivity().getApplication(), getView()); viewfinderView = (ViewfinderView) getView().findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); handler = null; lastResult = null; SurfaceView surfaceView = (SurfaceView) getView().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); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } if (customFramingRect != null) { cameraManager.setManualFramingRect(customFramingRect); } beepManager.updatePrefs(); ambientLightManager.start(cameraManager); Log.e(TAG, "Camera:5"); inactivityTimer.onResume(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); decodeFormats = null; characterSet = null; }
From source file:com.nekomeshi312.whiteboardcorrection.CameraViewFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub if (MyDebug.DEBUG) Log.d(LOG_TAG, "onViewCreated"); super.onViewCreated(view, savedInstanceState); mTextViewLineDetectErrorMsg = (TextView) mParentActivity.findViewById(R.id.line_detection_error_msg); mCameraSurfaceView = (CameraSurfaceView) mParentActivity.findViewById(R.id.camera_surface_view); SurfaceHolder holder = mCameraSurfaceView.getHolder(); holder.addCallback(this); if (Build.VERSION.SDK_INT < 11) { holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }/*from w w w . j av a2s.co m*/ mCameraSurfaceView.setCameraPreview(this); mWhiteBoardView = (WhiteBoardAreaView) mParentActivity.findViewById(R.id.whiteboard_area_view); mWhiteBoardView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // TODO Auto-generated method stub if (mBaseWidth == -1) { if (mCameraSetting.isCameraOpen()) { fitChildSize2CamSize(); } } } }); }
From source file:se.droidgiro.scanner.CaptureActivity.java
@Override protected void onResume() { super.onResume(); resetStatusView();// w w w . ja v a 2 s. co m 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); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); playBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true); if (playBeep) { // See if sound settings overrides this AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE); if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) { playBeep = false; } } vibrate = prefs.getBoolean(PreferencesActivity.KEY_VIBRATE, false); initBeepSound(); }
From source file:tw.jwzhuang.ipcamviewer.devices.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;/*from w ww . j a v a2s.co m*/ lastResult = null; resetStatusView(); 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); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(Contant.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); inputUri.getQueryParameter(RETURN_URL_PARAM); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
From source file:com.cellbots.logger.LoggerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); application = (LoggerApplication) getApplication(); // Keep the screen on to make sure the phone stays awake. getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mIsRecording = false;/*from w w w. j a v a 2 s .co m*/ useZip = getIntent().getBooleanExtra(EXTRA_USE_ZIP, true); final int mode = getIntent().getIntExtra(EXTRA_MODE, MODE_VIDEO_FRONT); if ((mode == MODE_VIDEO_FRONT) || (mode == MODE_VIDEO_BACK)) { if (mode == MODE_VIDEO_FRONT) { setContentView(R.layout.video_front_mode); } else { setContentView(R.layout.video_back_mode); } mCamcorderView = (AbstractCamcorderPreview) findViewById(R.id.surface); final SurfaceHolder previewHolder = mCamcorderView.getHolder(); previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } else { mDelay = getIntent().getIntExtra(EXTRA_PICTURE_DELAY, 30) * 1000; if (mDelay < 0) { mDelay = 0; } setContentView(R.layout.pictures_mode); mCameraView = (CameraPreview) findViewById(R.id.surface); } // Setup the initial available space mStatFs = new StatFs(Environment.getExternalStorageDirectory().toString()); float percentage = (float) (mStatFs.getBlockCount() - mStatFs.getAvailableBlocks()) / (float) mStatFs.getBlockCount(); mFreeSpacePct = (int) (percentage * 100); mStorageBarImageView = (BarImageView) findViewById(R.id.storage_barImageView); mStorageBarImageView.setPercentage(percentage); mStorageTextView = (TextView) findViewById(R.id.storage_text); mStorageSpacerTextView = (TextView) findViewById(R.id.storage_text_spacer); mStorageTextView.setText(mFreeSpacePct + "%"); mStorageSpacerTextView.setPadding(mStorageSpacerTextView.getPaddingLeft(), (int) ((1 - percentage) * UI_BAR_MAX_TOP_PADDING), mStorageSpacerTextView.getPaddingRight(), mStorageSpacerTextView.getPaddingBottom()); mFlashingRecGroup = (LinearLayout) findViewById(R.id.flashingRecGroup); mRecTimeTextView = (TextView) findViewById(R.id.recTime); mGpsLocationView = (TextView) findViewById(R.id.gpsLocation); mPictureCountView = (TextView) findViewById(R.id.pictureCount); mDataDrawer = (SlidingDrawer) findViewById(R.id.dataDrawer); mDiagnosticsDrawer = (SlidingDrawer) findViewById(R.id.diagnosticsDrawer); final ImageButton recordButton = (ImageButton) findViewById(R.id.button_record); recordButton.setOnClickListener(new View.OnClickListener() { // @Override @Override public void onClick(View v) { synchronized (mIsRecording) { if ((mode == MODE_VIDEO_FRONT) || (mode == MODE_VIDEO_BACK)) { if (!mIsRecording) { try { mIsRecording = true; recordButton.setImageResource(R.drawable.rec_button_pressed); // initializes recording mCamcorderView.initializeRecording(); // starts recording mCamcorderView.startRecording(); startRecTime = System.currentTimeMillis(); new Thread(updateRecTimeDisplay).start(); if (mRemoteControl != null) mRemoteControl.broadcastMessage("*** Recording Started ***\n"); } catch (Exception e) { Log.e("ls", "Recording has failed...", e); Toast.makeText(getApplicationContext(), "Camera hardware error. Please restart the application.", Toast.LENGTH_LONG) .show(); finish(); return; } } else { cleanup(); } } else { if (!mIsRecording) { try { mIsRecording = true; recordButton.setImageResource(R.drawable.rec_button_pressed); mCameraView.takePictures(mDelay); new Thread(updateRecTimeDisplay).start(); } catch (Exception e) { Log.e("ls", "Taking pictures has failed...", e); Toast.makeText(getApplicationContext(), "Taking pictures is not possible at the moment: " + e.toString(), Toast.LENGTH_SHORT).show(); } } else { cleanup(); } } } } }); final ImageButton dataButton = (ImageButton) findViewById(R.id.button_data); dataButton.setOnClickListener(new View.OnClickListener() { // @Override @Override public void onClick(View v) { if (mDataDrawer.isOpened()) { dataButton.setImageResource(R.drawable.data_button_up); mDataDrawer.animateClose(); } else { dataButton.setImageResource(R.drawable.data_button_pressed); mDataDrawer.animateOpen(); } } }); final ImageButton diagnosticsButton = (ImageButton) findViewById(R.id.button_diagnostics); diagnosticsButton.setOnClickListener(new View.OnClickListener() { // @Override @Override public void onClick(View v) { if (mDiagnosticsDrawer.isOpened()) { diagnosticsButton.setImageResource(R.drawable.diagnostics_button_up); mDiagnosticsDrawer.animateClose(); } else { diagnosticsButton.setImageResource(R.drawable.diagnostics_button_pressed); mDiagnosticsDrawer.animateOpen(); } } }); // setupSensors(); initSensorUi(); }
From source file:com.xgf.inspection.qrcode.google.zxing.client.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); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;/* www . j ava2s . c o m*/ lastResult = null; resetStatusView(); 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); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } beepManager.updatePrefs(); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); returnRaw = inputUri.getQueryParameter(RAW_PARAM) != null; decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }