@Override public void barcodeResult(BarcodeResult result) { if (result.getText() != null) { BeepManager bm = new BeepManager(getActivity()); bm.setVibrateEnabled(true); if (!BEEP) { bm.setBeepEnabled(false); } if (!VIBRATE) { bm.setVibrateEnabled(false); } bm.updatePrefs(); bm.playBeepSoundAndVibrate(); if (imagePreview == null && SHOW_ORIGINAL_PREVIEW) imagePreview = result.getBitmap(); activityHelper.launchDetailActivity(imagePreview, result.getResult(), true); } }
public ScanHelper(Activity activity, SurfaceView surfaceView) { this.activity = activity; this.capturePreview = surfaceView; this.hasSurface = false; this.mInactivityTimer = new InactivityTimer(activity); this.mBeepManager = new BeepManager(activity); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } View v; v = inflater.inflate(R.layout.fragment_capture, container, false); if (SDK_INT >= Build.VERSION_CODES.M) if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CAMERA}, 0); } barcodeView = (CompoundBarcodeView) v.findViewById(R.id.barcode_scanner); barcodeView.setTorchListener(new CompoundBarcodeView.TorchListener() { @Override public void onTorchOn() { torchOn = true; } @Override public void onTorchOff() { torchOn = false; } }); barcodeView.decodeContinuous(callback); beepManager = new BeepManager(getActivity()); return v; }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); hasSurface = false; inactivityTimer = new InactivityTimer(getActivity()); beepManager = new BeepManager(getActivity()); ambientLightManager = new AmbientLightManager(getActivity()); PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false); }