コード例 #1
0
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {
     pref = (Preferences) data.getSerializableExtra("newPref");
     if (pref != null) {
       Log.d("DEBUG", "Image size: " + pref.getImageSize().toString());
       Log.d("DEBUG", "Color filter: " + pref.getColorFilter().toString());
       Log.d("DEBUG", "Image type: " + pref.getImageType().toString());
       Log.d("DEBUG", "Site filter: " + pref.getSiteFilter().toString());
     } else {
       Log.d("DEBUG", "Pref is null <onActivityResult>");
     }
   }
 }
コード例 #2
0
  private String createURL(int offset) {
    String imageSize = "no selection";
    String colorFilter = "no selection";
    String imageType = "no selection";
    String siteSearch = "no selection";
    String tempURL = "";

    if (pref != null) {
      imageSize = pref.getImageSize();
      colorFilter = pref.getColorFilter();
      imageType = pref.getImageType();
      siteSearch = pref.getSiteFilter();
    } else {
      Log.d("DEBUG", "Pref is null");
    }

    if (!colorFilter.equalsIgnoreCase("no selection")) {
      tempURL += "&imgcolor=" + colorFilter;
    }

    if (!imageSize.equalsIgnoreCase("no selection")) {
      tempURL += "&imgsz=" + imageSize;
    }

    if (!imageType.equalsIgnoreCase("no selection")) {
      tempURL += "&imgtype=" + imageType;
    }

    if (!siteSearch.isEmpty()) {
      tempURL += "&as_sitesearch=" + siteSearch;
    }

    Log.d("DEBUG", "Temp URL: " + tempURL);

    String url =
        "https://ajax.googleapis.com/ajax/services/search/images?rsz=8"
            + "&start="
            + (offset * 8)
            + tempURL
            + "&v=1.0&q="
            + Uri.encode(etSearch.getText().toString());

    return url;
  }