com.google.zxing.client.result.URIParsedResult Java Examples

The following examples show how to use com.google.zxing.client.result.URIParsedResult. 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: URIResultHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #2
Source File: URIResultHandler.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
@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;
  }
}
 
Example #3
Source File: URIResultHandler.java    From reacteu-app with MIT License 6 votes vote down vote up
@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;
  }
}
 
Example #4
Source File: SupplementalInfoRetriever.java    From reacteu-app with MIT License 6 votes vote down vote up
public static void maybeInvokeRetrieval(TextView textView,
                                        ParsedResult result,
                                        HistoryManager historyManager,
                                        Context context) {
  AsyncTaskExecInterface taskExec = new AsyncTaskExecManager().build();
  if (result instanceof URIParsedResult) {
    taskExec.execute(new URIResultInfoRetriever(textView, (URIParsedResult) result, historyManager, context));
    taskExec.execute(new TitleRetriever(textView, (URIParsedResult) result, historyManager));
  } else if (result instanceof ProductParsedResult) {
    String productID = ((ProductParsedResult) result).getProductID();
    taskExec.execute(new ProductResultInfoRetriever(textView, productID, historyManager, context));
  } else if (result instanceof ISBNParsedResult) {
    String isbn = ((ISBNParsedResult) result).getISBN();
    taskExec.execute(new ProductResultInfoRetriever(textView, isbn, historyManager, context));
    taskExec.execute(new BookResultInfoRetriever(textView, isbn, historyManager, context));
  }
}
 
Example #5
Source File: URIResultHandler.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #6
Source File: URIResultHandler.java    From android-apps with MIT License 6 votes vote down vote up
@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;
  }
}
 
Example #7
Source File: SupplementalInfoRetriever.java    From android-apps with MIT License 6 votes vote down vote up
public static void maybeInvokeRetrieval(TextView textView,
                                        ParsedResult result,
                                        Handler handler,
                                        HistoryManager historyManager,
                                        Context context) {

  Collection<SupplementalInfoRetriever> retrievers = new ArrayList<SupplementalInfoRetriever>(1);

  if (result instanceof URIParsedResult) {
    retrievers.add(new URIResultInfoRetriever(textView, (URIParsedResult) result, handler, historyManager, context));
  } else if (result instanceof ProductParsedResult) {
    String productID = ((ProductParsedResult) result).getProductID();
    retrievers.add(new ProductResultInfoRetriever(textView, productID, handler, historyManager, context));
  } else if (result instanceof ISBNParsedResult) {
    String isbn = ((ISBNParsedResult) result).getISBN();
    retrievers.add(new ProductResultInfoRetriever(textView, isbn, handler, historyManager, context));
    retrievers.add(new BookResultInfoRetriever(textView, isbn, handler, historyManager, context));
  }

  for (SupplementalInfoRetriever retriever : retrievers) {
    ExecutorService executor = getExecutorService();
    Future<?> future = executor.submit(retriever);
    // Make sure it's interrupted after a short time though
    executor.submit(new KillerCallable(future, 10, TimeUnit.SECONDS));
  }
}
 
Example #8
Source File: URIResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #9
Source File: UriResultProcessor.java    From BarcodeEye with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #10
Source File: URIResultHandler.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #11
Source File: URIResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #12
Source File: URIResultHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #13
Source File: URIResultHandler.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
@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;
}
 
Example #14
Source File: URIResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}
 
Example #15
Source File: URIResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}
 
Example #16
Source File: ResultProcessorFactory.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #17
Source File: URIResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@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;
}
 
Example #18
Source File: SupplementalInfoRetriever.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
public static void maybeInvokeRetrieval(TextView textView,
                                        ParsedResult result,
                                        HistoryManager historyManager,
                                        Context context) {
  if (result instanceof URIParsedResult) {
    SupplementalInfoRetriever uriRetriever = 
        new URIResultInfoRetriever(textView, (URIParsedResult) result, historyManager, context);
    uriRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    SupplementalInfoRetriever titleRetriever = 
        new TitleRetriever(textView, (URIParsedResult) result, historyManager);
    titleRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  } else if (result instanceof ProductParsedResult) {
    ProductParsedResult productParsedResult = (ProductParsedResult) result;
    String productID = productParsedResult.getProductID();
    SupplementalInfoRetriever productRetriever =
        new ProductResultInfoRetriever(textView, productID, historyManager, context);
    productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  } else if (result instanceof ISBNParsedResult) {
    String isbn = ((ISBNParsedResult) result).getISBN();
    SupplementalInfoRetriever productInfoRetriever = 
        new ProductResultInfoRetriever(textView, isbn, historyManager, context);
    productInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    SupplementalInfoRetriever bookInfoRetriever = 
        new BookResultInfoRetriever(textView, isbn, historyManager, context);
    bookInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
}
 
Example #19
Source File: URIResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}
 
Example #20
Source File: URIResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
@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;
}
 
Example #21
Source File: URIResultInfoRetriever.java    From android-apps with MIT License 5 votes vote down vote up
URIResultInfoRetriever(TextView textView,
                       URIParsedResult result,
                       Handler handler,
                       HistoryManager historyManager,
                       Context context) {
  super(textView, handler, historyManager);
  redirectString = context.getString(R.string.msg_redirect);
  this.result = result;
}
 
Example #22
Source File: SupplementalInfoRetriever.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
public static void maybeInvokeRetrieval(TextView textView,
                                        ParsedResult result,
                                        HistoryManager historyManager,
                                        Context context) {
  try {
    if (result instanceof URIParsedResult) {
      SupplementalInfoRetriever uriRetriever =
          new URIResultInfoRetriever(textView, (URIParsedResult) result, historyManager, context);
      uriRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
      SupplementalInfoRetriever titleRetriever =
          new TitleRetriever(textView, (URIParsedResult) result, historyManager);
      titleRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else if (result instanceof ProductParsedResult) {
      ProductParsedResult productParsedResult = (ProductParsedResult) result;
      String productID = productParsedResult.getProductID();
      SupplementalInfoRetriever productRetriever =
          new ProductResultInfoRetriever(textView, productID, historyManager, context);
      productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else if (result instanceof ISBNParsedResult) {
      String isbn = ((ISBNParsedResult) result).getISBN();
      SupplementalInfoRetriever productInfoRetriever =
          new ProductResultInfoRetriever(textView, isbn, historyManager, context);
      productInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
      SupplementalInfoRetriever bookInfoRetriever =
          new BookResultInfoRetriever(textView, isbn, historyManager, context);
      bookInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  } catch (RejectedExecutionException ree) {
    // do nothing
  }
}
 
Example #23
Source File: URIResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI().toLowerCase(Locale.ENGLISH);
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(uri, contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example #24
Source File: URIResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #25
Source File: URIResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI().toLowerCase(Locale.ENGLISH);
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(uri, contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example #26
Source File: URIResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #27
Source File: URIResultHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}
 
Example #28
Source File: URIResultHandler.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}
 
Example #29
Source File: URIResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #30
Source File: URIResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public int getButtonCount() {
  if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
    return buttons.length;
  }
  return buttons.length - 1;
}