com.google.zxing.client.android.result.ResultHandlerFactory Java Examples

The following examples show how to use com.google.zxing.client.android.result.ResultHandlerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppInvCaptureActivity.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode) {
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);

  boolean fromLiveScan = barcode != null;
  if (fromLiveScan) {
    drawResultPoints(barcode, rawResult);
  }

  switch (source) {
    case NATIVE_APP_INTENT:
    case PRODUCT_SEARCH_LINK:
      handleDecodeExternally(rawResult, resultHandler, barcode);
      break;
    case NONE:
      if (fromLiveScan) {
        String message = " (bulk scan)";
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
        // Wait a moment or else it will scan the same barcode continuously about 3 times
        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
      }
      break;
  }
}
 
Example #2
Source File: CaptureActivity.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
  inactivityTimer.onActivity();
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);

  boolean fromLiveScan = barcode != null;
  if (fromLiveScan) {
    historyManager.addHistoryItem(rawResult, resultHandler);
    // Then not from history, so beep/vibrate and we have an image to draw on
    beepManager.playBeepSoundAndVibrate();
    drawResultPoints(barcode, scaleFactor, rawResult);
  }

  switch (source) {
    case NATIVE_APP_INTENT:
    case PRODUCT_SEARCH_LINK:
      handleDecodeExternally(rawResult, resultHandler, barcode);
      break;
    case ZXING_LINK:
      if (scanFromWebPageManager == null || !scanFromWebPageManager.isScanFromWebPage()) {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      } else {
        handleDecodeExternally(rawResult, resultHandler, barcode);
      }
      break;
    case NONE:
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
        Toast.makeText(getApplicationContext(),
                       getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
                       Toast.LENGTH_SHORT).show();
        // Wait a moment or else it will scan the same barcode continuously about 3 times
        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      }
      break;
  }
}
 
Example #3
Source File: CaptureActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
  inactivityTimer.onActivity();
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);

  boolean fromLiveScan = barcode != null;
  if (fromLiveScan) {
    historyManager.addHistoryItem(rawResult, resultHandler);
    // Then not from history, so beep/vibrate and we have an image to draw on
    beepManager.playBeepSoundAndVibrate();
    drawResultPoints(barcode, scaleFactor, rawResult);
  }

  switch (source) {
    case NATIVE_APP_INTENT:
    case PRODUCT_SEARCH_LINK:
      handleDecodeExternally(rawResult, resultHandler, barcode);
      break;
    case ZXING_LINK:
      if (scanFromWebPageManager == null || !scanFromWebPageManager.isScanFromWebPage()) {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      } else {
        handleDecodeExternally(rawResult, resultHandler, barcode);
      }
      break;
    case NONE:
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
        Toast.makeText(getApplicationContext(),
                       getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
                       Toast.LENGTH_SHORT).show();
        // Wait a moment or else it will scan the same barcode continuously about 3 times
        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      }
      break;
  }
}
 
Example #4
Source File: CaptureActivity.java    From reacteu-app with MIT License 5 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode) {
  inactivityTimer.onActivity();
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);

  boolean fromLiveScan = barcode != null;
  if (fromLiveScan) {
    historyManager.addHistoryItem(rawResult, resultHandler);
    // Then not from history, so beep/vibrate and we have an image to draw on
    beepManager.playBeepSoundAndVibrate();
    drawResultPoints(barcode, rawResult);
  }

  switch (source) {
    case NATIVE_APP_INTENT:
    case PRODUCT_SEARCH_LINK:
      handleDecodeExternally(rawResult, resultHandler, barcode);
      break;
    case ZXING_LINK:
      if (returnUrlTemplate == null){
        handleDecodeInternally(rawResult, resultHandler, barcode);
      } else {
        handleDecodeExternally(rawResult, resultHandler, barcode);
      }
      break;
    case NONE:
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
        String message = getResources().getString(fakeR.getId("string", "msg_bulk_mode_scanned"))
            + " (" + rawResult.getText() + ')';
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
        // Wait a moment or else it will scan the same barcode continuously about 3 times
        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      }
      break;
  }
}
 
Example #5
Source File: CaptureActivity.java    From android-apps with MIT License 5 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode) {
  inactivityTimer.onActivity();
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);
  historyManager.addHistoryItem(rawResult, resultHandler);

  if (barcode == null) {
    // This is from history -- no saved barcode
    handleDecodeInternally(rawResult, resultHandler, null);
  } else {
    beepManager.playBeepSoundAndVibrate();
    drawResultPoints(barcode, rawResult);
    switch (source) {
      case NATIVE_APP_INTENT:
      case PRODUCT_SEARCH_LINK:
        handleDecodeExternally(rawResult, resultHandler, barcode);
        break;
      case ZXING_LINK:
        if (returnUrlTemplate == null){
          handleDecodeInternally(rawResult, resultHandler, barcode);
        } else {
          handleDecodeExternally(rawResult, resultHandler, barcode);
        }
        break;
      case NONE:
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        if (prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
          Toast.makeText(this, R.string.msg_bulk_mode_scanned, Toast.LENGTH_SHORT).show();
          // Wait a moment or else it will scan the same barcode continuously about 3 times
          restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
        } else {
          handleDecodeInternally(rawResult, resultHandler, barcode);
        }
        break;
    }
  }
}
 
Example #6
Source File: CaptureActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show
 * the results.
 * 
 * @param rawResult
 *            The contents of the barcode.
 * @param scaleFactor
 *            amount by which thumbnail was scaled
 * @param barcode
 *            A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
	inactivityTimer.onActivity();
	lastResult = rawResult;
	ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(
			this, rawResult);

	boolean fromLiveScan = barcode != null;
	if (fromLiveScan) {
		historyManager.addHistoryItem(rawResult, resultHandler);
		// Then not from history, so beep/vibrate and we have an image to
		// draw on
		beepManager.playBeepSoundAndVibrate();
		drawResultPoints(barcode, scaleFactor, rawResult);
	}

	switch (source) {
	case NATIVE_APP_INTENT:
	case PRODUCT_SEARCH_LINK:
		handleDecodeExternally(rawResult, resultHandler, barcode);
		break;
	case ZXING_LINK:
		if (scanFromWebPageManager == null
				|| !scanFromWebPageManager.isScanFromWebPage()) {
			handleDecodeInternally(rawResult, resultHandler, barcode);
		} else {
			handleDecodeExternally(rawResult, resultHandler, barcode);
		}
		break;
	case NONE:
		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(this);
		if (fromLiveScan
				&& prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE,
						false)) {
			Toast.makeText(
					getApplicationContext(),
					getResources()
							.getString(R.string.msg_bulk_mode_scanned)
							+ " (" + rawResult.getText() + ')',
					Toast.LENGTH_SHORT).show();
			// Wait a moment or else it will scan the same barcode
			// continuously about 3 times
			restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
		} else {
			handleDecodeInternally(rawResult, resultHandler, barcode);
		}
		break;
	}
}
 
Example #7
Source File: CaptureActivity.java    From weex with Apache License 2.0 4 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show
 * the results.
 * 
 * @param rawResult
 *            The contents of the barcode.
 * @param scaleFactor
 *            amount by which thumbnail was scaled
 * @param barcode
 *            A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
	inactivityTimer.onActivity();
	lastResult = rawResult;
	ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(
			this, rawResult);

	boolean fromLiveScan = barcode != null;
	if (fromLiveScan) {
		historyManager.addHistoryItem(rawResult, resultHandler);
		// Then not from history, so beep/vibrate and we have an image to
		// draw on
		beepManager.playBeepSoundAndVibrate();
		drawResultPoints(barcode, scaleFactor, rawResult);
	}

	switch (source) {
	case NATIVE_APP_INTENT:
	case PRODUCT_SEARCH_LINK:
		handleDecodeExternally(rawResult, resultHandler, barcode);
		break;
	case ZXING_LINK:
		if (scanFromWebPageManager == null
				|| !scanFromWebPageManager.isScanFromWebPage()) {
			handleDecodeInternally(rawResult, resultHandler, barcode);
		} else {
			handleDecodeExternally(rawResult, resultHandler, barcode);
		}
		break;
	case NONE:
		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(this);
		if (fromLiveScan
				&& prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE,
						false)) {
			Toast.makeText(
					getApplicationContext(),
					getResources()
							.getString(R.string.msg_bulk_mode_scanned)
							+ " (" + rawResult.getText() + ')',
					Toast.LENGTH_SHORT).show();
			// Wait a moment or else it will scan the same barcode
			// continuously about 3 times
			restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
		} else {
			handleDecodeInternally(rawResult, resultHandler, barcode);
		}
		break;
	}
}
 
Example #8
Source File: CaptureActivity.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
/**
 * A valid barcode has been found, so give an indication of success and show the results.
 *
 * @param rawResult The contents of the barcode.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param barcode   A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
  inactivityTimer.onActivity();
  lastResult = rawResult;
  ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);

  boolean fromLiveScan = barcode != null;
  if (fromLiveScan) {
    historyManager.addHistoryItem(rawResult, resultHandler);
    // Then not from history, so beep/vibrate and we have an image to draw on
    if (beepOnScan) {
      beepManager.playBeepSoundAndVibrate();
    }
    drawResultPoints(barcode, scaleFactor, rawResult);
  }

  switch (source) {
    case NATIVE_APP_INTENT:
    case PRODUCT_SEARCH_LINK:
      if (fromLiveScan && getIntent().getBooleanExtra(Intents.Scan.BULK_SCAN, false)) {

        Intent intermediateResult = new Intent("bulk-barcode-result");
        intermediateResult.putExtra(Intents.Scan.RESULT, rawResult.toString());
        intermediateResult.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
        LocalBroadcastManager.getInstance(this).sendBroadcast(intermediateResult);

        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
        handleDecodeExternally(rawResult, resultHandler, barcode);
      }
      break;
    case ZXING_LINK:
      if (scanFromWebPageManager == null || !scanFromWebPageManager.isScanFromWebPage()) {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      } else {
        handleDecodeExternally(rawResult, resultHandler, barcode);
      }
      break;
    case NONE:
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
        Toast.makeText(getApplicationContext(),
                       getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
                       Toast.LENGTH_SHORT).show();
        // Wait a moment or else it will scan the same barcode continuously about 3 times
        restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
      } else {
        handleDecodeInternally(rawResult, resultHandler, barcode);
      }
      break;
  }
}