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; /*from w w w . jav a 2 s . com*/ import org.xml.sax.Attributes; import uk.co.jarofgreen.cityoutdoors.OurApplication; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.sax.Element; import android.sax.RootElement; import android.sax.StartElementListener; import android.util.Log; /** * * @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 CheckCurrentUserCall extends BaseCall { public CheckCurrentUserCall(InformationNeededFromContext informationNeededFromContext) { super(informationNeededFromContext); } public CheckCurrentUserCall(Context context, OurApplication ourApplication) { super(context, ourApplication); } Integer userID = null; String name = null; String email = null; Integer score = null; public boolean execute() { RootElement root = new RootElement("data"); Element user = root.getChild("user"); user.setStartElementListener(new StartElementListener(){ public void start(Attributes attributes) { if (attributes.getValue("id") != null) userID = Integer.parseInt(attributes.getValue("id")); if (attributes.getValue("score") != null) score = Integer.parseInt(attributes.getValue("score")); name = attributes.getValue("name"); email = attributes.getValue("email"); Log.d("CHECKCALL","userID="+Integer.toString(userID)); } }); setUpCall("/api/v1/currentUser.php?showLinks=0&"); if (!isUserTokenAttached) { return false; } makeCall(root); if (userID != null) { SharedPreferences.Editor editor = informationNeededFromContext.getSettings().edit(); if (score != null) editor.putInt("userScore", score); if (name != null) editor.putString("userDisplayName", name); if (email != null) editor.putString("userEmail", email); editor.commit(); return true; } else { return false; } } }