Back to project page homeless-nyc.
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.
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; } */ }