Java 类com.google.zxing.client.android.HttpHelper 实例源码

项目:keepass2android    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:weex-3d-map    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:weex-3d-map    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        title = Html.fromHtml(title).toString();
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:weex-3d-map    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:KeePass2Android    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:PortraitZXing    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
    CharSequence contents;
    try {
        contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
    } catch (IOException ioe) {
        // ignore this
        return;
    }
    if (contents != null && contents.length() > 0) {
        Matcher m = TITLE_PATTERN.matcher(contents);
        if (m.find()) {
            String title = m.group(1);
            if (title != null && !title.isEmpty()) {
                title = Html.fromHtml(title).toString();
                if (title.length() > MAX_TITLE_LEN) {
                    title = title.substring(0, MAX_TITLE_LEN) + "...";
                }
                append(httpUrl, null, new String[] { title }, httpUrl);
            }
        }
    }
}
项目:PortraitZXing    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

    String encodedProductID = URLEncoder.encode(productID, "UTF-8");
    String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
            + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

    for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
        Matcher matcher = p.matcher(content);
        if (matcher.find()) {
            append(productID, source,
                    new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) }, uri);
            break;
        }
    }
}
项目:PortraitZXing    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
    URI oldURI;
    try {
        oldURI = new URI(result.getURI());
    } catch (URISyntaxException ignored) {
        return;
    }
    URI newURI = HttpHelper.unredirect(oldURI);
    int count = 0;
    while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
        append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI },
                newURI.toString());
        oldURI = newURI;
        newURI = HttpHelper.unredirect(newURI);
    }
}
项目:PortraitZXing    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
    CharSequence contents;
    try {
        contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
    } catch (IOException ioe) {
        // ignore this
        return;
    }
    if (contents != null && contents.length() > 0) {
        Matcher m = TITLE_PATTERN.matcher(contents);
        if (m.find()) {
            String title = m.group(1);
            if (title != null && !title.isEmpty()) {
                title = Html.fromHtml(title).toString();
                if (title.length() > MAX_TITLE_LEN) {
                    title = title.substring(0, MAX_TITLE_LEN) + "...";
                }
                append(httpUrl, null, new String[] { title }, httpUrl);
            }
        }
    }
}
项目:PortraitZXing    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

    String encodedProductID = URLEncoder.encode(productID, "UTF-8");
    String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
            + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

    for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
        Matcher matcher = p.matcher(content);
        if (matcher.find()) {
            append(productID, source,
                    new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) }, uri);
            break;
        }
    }
}
项目:PortraitZXing    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
    URI oldURI;
    try {
        oldURI = new URI(result.getURI());
    } catch (URISyntaxException ignored) {
        return;
    }
    URI newURI = HttpHelper.unredirect(oldURI);
    int count = 0;
    while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
        append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI },
                newURI.toString());
        oldURI = newURI;
        newURI = HttpHelper.unredirect(newURI);
    }
}
项目:PortraitZXing    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
    CharSequence contents;
    try {
        contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
    } catch (IOException ioe) {
        // ignore this
        return;
    }
    if (contents != null && contents.length() > 0) {
        Matcher m = TITLE_PATTERN.matcher(contents);
        if (m.find()) {
            String title = m.group(1);
            if (title != null && !title.isEmpty()) {
                title = Html.fromHtml(title).toString();
                if (title.length() > MAX_TITLE_LEN) {
                    title = title.substring(0, MAX_TITLE_LEN) + "...";
                }
                append(httpUrl, null, new String[] { title }, httpUrl);
            }
        }
    }
}
项目:PortraitZXing    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

    String encodedProductID = URLEncoder.encode(productID, "UTF-8");
    String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
            + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

    for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
        Matcher matcher = p.matcher(content);
        if (matcher.find()) {
            append(productID, source,
                    new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) }, uri);
            break;
        }
    }
}
项目:PortraitZXing    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
    URI oldURI;
    try {
        oldURI = new URI(result.getURI());
    } catch (URISyntaxException ignored) {
        return;
    }
    URI newURI = HttpHelper.unredirect(oldURI);
    int count = 0;
    while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
        append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI },
                newURI.toString());
        oldURI = newURI;
        newURI = HttpHelper.unredirect(newURI);
    }
}
项目:PortraitZXing    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
    CharSequence contents;
    try {
        contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
    } catch (IOException ioe) {
        // ignore this
        return;
    }
    if (contents != null && contents.length() > 0) {
        Matcher m = TITLE_PATTERN.matcher(contents);
        if (m.find()) {
            String title = m.group(1);
            if (title != null && !title.isEmpty()) {
                title = Html.fromHtml(title).toString();
                if (title.length() > MAX_TITLE_LEN) {
                    title = title.substring(0, MAX_TITLE_LEN) + "...";
                }
                append(httpUrl, null, new String[] { title }, httpUrl);
            }
        }
    }
}
项目:PortraitZXing    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

    String encodedProductID = URLEncoder.encode(productID, "UTF-8");
    String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
            + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

    for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
        Matcher matcher = p.matcher(content);
        if (matcher.find()) {
            append(productID, source,
                    new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) }, uri);
            break;
        }
    }
}
项目:PortraitZXing    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
    URI oldURI;
    try {
        oldURI = new URI(result.getURI());
    } catch (URISyntaxException ignored) {
        return;
    }
    URI newURI = HttpHelper.unredirect(oldURI);
    int count = 0;
    while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
        append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI },
                newURI.toString());
        oldURI = newURI;
        newURI = HttpHelper.unredirect(newURI);
    }
}
项目:weex-analyzer-android    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:weex-analyzer-android    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        title = Html.fromHtml(title).toString();
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:weex-analyzer-android    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:weex-analyzer-android    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
  URI oldURI;
  try {
    oldURI = new URI(result.getURI());
  } catch (URISyntaxException ignored) {
    return;
  }
  URI newURI = HttpHelper.unredirect(oldURI);
  int count = 0;
  while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
    append(result.getDisplayResult(), 
           null, 
           new String[] { redirectString + " : " + newURI }, 
           newURI.toString());
    oldURI = newURI;
    newURI = HttpHelper.unredirect(newURI);
  }
}
项目:weex-3d-map    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:weex-3d-map    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        title = Html.fromHtml(title).toString();
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:weex-3d-map    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:weex-3d-map    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
  URI oldURI;
  try {
    oldURI = new URI(result.getURI());
  } catch (URISyntaxException ignored) {
    return;
  }
  URI newURI = HttpHelper.unredirect(oldURI);
  int count = 0;
  while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
    append(result.getDisplayResult(), 
           null, 
           new String[] { redirectString + " : " + newURI }, 
           newURI.toString());
    oldURI = newURI;
    newURI = HttpHelper.unredirect(newURI);
  }
}
项目:Weex-TestDemo    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:Weex-TestDemo    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        title = Html.fromHtml(title).toString();
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:Weex-TestDemo    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:Weex-TestDemo    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
  URI oldURI;
  try {
    oldURI = new URI(result.getURI());
  } catch (URISyntaxException ignored) {
    return;
  }
  URI newURI = HttpHelper.unredirect(oldURI);
  int count = 0;
  while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
    append(result.getDisplayResult(), 
           null, 
           new String[] { redirectString + " : " + newURI }, 
           newURI.toString());
    oldURI = newURI;
    newURI = HttpHelper.unredirect(newURI);
  }
}
项目:weex    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:weex    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        title = Html.fromHtml(title).toString();
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:weex    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "https://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:weex    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
  URI oldURI;
  try {
    oldURI = new URI(result.getURI());
  } catch (URISyntaxException ignored) {
    return;
  }
  URI newURI = HttpHelper.unredirect(oldURI);
  int count = 0;
  while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
    append(result.getDisplayResult(), 
           null, 
           new String[] { redirectString + " : " + newURI }, 
           newURI.toString());
    oldURI = newURI;
    newURI = HttpHelper.unredirect(newURI);
  }
}
项目:sres-app    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:sres-app    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && title.length() > 0) {
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:sres-app    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "http://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}
项目:sres-app    文件:URIResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {
  URI oldURI;
  try {
    oldURI = new URI(result.getURI());
  } catch (URISyntaxException e) {
    return;
  }
  URI newURI = HttpHelper.unredirect(oldURI);
  int count = 0;
  while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
    append(result.getDisplayResult(), 
           null, 
           new String[] { redirectString + " : " + newURI }, 
           newURI.toString());
    oldURI = newURI;
    newURI = HttpHelper.unredirect(newURI);
  }
}
项目:faims-android    文件:SearchBookContentsActivity.java   
@Override
protected JSONObject doInBackground(String... args) {
  try {
    // These return a JSON result which describes if and where the query was found. This API may
    // break or disappear at any time in the future. Since this is an API call rather than a
    // website, we don't use LocaleManager to change the TLD.
    String theQuery = args[0];
    String theIsbn = args[1];
    String uri;
    if (LocaleManager.isBookSearchUrl(theIsbn)) {
      int equals = theIsbn.indexOf('=');
      String volumeId = theIsbn.substring(equals + 1);
      uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    } else {
      uri = "http://www.google.com/books?vid=isbn" + theIsbn + "&jscmd=SearchWithinVolume2&q=" + theQuery;
    }
    CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON);
    return new JSONObject(content.toString());
  } catch (IOException ioe) {
    Log.w(TAG, "Error accessing book search", ioe);
    return null;
  } catch (JSONException je) {
    Log.w(TAG, "Error accessing book search", je);
    return null;
  }
}
项目:faims-android    文件:TitleRetriever.java   
@Override
void retrieveSupplementalInfo() {
  CharSequence contents;
  try {
    contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
  } catch (IOException ioe) {
    // ignore this
    return;
  }
  if (contents != null && contents.length() > 0) {
    Matcher m = TITLE_PATTERN.matcher(contents);
    if (m.find()) {
      String title = m.group(1);
      if (title != null && !title.isEmpty()) {
        if (title.length() > MAX_TITLE_LEN) {
          title = title.substring(0, MAX_TITLE_LEN) + "...";
        }
        append(httpUrl, null, new String[] {title}, httpUrl);
      }
    }
  }
}
项目:faims-android    文件:ProductResultInfoRetriever.java   
@Override
void retrieveSupplementalInfo() throws IOException {

  String encodedProductID = URLEncoder.encode(productID, "UTF-8");
  String uri = "http://www.google." + LocaleManager.getProductSearchCountryTLD(context)
          + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
  CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);

  for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
    Matcher matcher = p.matcher(content);
    if (matcher.find()) {
      append(productID,
             source,
             new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
             uri);
      break;
    }
  }
}