コード例 #1
0
ファイル: URIResultHandler.java プロジェクト: pythe/wristpass
 @Override
 public int getButtonCount() {
   if (LocaleManager.isBookSearchUrl(((URIParsedResult) getResult()).getURI())) {
     return buttons.length;
   }
   return buttons.length - 1;
 }
コード例 #2
0
 @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;
   }
 }
コード例 #3
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
      finish();
      return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
      setTitle(getString(R.string.sbc_name));
    } else {
      setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
      // Populate the search box but don't trigger the search
      queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView =
        (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
  }