Android Open Source - isidore Region






From Project

Back to project page isidore.

License

The source code is released under:

GNU General Public License

If you think the Android project isidore 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.tbardici.isidore;
/* w w  w.  j  a  v a 2  s  . co  m*/
import java.util.ArrayList;

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

/**
 * 
 * @author Teo
 *
 */
public class Region {
  public final int id;
  public final String slug;
  public final String name;
  
  public Region(JSONObject from) throws JSONException{
    this.id =     from.getInt("id");
    this.name =   from.getString("name");
    this.slug =   from.getString("slug");
  }
  
  private static ArrayList<Region> regions = new ArrayList<Region>();
  private static String rawJson;
  
  public static void initialize(JSONObject obj) throws JSONException{
    Region.regions = new ArrayList<Region>();
    if (obj != null){
      Region.rawJson = obj.toString();
      JSONArray array = obj.getJSONArray("regions");
      for (int i = 0; i < array.length(); i++){
        Region.regions.add(new Region(array.getJSONObject(i)));  
      }
    }
  }
  
  public static Region getWithId(int id){
    for (int i = 0; i < Region.regions.size(); i++){
      if (Region.regions.get(i).id == id){
        return Region.regions.get(i);
      }
    }
    return null;
  }
  
  public static ArrayList<Region> getRegions(){
    return Region.regions;
  }
  
  public static String getRawJson(){
    return Region.rawJson;
  }
  
  @Override
  public String toString() {
    return name;
  }
}




Java Source Code List

com.tbardici.isidore.CallDOApiAsync.java
com.tbardici.isidore.CreateDropletActivity.java
com.tbardici.isidore.DCConfirmDialogFragment.java
com.tbardici.isidore.DOApi.java
com.tbardici.isidore.DrawablePreviewActivity.java
com.tbardici.isidore.DropletImage.java
com.tbardici.isidore.DropletListAdapter.java
com.tbardici.isidore.DropletType.java
com.tbardici.isidore.IsidoreSettings.java
com.tbardici.isidore.ItemDetailActivity.java
com.tbardici.isidore.ItemDetailFragment.java
com.tbardici.isidore.ItemListActivity.java
com.tbardici.isidore.ItemListFragment.java
com.tbardici.isidore.LoadDropletsAsync.java
com.tbardici.isidore.LongDurationCall.java
com.tbardici.isidore.MainActivity.java
com.tbardici.isidore.Region.java
com.tbardici.isidore.droplet.MyDroplets.java