Search in sources :

Example 6 with URIParsedResult

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

the class SupplementalInfoRetriever method maybeInvokeRetrieval.

public static void maybeInvokeRetrieval(TextView textView, ParsedResult result, Context context) {
    if (result instanceof URIParsedResult) {
        SupplementalInfoRetriever uriRetriever = new URIResultInfoRetriever(textView, (URIParsedResult) result, context);
        uriRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        SupplementalInfoRetriever titleRetriever = new TitleRetriever(textView, (URIParsedResult) result);
        titleRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else if (result instanceof ProductParsedResult) {
        ProductParsedResult productParsedResult = (ProductParsedResult) result;
        String productID = productParsedResult.getProductID();
        String normalizedProductID = productParsedResult.getNormalizedProductID();
        SupplementalInfoRetriever productRetriever = new ProductResultInfoRetriever(textView, productID, context);
        productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        switch(productID.length()) {
            case 12:
                SupplementalInfoRetriever upcInfoRetriever = new AmazonInfoRetriever(textView, "UPC", normalizedProductID, context);
                upcInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                break;
            case 13:
                SupplementalInfoRetriever eanInfoRetriever = new AmazonInfoRetriever(textView, "EAN", normalizedProductID, context);
                eanInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                break;
        }
    } else if (result instanceof ISBNParsedResult) {
        String isbn = ((ISBNParsedResult) result).getISBN();
        SupplementalInfoRetriever productInfoRetriever = new ProductResultInfoRetriever(textView, isbn, context);
        productInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        SupplementalInfoRetriever bookInfoRetriever = new BookResultInfoRetriever(textView, isbn, context);
        bookInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        SupplementalInfoRetriever amazonInfoRetriever = new AmazonInfoRetriever(textView, "ISBN", isbn, context);
        amazonInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : ProductParsedResult(com.google.zxing.client.result.ProductParsedResult) SpannableString(android.text.SpannableString) URIParsedResult(com.google.zxing.client.result.URIParsedResult) ISBNParsedResult(com.google.zxing.client.result.ISBNParsedResult)

Example 7 with URIParsedResult

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

the class UriResultProcessor method getCardResults.

@Override
public List<CardPresenter> getCardResults() {
    List<CardPresenter> cardResults = new ArrayList<CardPresenter>();
    URIParsedResult parsedResult = getParsedResult();
    CardPresenter cardPresenter = new CardPresenter().setText("Open in Browser").setFooter(parsedResult.getDisplayResult());
    if (getPhotoUri() != null) {
        cardPresenter.addImage(getPhotoUri());
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(parsedResult.getURI()));
    cardPresenter.setPendingIntent(createPendingIntent(getContext(), intent));
    cardResults.add(cardPresenter);
    return cardResults;
}
Also used : ArrayList(java.util.ArrayList) CardPresenter(com.github.barcodeeye.scan.api.CardPresenter) Intent(android.content.Intent) URIParsedResult(com.google.zxing.client.result.URIParsedResult)

Example 8 with URIParsedResult

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

the class URIResultHandler method areContentsSecure.

@Override
public boolean areContentsSecure() {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI().toLowerCase(Locale.ENGLISH);
    for (String secure : SECURE_PROTOCOLS) {
        if (uri.startsWith(secure)) {
            return true;
        }
    }
    return false;
}
Also used : URIParsedResult(com.google.zxing.client.result.URIParsedResult)

Example 9 with URIParsedResult

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

the class URIResultHandler method handleButtonPress.

@Override
public void handleButtonPress(int index) {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI();
    switch(index) {
        case 0:
            openURL(uri);
            break;
        case 1:
            shareByEmail(uri);
            break;
        case 2:
            shareBySMS(uri);
            break;
        case 3:
            searchBookContents(uri);
            break;
    }
}
Also used : URIParsedResult(com.google.zxing.client.result.URIParsedResult)

Example 10 with URIParsedResult

use of com.google.zxing.client.result.URIParsedResult in project zxingfragmentlib by mitoyarzun.

the class URIResultHandler method handleButtonPress.

@Override
public void handleButtonPress(int index) {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI();
    switch(index) {
        case 0:
            openURL(uri);
            break;
        case 1:
            shareByEmail(uri);
            break;
        case 2:
            shareBySMS(uri);
            break;
        case 3:
            searchBookContents(uri);
            break;
    }
}
Also used : URIParsedResult(com.google.zxing.client.result.URIParsedResult)

Aggregations

URIParsedResult (com.google.zxing.client.result.URIParsedResult)12 SpannableString (android.text.SpannableString)4 ISBNParsedResult (com.google.zxing.client.result.ISBNParsedResult)4 ProductParsedResult (com.google.zxing.client.result.ProductParsedResult)4 Intent (android.content.Intent)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 CardPresenter (com.github.barcodeeye.scan.api.CardPresenter)1 ParsedResult (com.google.zxing.client.result.ParsedResult)1 TextParsedResult (com.google.zxing.client.result.TextParsedResult)1 ArrayList (java.util.ArrayList)1