Back to project page City-Outdoors-Android.
The source code is released under:
Copyright (c) 2012, Edinburgh Council All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are ...
If you think the Android project City-Outdoors-Android 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 uk.co.jarofgreen.cityoutdoors.API; /* www. j a v a2s . co m*/ import org.xml.sax.Attributes; import uk.co.jarofgreen.cityoutdoors.OurApplication; import uk.co.jarofgreen.cityoutdoors.Storage; import uk.co.jarofgreen.cityoutdoors.Model.Feature; import android.content.Context; import android.sax.Element; import android.sax.EndElementListener; import android.sax.RootElement; import android.sax.StartElementListener; /** * * @author James Baster <james@jarofgreen.co.uk> * @copyright City of Edinburgh Council & James Baster * @license Open Source under the 3-clause BSD License * @url https://github.com/City-Outdoors/City-Outdoors-Android */ public class FeaturesCall extends BaseCall { public FeaturesCall(InformationNeededFromContext informationNeededFromContext) { super(informationNeededFromContext); } public FeaturesCall(Context context, OurApplication ourApplication) { super(context, ourApplication); } Feature lastFeature; public void execute() { RootElement root = new RootElement("data"); Element features = root.getChild("features"); Element feature = features.getChild("feature"); final Storage storage = informationNeededFromContext.getStorage(); feature.setStartElementListener(new StartElementListener(){ public void start(Attributes attributes) { lastFeature = new Feature(); lastFeature.setDeleted(attributes.getValue("deleted")); lastFeature.setId(attributes.getValue("id")); lastFeature.setLat(attributes.getValue("lat")); lastFeature.setLng(attributes.getValue("lng")); lastFeature.setTitle(attributes.getValue("title")); lastFeature.setAnsweredAllQuestions(attributes.getValue("answeredAllQuestions")); } }); feature.setEndElementListener(new EndElementListener() { public void end() { storage.storeFeature(lastFeature); } }); Element item = feature.getChild("items").getChild("item"); item.setStartElementListener(new StartElementListener(){ public void start(Attributes attributes) { lastFeature.setCollectionID((int)Integer.parseInt(attributes.getValue("collectionID"))); } }); setUpCall("/api/v1/features.php?showLinks=0&"); makeCall(root); } }