类com.google.zxing.client.result.ResultParser源码实例Demo

下面列出了怎么用com.google.zxing.client.result.ResultParser的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ZXing-Standalone-library   文件: ResultHandler.java
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);
}
 
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);
}
 
源代码3 项目: weex   文件: ResultHandler.java
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);
}
 
源代码4 项目: Study_Android_Demo   文件: ResultHandler.java
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);
}
 
源代码5 项目: barcodescanner-lib-aar   文件: ResultHandler.java
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);
}
 
源代码6 项目: zxingfragmentlib   文件: ResultHandler.java
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);
}
 
源代码7 项目: appinventor-extensions   文件: ResultHandler.java
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;
}
 
/**
 * After this function is called the the following values will not be null:
 * <ul>
 *     <li>currentHistoryItem</li>
 *     <li>mCodeImage</li>
 *     <li>mSavedToHistory</li>
 *     <li>mParsedResult</li>
 * </ul>
 * If the state can not be created the activity will call {@link Activity#finish()}
 * This method will also update the {@link HistoryItem} in the database with a recreation of the QR Code if the image is missing.
 */
public void initFromHistoryItem(HistoryItem historyItem) {
    currentHistoryItem = historyItem;
    mParsedResult = ResultParser.parseResult(currentHistoryItem.getResult());
    mCodeImage = currentHistoryItem.getImage();
    if(mCodeImage == null) {
        mCodeImage = Utils.generateCode(currentHistoryItem.getText(), BarcodeFormat.QR_CODE, null, null);
        currentHistoryItem.setImage(mCodeImage);
        currentHistoryItem.setFormat(BarcodeFormat.QR_CODE);
        updateHistoryItem(currentHistoryItem);
    }
    mSavedToHistory = true;
}
 
public void initFromScan(BarcodeResult barcodeResult) {
    currentBarcodeResult = barcodeResult;
    mParsedResult = ResultParser.parseResult(currentBarcodeResult.getResult());
    mCodeImage = currentBarcodeResult.getBitmapWithResultPoints(ContextCompat.getColor(getApplication(), R.color.colorAccent));

    createHistoryItem();
}
 
源代码10 项目: reacteu-app   文件: QRCodeEncoder.java
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");
  }
}
 
源代码11 项目: reacteu-app   文件: ResultHandler.java
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;
}
 
源代码12 项目: ProjectX   文件: ZxingScanViewActivity.java
@Override
public void onResult(ZxingScanView scanView, Result result, Bitmap barcode,
                     float scaleFactor) {
    ParsedResult parsedResult = ResultParser.parseResult(result);
    final String format = "format:" + result.getBarcodeFormat().toString();
    final String type = "type:" + parsedResult.getType().toString();
    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    final String date = "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);
}
 
源代码13 项目: android-apps   文件: QRCodeEncoder.java
private void encodeContentsFromShareIntentDefault(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);
    int length = stream.available();
    if (length <= 0) {
      throw new WriterException("Content stream is empty");
    }
    vcard = new byte[length];
    int bytesRead = stream.read(vcard, 0, length);
    if (bytesRead < length) {
      throw new WriterException("Unable to fully read available bytes from content stream");
    }
    vcardString = new String(vcard, 0, bytesRead, "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");
  }
}
 
源代码14 项目: android-apps   文件: ResultHandler.java
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;
}
 
源代码15 项目: AndroidWebServ   文件: QRCodeEncoder.java
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");
    }
}
 
源代码16 项目: BarcodeEye   文件: ResultProcessorFactory.java
public static ResultProcessor<? extends ParsedResult> makeResultProcessor(
        Context context, Result result, Uri photoUri) {

    ParsedResult parsedResult = ResultParser.parseResult(result);

    switch (parsedResult.getType()) {
        case PRODUCT:
            return new ProductResultProcessor(context,
                    (ProductParsedResult) parsedResult, result, photoUri);
        case URI:
            return new UriResultProcessor(context,
                    (URIParsedResult) parsedResult, result, photoUri);
        case ISBN:
            return new IsbnResultProcessor(context,
                    (ISBNParsedResult) parsedResult, result, photoUri);
        case SMS:
        case GEO:
        case TEL:
        case CALENDAR:
        case ADDRESSBOOK:
        case EMAIL_ADDRESS:
        case WIFI:
            // currently unsupported so we let them fall through
        default:
            return new TextResultProcessor(context, parsedResult, result, photoUri);
    }
}
 
源代码17 项目: letv   文件: ResultHandlerFactory.java
private static ParsedResult parseResult(Result rawResult) {
    return ResultParser.parseResult(rawResult);
}
 
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
源代码19 项目: ZXing-Standalone-library   文件: QRCodeEncoder.java
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;
  InputStream stream = null;
  try {
    stream = activity.getContentResolver().openInputStream(uri);
    if (stream == null) {
      throw new WriterException("Can't open stream for " + 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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
源代码21 项目: ZXing-Orient   文件: QRCodeEncoder.java
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;
  InputStream stream = null;
  try {
    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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
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;
  InputStream stream = null;
  try {
    stream = activity.getContentResolver().openInputStream(uri);
    if (stream == null) {
      throw new WriterException("Can't open stream for " + 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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
源代码24 项目: weex   文件: QRCodeEncoder.java
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;
  InputStream stream = null;
  try {
    stream = activity.getContentResolver().openInputStream(uri);
    if (stream == null) {
      throw new WriterException("Can't open stream for " + 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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
源代码25 项目: weex   文件: ResultHandlerFactory.java
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
源代码26 项目: Study_Android_Demo   文件: QRCodeEncoder.java
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;
  InputStream stream = null;
  try {
    stream = activity.getContentResolver().openInputStream(uri);
    if (stream == null) {
      throw new WriterException("Can't open stream for " + 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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
源代码27 项目: Study_Android_Demo   文件: ResultHandlerFactory.java
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
public HistoryItemViewModel(Context context, HistoryItem entry) {
    this.context = context;
    this.entry = entry;
    this.parsed = ResultParser.parseResult(entry.getResult());
}
 
源代码29 项目: barcodescanner-lib-aar   文件: QRCodeEncoder.java
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;
  InputStream stream = null;
  try {
    stream = activity.getContentResolver().openInputStream(uri);
    if (stream == null) {
      throw new WriterException("Can't open stream for " + 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);
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // continue
      }
    }
  }
  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");
  }
}
 
private static ParsedResult parseResult(Result rawResult) {
  return ResultParser.parseResult(rawResult);
}
 
 类所在包
 类方法
 同包方法