当前位置: 首页>>代码示例>>Java>>正文


Java ResultParser类代码示例

本文整理汇总了Java中com.google.zxing.client.result.ResultParser的典型用法代码示例。如果您正苦于以下问题:Java ResultParser类的具体用法?Java ResultParser怎么用?Java ResultParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResultParser类属于com.google.zxing.client.result包,在下文中一共展示了ResultParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
  if (customProductSearch == null) {
    return text; // ?
  }
  try {
    text = URLEncoder.encode(text, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    // can't happen; UTF-8 is always supported. Continue, I guess, without encoding      
  }
  String url = customProductSearch.replace("%s", text);
  if (rawResult != null) {
    url = url.replace("%f", rawResult.getBarcodeFormat().toString());
    if (url.contains("%t")) {
      ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
      url = url.replace("%t", parsedResultAgain.getType().toString());
    }
  }
  return url;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:20,代码来源:ResultHandler.java

示例2: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
  if (customProductSearch == null) {
    return text; // ?
  }
  try {
    text = URLEncoder.encode(text, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    // can't happen; UTF-8 is always supported. Continue, I guess, without encoding      
  }
  String url = customProductSearch;
  if (rawResult != null) {
    // Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
    // problematic but avoids the more surprising problem of breaking escapes
    url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
    if (url.contains("%t")) {
      ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
      url = url.replace("%t", parsedResultAgain.getType().toString());
    }
  }
  // Replace %s last as it might contain itself %f or %t
  return url.replace("%s", text);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:23,代码来源:ResultHandler.java

示例3: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
    if (customProductSearch == null) {
        return text; // ?
    }
    try {
        text = URLEncoder.encode(text, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        // can't happen; UTF-8 is always supported. Continue, I guess, without encoding
    }
    String url = customProductSearch;
    if (rawResult != null) {
        // Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
        // problematic but avoids the more surprising problem of breaking escapes
        url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
        if (url.contains("%t")) {
            ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
            url = url.replace("%t", parsedResultAgain.getType().toString());
        }
    }
    // Replace %s last as it might contain itself %f or %t
    return url.replace("%s", text);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:23,代码来源:ResultHandler.java

示例4: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
	if (customProductSearch == null) {
		return text; // ?
	}
	try {
		text = URLEncoder.encode(text, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		// can't happen; UTF-8 is always supported. Continue, I guess,
		// without encoding
	}
	String url = customProductSearch;
	if (rawResult != null) {
		// Replace %f but only if it doesn't seem to be a hex escape
		// sequence. This remains
		// problematic but avoids the more surprising problem of breaking
		// escapes
		url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
		if (url.contains("%t")) {
			ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
			url = url.replace("%t", parsedResultAgain.getType().toString());
		}
	}
	// Replace %s last as it might contain itself %f or %t
	return url.replace("%s", text);
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:26,代码来源:ResultHandler.java

示例5: handleDecode

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {

        // 重新计时
        inactivityTimer.onActivity();

        lastResult = rawResult;

        // 把图片画到扫描框
        viewfinderView.drawResultBitmap(barcode);

        beepManager.playBeepSoundAndVibrate();
        // //////////////////////////////////////////////////////////////////////////////////////////////////////
        Intent mIntent = new Intent();
        mIntent.putExtra("describe", ResultParser.parseResult(rawResult)
                .toString());
        setResult(1001, mIntent);
        finish();
    }
 
开发者ID:xbw12138,项目名称:shadowsocks_android,代码行数:19,代码来源:SaoYiSao.java

示例6: handleDecode

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
/**
 * 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) {
	lastResult = rawResult;
	// ResultHandler resultHandler =
	// ResultHandlerFactory.makeResultHandler(this, rawResult);
	ResultHandler resultHandler = new ResultHandler(this, ResultParser.parseResult(rawResult));

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

	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
	if (fromLiveScan && prefs.getBoolean(PreferencesSettings.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);
	}
}
 
开发者ID:Hamaoui-Issame,项目名称:nutriflash,代码行数:36,代码来源:CaptureActivity.java

示例7: handleDecodeInternally

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
private void handleDecodeInternally(Result rawResult, Bitmap barcode) {

        Uri imageUri = null;
        String imageName = IMAGE_PREFIX + System.currentTimeMillis() + ".png";
        Log.v(TAG, "Saving image as: " + imageName);
        try {
            imageUri = mImageManager.saveImage(imageName, barcode);
        } catch (IOException e) {
            Log.e(TAG, "Failed to save image!", e);
        }

        ResultProcessor<?> processor = new ResultProcessor<ParsedResult>(
                this, ResultParser.parseResult(rawResult), rawResult, imageUri);

        // ***** CultureGlass entry point *****

        //Original BarcodeEye path
        //startActivity(ResultsActivity.newIntent(this,processor.getCardResults()));

        ParsedResult result = processor.getParsedResult();

        startActivity(new Intent(this, LoadingActivity.class)
                .putExtra(EXTRA_CODE, result.getDisplayResult())
                .putExtra(EXTRA_TYPE, result.getType().toString()));
    }
 
开发者ID:raahilshah,项目名称:ProjectKilo,代码行数:26,代码来源:CaptureActivity.java

示例8: handleDecode

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
/**
 * 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;
    // 把图片画到扫描框
    viewfinderView.drawResultBitmap(barcode);
    beepManager.playBeepSoundAndVibrate();

    Toast.makeText(this, "识别结果:" + ResultParser.parseResult(rawResult).toString(), Toast.LENGTH_SHORT).show();
    // Intent intent = new Intent();
    // intent.putExtra("result", ResultParser.parseResult(rawResult)
    // .toString());
    // setResult(RESULT_OK, intent);
    // finish();
    // String result = ResultParser.parseResult(rawResult).toString()
    // + "&appkey=peixunduoduo";
    // Intent intent = new Intent();
    // Bundle bundle = new Bundle();
    // bundle.putString("title", "扫一扫检录");
    // intent.setData(Uri.parse("traindd://" + result));
    // intent.putExtra("initValues", bundle);
    // startActivity(intent);

}
 
开发者ID:oneapp1e,项目名称:BarcodeScanner,代码行数:35,代码来源:CaptureActivity.java

示例9: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
    if (customProductSearch == null) {
        return text; // ?
    }
    try {
        text = URLEncoder.encode(text, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        // can't happen; UTF-8 is always supported. Continue, I guess, without encoding
    }
    String url = customProductSearch.replace("%s", text);
    if (rawResult != null) {
        url = url.replace("%f", rawResult.getBarcodeFormat().toString());
        if (url.contains("%t")) {
            ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
            url = url.replace("%t", parsedResultAgain.getType().toString());
        }
    }
    return url;
}
 
开发者ID:yakovenkodenis,项目名称:Discounty,代码行数:20,代码来源:ResultHandler.java

示例10: getContactDetailsFromUri

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
public static AddressBookParsedResult getContactDetailsFromUri(
		Context context, Uri contactUri) {
	try {
		byte[] vcard;
		String vcardString;
		InputStream stream;
		stream = context.getContentResolver().openInputStream(contactUri);
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		byte[] buffer = new byte[2048];
		int bytesRead;
		while ((bytesRead = stream.read(buffer)) > 0) {
			baos.write(buffer, 0, bytesRead);
		}
		vcard = baos.toByteArray();
		vcardString = new String(vcard, 0, vcard.length, "UTF-8");
		Result result = new Result(vcardString, vcard, null,
				BarcodeFormat.QR_CODE);
		ParsedResult parsedResult = ResultParser.parseResult(result);
		return (AddressBookParsedResult) parsedResult;
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:guiguito,项目名称:AIRShare,代码行数:24,代码来源:ContactsUtils.java

示例11: assertCorrectImage2result

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected)
    throws IOException, NotFoundException {
  Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);

  BufferedImage image = ImageIO.read(path.toFile());
  BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
  int rowNumber = binaryMap.getHeight() / 2;
  BitArray row = binaryMap.getBlackRow(rowNumber, null);

  Result theResult;
  try {
    RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
    theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
  } catch (ReaderException re) {
    fail(re.toString());
    return;
  }

  assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());

  ParsedResult result = ResultParser.parseResult(theResult);

  assertEquals(expected, result);
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:25,代码来源:RSSExpandedImage2resultTestCase.java

示例12: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
final String fillInCustomSearchURL(String text) {
  if (customProductSearch == null) {
    return text; // ?
  }
  try {
    text = URLEncoder.encode(text, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    // can't happen; UTF-8 is always supported. Continue, I guess, without encoding      
  }
  String url = text;
  if (rawResult != null) {
    // Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
    // problematic but avoids the more surprising problem of breaking escapes
    url = url.replace("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
    if (url.contains("%t")) {
      ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
      url = url.replace("%t", parsedResultAgain.getType().toString());
    }
  }
  // Replace %s last as it might contain itself %f or %t
  url = customProductSearch.replace("%s", url);
  return url;
}
 
开发者ID:xiaowei4895,项目名称:zxing-android-portrait,代码行数:24,代码来源:ResultHandler.java

示例13: assertCorrectImage2result

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected)
    throws IOException, NotFoundException {
  RSSExpandedReader rssExpandedReader = new RSSExpandedReader();

  File file = new File(path);
  if (!file.exists()) {
    // Support running from project root too
    file = new File("core", path);
  }

  BufferedImage image = ImageIO.read(file);
  BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
  int rowNumber = binaryMap.getHeight() / 2;
  BitArray row = binaryMap.getBlackRow(rowNumber, null);

  Result theResult = rssExpandedReader.decodeRow(rowNumber, row, null);

  assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());

  ParsedResult result = ResultParser.parseResult(theResult);

  assertEquals(expected, result);
}
 
开发者ID:da-baumann,项目名称:dev,代码行数:24,代码来源:RSSExpandedImage2resultTestCase.java

示例14: encodeFromStreamExtra

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
private void encodeFromStreamExtra(Intent intent) throws WriterException {
  format = BarcodeFormat.QR_CODE;
  Bundle bundle = intent.getExtras();
  if (bundle == null) {
    throw new WriterException("No extras");
  }
  Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM);
  if (uri == null) {
    throw new WriterException("No EXTRA_STREAM");
  }
  byte[] vcard;
  String vcardString;
  try {
    InputStream stream = activity.getContentResolver().openInputStream(uri);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[2048];
    int bytesRead;
    while ((bytesRead = stream.read(buffer)) > 0) {
      baos.write(buffer, 0, bytesRead);
    }
    vcard = baos.toByteArray();
    vcardString = new String(vcard, 0, vcard.length, "UTF-8");
  } catch (IOException ioe) {
    throw new WriterException(ioe);
  }
  Log.d(TAG, "Encoding share intent content:");
  Log.d(TAG, vcardString);
  Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
  ParsedResult parsedResult = ResultParser.parseResult(result);
  if (!(parsedResult instanceof AddressBookParsedResult)) {
    throw new WriterException("Result was not an address");
  }
  encodeQRCodeContents((AddressBookParsedResult) parsedResult);
  if (contents == null || contents.isEmpty()) {
    throw new WriterException("No content to encode");
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:38,代码来源:QRCodeEncoder.java

示例15: fillInCustomSearchURL

import com.google.zxing.client.result.ResultParser; //导入依赖的package包/类
String fillInCustomSearchURL(String text) {
  if (customProductSearch == null) {
    return text; // ?
  }
  String url = customProductSearch.replace("%s", text);
  if (rawResult != null) {
    url = url.replace("%f", rawResult.getBarcodeFormat().toString());
    if (url.contains("%t")) {
      ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
      url = url.replace("%t", parsedResultAgain.getType().toString());
    }
  }
  return url;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:15,代码来源:ResultHandler.java


注:本文中的com.google.zxing.client.result.ResultParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。