Ejemplo n.º 1
0
 @Override
 public void handleMessage(Message message) {
   switch (message.what) {
     case ZXING_RESTART:
       restartPreviewAndDecode();
       break;
     case R.id.zxing_decode_succeeded:
       state = State.SUCCESS;
       Bundle bundle = message.getData();
       Bitmap barcode = null;
       if (bundle != null) {
         byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
         if (compressedBitmap != null) {
           barcode =
               BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
           // Mutable copy:
           barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
         }
       }
       activity.handleDecode((Result) message.obj, barcode);
       break;
     case R.id.zxing_decode_failed:
       // We're decoding as fast as possible, so when one decode fails, start another.
       state = State.PREVIEW;
       cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.zxing_decode);
       break;
   }
 }