Android Open Source - KangarooImageSearch Settings Data






From Project

Back to project page KangarooImageSearch.

License

The source code is released under:

MIT License

If you think the Android project KangarooImageSearch listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nickrasband.kangarooimagesearchv2;
//  w  w w .j a v  a2 s  .  c  o  m
import java.io.Serializable;

/**
 * This class serves as a container for Google Image Search API settings
 * which the user has chosen.
 * @author Nik Rasband
 *
 */
public class SettingsData implements Serializable {
  private static final long serialVersionUID = -3333357209777261623L;
  // Use siteSearch to restrict the domain within which the site is performed.
  private static final String SITE_SEARCH_KEY = "as_sitesearch";
  public String siteSearch;
  
  private String getSiteSearchParam() {
    String param = "";
    if (siteSearch != "") {
      param = "&" + SITE_SEARCH_KEY + "=" + siteSearch;
    }
    return param;
  }
  
  // Used to restrict the search to images containing the provided
  // color predominantly.
  private static final String IMAGE_COLOR_KEY = "imgcolor";
  public String imageColor;
  private String [] imageColors = new String[] {
      "black",
          "blue",
          "brown",
      "gray",
      "green",
      "orange",
      "pink",
      "purple",
      "red",
      "teal",
      "white",
      "yellow"
  };
  
  private String getImageColorParam() {
    String param = "";
    if (imageColor != "") {
      param = "&" + IMAGE_COLOR_KEY + "=" + imageColor;
    }
    return param;
  }
  
  public int getColorFilterIndex() {
    int index = -1;
    for (int i = 0; i < imageColors.length; ++i) {
      if (imageColors[i].equals(imageColor)){
        index = i;
        break;
      }
    }
    return index;
  }
  
  // Restrict the image set to images of a particular size.
  // imgsz=icon restricts results to small images
  // imgsz=small|medium|large|xlarge restricts results to medium-sized images
  // imgsz=xxlarge restricts results to large images
  // imgsz=huge restricts results to extra-large images
  private static final String IMAGE_SIZE_KEY = "imgsz";
  public String imageSize;
  private String [] imageSizes = new String [] {
      "icon", "small", "medium", "large", "xlarge", "xxlarge", "huge"
  };
  
  private String getImageSizeParam() {
    String param = "";
    if (imageSize != "") {
      param = "&" + IMAGE_SIZE_KEY + "=" + imageSize;
    }
    return param;
  }
  
  public int getImageSizeIndex() {
    int index = -1;
    for (int i = 0; i < imageSizes.length; ++i) {
      if (imageSizes[i].equals(imageSize)) {
        index = i;
        break;
      }
    }
    return index;
  }
  
  // Restrict the results to certain image types.
  // imgtype=face restricts results to images of faces.
  // imgtype=photo restricts results to photographic images.
  // imgtype=clipart restricts results to clipart images.
  // imgtype=lineart restricts results to line drawing images.
  public static final String IMAGE_TYPE_KEY = "imgtype";
  public String imageType;
  private String [] imageTypes = new String[] {
      "face", "photo", "clipart", "lineart"
  };
  
  private String getImageTypeParam() {
    String param = "";
    if (imageType != "") {
      param = "&" + IMAGE_TYPE_KEY + "=" + imageType;
    }
    return param;
  }
  
  public int getImageTypeIndex() {
    int index = -1;
    for (int i = 0; i < imageTypes.length; ++i) {
      if (imageTypes[i].equals(imageType)){
        index = i;
        break;
      }
    }
    return index;
  }
  
  public String getParams() {
    return getImageTypeParam() + getImageSizeParam() + getImageColorParam() + getSiteSearchParam();
  }
  
  public SettingsData() {
    siteSearch = "";
    imageColor = "";
    imageSize = "";
    imageType = "";
  }
}




Java Source Code List

com.nickrasband.kangarooimagesearchv2.EndlessScrollListener.java
com.nickrasband.kangarooimagesearchv2.FullScreenImageActivity.java
com.nickrasband.kangarooimagesearchv2.ImageDataAdapter.java
com.nickrasband.kangarooimagesearchv2.ImageData.java
com.nickrasband.kangarooimagesearchv2.ImageSearchActivity.java
com.nickrasband.kangarooimagesearchv2.SettingsActivity.java
com.nickrasband.kangarooimagesearchv2.SettingsData.java
com.nickrasband.kangarooimagesearchv2.Utils.java