Search in sources :

Example 11 with ParsedResult

use of com.google.zxing.client.result.ParsedResult in project BarcodeEye by BarcodeEye.

the class IsbnResultProcessor method getCardResults.

@Override
public List<CardPresenter> getCardResults() {
    List<CardPresenter> cardPresenters = new ArrayList<CardPresenter>();
    ParsedResult parsedResult = getParsedResult();
    String codeValue = parsedResult.getDisplayResult();
    for (String key : PRODUCT_SEARCH_ENDPOINTS.keySet()) {
        CardPresenter cardPresenter = new CardPresenter();
        cardPresenter.setText("Lookup on " + key).setFooter(codeValue);
        String url = PRODUCT_SEARCH_ENDPOINTS.get(key);
        url = url.replace("{CODE}", codeValue);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        cardPresenter.setPendingIntent(createPendingIntent(getContext(), intent));
        if (getPhotoUri() != null) {
            cardPresenter.addImage(getPhotoUri());
        }
        cardPresenters.add(cardPresenter);
    }
    return cardPresenters;
}
Also used : ArrayList(java.util.ArrayList) CardPresenter(com.github.barcodeeye.scan.api.CardPresenter) ParsedResult(com.google.zxing.client.result.ParsedResult) ISBNParsedResult(com.google.zxing.client.result.ISBNParsedResult) Intent(android.content.Intent)

Example 12 with ParsedResult

use of com.google.zxing.client.result.ParsedResult in project weex-example by KalicyZhou.

the class ResultHandler method fillInCustomSearchURL.

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);
}
Also used : ParsedResult(com.google.zxing.client.result.ParsedResult) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

ParsedResult (com.google.zxing.client.result.ParsedResult)12 Result (com.google.zxing.Result)5 Intent (android.content.Intent)4 Uri (android.net.Uri)3 Bundle (android.os.Bundle)3 CardPresenter (com.github.barcodeeye.scan.api.CardPresenter)3 WriterException (com.google.zxing.WriterException)3 AddressBookParsedResult (com.google.zxing.client.result.AddressBookParsedResult)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 ArrayList (java.util.ArrayList)3 BinaryBitmap (com.google.zxing.BinaryBitmap)2 BufferedImage (java.awt.image.BufferedImage)2 BufferedImageLuminanceSource (com.google.zxing.BufferedImageLuminanceSource)1 LuminanceSource (com.google.zxing.LuminanceSource)1 MultiFormatReader (com.google.zxing.MultiFormatReader)1 NotFoundException (com.google.zxing.NotFoundException)1 ReaderException (com.google.zxing.ReaderException)1