- @Override
- public void run() {
- Looper.prepare();
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case R.id.decode:
- decode((byte[]) message.obj, message.arg1, message.arg2);
- break;
- case R.id.quit:
- Looper.myLooper().quit();
- break;
- }
- }
- };
- Looper.loop();
- }
-
- private void setDecodeProductMode() {
- Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
- Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>();
- vector.addElement(BarcodeFormat.UPC_A);
- vector.addElement(BarcodeFormat.UPC_E);
- vector.addElement(BarcodeFormat.EAN_13);
- vector.addElement(BarcodeFormat.EAN_8);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- mMultiFormatReader.setHints(hints);
- }
-
- // TODO: This is fragile in case we add new formats. It would be better to have a new enum
- // value which represented all 1D formats.
- private void setDecode1DMode() {
- Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
- Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>();
- vector.addElement(BarcodeFormat.UPC_A);
- vector.addElement(BarcodeFormat.UPC_E);
- vector.addElement(BarcodeFormat.EAN_13);
- vector.addElement(BarcodeFormat.EAN_8);
- vector.addElement(BarcodeFormat.CODE_39);
- vector.addElement(BarcodeFormat.CODE_128);
- vector.addElement(BarcodeFormat.ITF);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- mMultiFormatReader.setHints(hints);
- }
-
- private void setDecodeQRMode() {
- Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
- Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>();
- vector.addElement(BarcodeFormat.QR_CODE);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- mMultiFormatReader.setHints(hints);
- }