Android Open Source - homeless-nyc facilities Manager






From Project

Back to project page homeless-nyc.

License

The source code is released under:

GNU General Public License

If you think the Android project homeless-nyc 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 io.rasmi.homelessnyc;
/*from  www  .ja  v  a 2 s  .c o  m*/
import java.util.ArrayList;

import android.content.Context;
import android.util.Log;

public class facilitiesManager {
  private static final String TAG = "facilitiesManager";
  private static facilitiesManager FacilitiesManager;
  private Context mAppContext;
  private JSONParser parser;
  
  private ArrayList<facility> foodbanks;
  private ArrayList<facility> foodstamps;
  private ArrayList<facility> homebases;
  private ArrayList<facility> libraries;
  private ArrayList<facility> shelters;
  
  private facilitiesManager(Context appContext) {
    mAppContext = appContext;
    parser = new JSONParser(mAppContext);
    try {
      foodbanks = parser.loadFacilities("foodbanks");
      foodstamps = parser.loadFacilities("foodstamps");
      homebases = parser.loadFacilities("homebases");
      libraries = parser.loadFacilities("libraries");
      shelters = parser.loadFacilities("shelters");
    } catch (Exception e) {
      foodbanks = new ArrayList<facility>();
      foodstamps = new ArrayList<facility>();
      homebases = new ArrayList<facility>();
      libraries = new ArrayList<facility>();
      shelters = new ArrayList<facility>();
      Log.e(TAG, "Error loading facilities from JSON file.");
    }
  }
  
  public static facilitiesManager get(Context context) {
    if (FacilitiesManager == null) {
      FacilitiesManager = new facilitiesManager(context.getApplicationContext());
    }
    
    return FacilitiesManager;
  }
  
  public ArrayList<facility> getFacilities(String type) {
    if ("foodbanks".equals(type)) return foodbanks;
    else if ("foodstamps".equals(type)) return foodstamps;
    else if ("homebases".equals(type)) return homebases;
    else if ("libraries".equals(type)) return libraries;
    else if ("shelters".equals(type)) return shelters;
    else return null;
  }
  
  /*
  public facility getFacility(String id) {
    for (facility f : facilities) {
      if (f.id.equals(id))
        return f;
    }
    return null;
  }
  */
}




Java Source Code List

io.rasmi.homelessnyc.JSONParser.java
io.rasmi.homelessnyc.MainActivity.java
io.rasmi.homelessnyc.MapActivity.java
io.rasmi.homelessnyc.facilitiesManager.java
io.rasmi.homelessnyc.facilityInfo.java
io.rasmi.homelessnyc.facility.java
io.rasmi.homelessnyc.faq.java
io.rasmi.homelessnyc.reportActivity.java
io.rasmi.homelessnyc.serviceInfo.java
io.rasmi.homelessnyc.serviceList.java
io.rasmi.homelessnyc.service.java
io.rasmi.homelessnyc.servicesManager.java
io.rasmi.homelessnyc.webAction.java