當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultParser.parseResult方法代碼示例

本文整理匯總了Java中com.google.zxing.client.result.ResultParser.parseResult方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultParser.parseResult方法的具體用法?Java ResultParser.parseResult怎麽用?Java ResultParser.parseResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.zxing.client.result.ResultParser的用法示例。


在下文中一共展示了ResultParser.parseResult方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例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 = 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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 = (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.length() == 0) {
    throw new WriterException("No content to encode");
  }
}
 
開發者ID:atomsheep,項目名稱:sres-app,代碼行數:38,代碼來源:QRCodeEncoder.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.length() == 0) {
        throw new WriterException("No content to encode");
    }
}
 
開發者ID:yakovenkodenis,項目名稱:Discounty,代碼行數:38,代碼來源:QRCodeEncoder.java

示例15: onResult

import com.google.zxing.client.result.ResultParser; //導入方法依賴的package包/類
@Override
public void onResult(ZxingScanView scanView, Result result, Bitmap barcode,
                     float scaleFactor) {
    ParsedResult parsedResult = ResultParser.parseResult(result);
    final String format = "格式:" + result.getBarcodeFormat().toString();
    final String type = "類型:" + parsedResult.getType().toString();
    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    final String date = "時間:" + formatter.format(new Date(result.getTimestamp()));
    String meta = "";
    Map<ResultMetadataType, Object> metadata = result.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            meta = metadataText.toString();
        }
    }
    CharSequence displayContents = parsedResult.getDisplayResult();
    Toast.makeText(this, format + "\n" + type + "\n" + date + "\n" + meta + "\n" + displayContents,
            Toast.LENGTH_SHORT).show();
    // 重新掃描
    scanView.restartScanDelay(3000);
}
 
開發者ID:AlexMofer,項目名稱:ProjectX,代碼行數:29,代碼來源:ZxingScanViewActivity.java


注:本文中的com.google.zxing.client.result.ResultParser.parseResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。