Java Code Examples for com.google.zxing.client.result.ResultParser#parseResult()
The following examples show how to use
com.google.zxing.client.result.ResultParser#parseResult() .
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: ResultHandler.java From barcodescanner-lib-aar with MIT License | 6 votes |
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); }
Example 2
Source File: ResultHandler.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: ResultHandler.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: ResultHandler.java From weex with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: ResultViewModel.java From privacy-friendly-qr-scanner with GNU General Public License v3.0 | 5 votes |
public void initFromScan(BarcodeResult barcodeResult) { currentBarcodeResult = barcodeResult; mParsedResult = ResultParser.parseResult(currentBarcodeResult.getResult()); mCodeImage = currentBarcodeResult.getBitmapWithResultPoints(ContextCompat.getColor(getApplication(), R.color.colorAccent)); createHistoryItem(); }
Example 6
Source File: QRCodeEncoder.java From android-apps with MIT License | 5 votes |
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"); } }
Example 7
Source File: ResultViewModel.java From privacy-friendly-qr-scanner with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 8
Source File: ResultHandler.java From android-apps with MIT License | 5 votes |
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; }
Example 9
Source File: ResultHandlerFactory.java From barcodescanner-lib-aar with MIT License | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 10
Source File: ResultHandlerFactory.java From android-quick-response-code with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 11
Source File: HistoryItemViewModel.java From privacy-friendly-qr-scanner with GNU General Public License v3.0 | 4 votes |
public HistoryItemViewModel(Context context, HistoryItem entry) { this.context = context; this.entry = entry; this.parsed = ResultParser.parseResult(entry.getResult()); }
Example 12
Source File: ResultHandlerFactory.java From android-apps with MIT License | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 13
Source File: ResultHandlerFactory.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 14
Source File: QRCodeEncoder.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
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"); } }
Example 15
Source File: ResultHandlerFactory.java From weex with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 16
Source File: ResultHandlerFactory.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 17
Source File: QRCodeEncoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 4 votes |
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"); } }
Example 18
Source File: ResultHandlerFactory.java From ZXing-Standalone-library with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }
Example 19
Source File: QRCodeEncoder.java From ZXing-Standalone-library with Apache License 2.0 | 4 votes |
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"); } }
Example 20
Source File: ResultHandlerFactory.java From appinventor-extensions with Apache License 2.0 | 4 votes |
private static ParsedResult parseResult(Result rawResult) { return ResultParser.parseResult(rawResult); }