Back to project page Go2-Rennes.
The source code is released under:
GNU General Public License
If you think the Android project Go2-Rennes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com * //from ww w . ja v a 2 s. c o m * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package fr.gotorennes.remote; import java.util.ArrayList; import java.util.List; import org.json.JSONException; import org.json.JSONObject; import android.content.Context; import fr.gotorennes.domain.PointDeVenteCommune; public class CommuneService extends RemoteService<PointDeVenteCommune> { public static final String COMMAND = "getcities"; public static final String NODE = "city"; private static CommuneService instance; private CommuneService(Context context) { super(); } protected String getVersion() { return "2.0"; } public static synchronized CommuneService getInstance(Context context) { if (instance == null) { instance = new CommuneService(context); } return instance; } private List<PointDeVenteCommune> cache = null; public List<PointDeVenteCommune> getCommunes() { if (cache == null) { cache = loadList(COMMAND, NODE); } return cache != null ? new ArrayList<PointDeVenteCommune>(cache) : cache; } @Override protected PointDeVenteCommune populate(JSONObject jsonObject) throws JSONException { PointDeVenteCommune commune = new PointDeVenteCommune(); commune.id = jsonObject.getString("id"); commune.nom = jsonObject.getString("name"); commune.quartiers = jsonObject.getInt("district"); return commune; } }