Android Open Source - android-grid-image-search Image Result






From Project

Back to project page android-grid-image-search.

License

The source code is released under:

MIT License

If you think the Android project android-grid-image-search 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.gemmakbarlow.gridimagesearch.model;
//  w ww. j  av a2 s .co m
import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

// TODO Things remaining to implement 
// Smoothie (see Github) - Async pagination on a GridView
// No pagination has been added yet
// Filters - size, color, type, site restriction

public class ImageResult implements Serializable {
  
  private static final long serialVersionUID = 2578540597849123970L;
  private String fullUrl;
  private String thumbUrl;
  
  
  // Constructor
  
  public ImageResult(JSONObject json) {
    try {
      this.fullUrl = json.getString("url");
      this.thumbUrl = json.getString("tbUrl");
    } catch (JSONException e) {
      this.fullUrl = null;
      this.thumbUrl = null;
    }
  }
  
  
  // Getters / Setters
  
  public String getFullUrl() {
    return fullUrl;
  }
  public void setFullUrl(String fullUrl) {
    this.fullUrl = fullUrl;
  }
  public String getThumbUrl() {
    return thumbUrl;
  }
  public void setThumbUrl(String thumbUrl) {
    this.thumbUrl = thumbUrl;
  }
  
  
  // Description
  
  public String toString() {
    return this.fullUrl;
  }


  public static ArrayList<ImageResult> fromJSONArray(
      JSONArray imageJsonResults) {
    ArrayList<ImageResult> results = new ArrayList<ImageResult>();
    for(int i=0; i<imageJsonResults.length(); i++) {
      try {
        results.add(new ImageResult(imageJsonResults.getJSONObject(i)));
      }
      catch(JSONException e) {
        
      }
    }
    return results;
  }

  
  // Other
}




Java Source Code List

com.gemmakbarlow.gridimagesearch.AdvancedFilterActivity.java
com.gemmakbarlow.gridimagesearch.EndlessScrollListener.java
com.gemmakbarlow.gridimagesearch.ImageDisplayActivity.java
com.gemmakbarlow.gridimagesearch.ImageResultArrayAdapter.java
com.gemmakbarlow.gridimagesearch.SearchActivity.java
com.gemmakbarlow.gridimagesearch.model.ImageResult.java
com.gemmakbarlow.gridimagesearch.model.SearchQuery.java