From 8a527aace4cb91d856d2d6b2fdd722ca40e056ee Mon Sep 17 00:00:00 2001 From: DjBushido Date: Mon, 31 Mar 2014 15:07:10 -0400 Subject: [PATCH] Add REST implementation skeleton The Location class is still in flux, so waiting on that. --- UNCCScavenger/res/values/strings.xml | 3 +- .../src/edu/uncc/scavenger/rest/Location.java | 5 +++ .../uncc/scavenger/rest/LocationClient.java | 34 +++++++++++++++++++ .../uncc/scavenger/rest/LocationService.java | 17 ++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java create mode 100644 UNCCScavenger/src/edu/uncc/scavenger/rest/LocationClient.java create mode 100644 UNCCScavenger/src/edu/uncc/scavenger/rest/LocationService.java diff --git a/UNCCScavenger/res/values/strings.xml b/UNCCScavenger/res/values/strings.xml index 2686f98..b5a8f31 100644 --- a/UNCCScavenger/res/values/strings.xml +++ b/UNCCScavenger/res/values/strings.xml @@ -3,6 +3,7 @@ UNCC Scavenger Settings - Hello world! + Hello world! + http://djbushido.no-ip.org/ diff --git a/UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java b/UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java new file mode 100644 index 0000000..635d98d --- /dev/null +++ b/UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java @@ -0,0 +1,5 @@ +package edu.uncc.scavenger.rest; + +public class Location { + +} diff --git a/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationClient.java b/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationClient.java new file mode 100644 index 0000000..fbf2bbe --- /dev/null +++ b/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationClient.java @@ -0,0 +1,34 @@ +package edu.uncc.scavenger.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import edu.uncc.scavenger.R; +import android.content.Context; + +import retrofit.RestAdapter; + +public class LocationClient { + + + + public static LocationService getAdapter(Context ctx) { + String endpoint = ctx.getString(R.string.endpoint); + RestAdapter ra = new RestAdapter.Builder().setEndpoint(endpoint).build(); + return ra.create(LocationService.class); + } + + public static String validateLocation(Context ctx, int id, String key) { + LocationService client = getAdapter(ctx); + Map keys = new HashMap(); + keys.put("key", key); + keys.put("id", String.valueOf(id)); + return client.getResult(keys); + } + + public static List getLocations(Context ctx) { + LocationService client = getAdapter(ctx); + return client.listLocations(); + } +} diff --git a/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationService.java b/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationService.java new file mode 100644 index 0000000..2282627 --- /dev/null +++ b/UNCCScavenger/src/edu/uncc/scavenger/rest/LocationService.java @@ -0,0 +1,17 @@ +package edu.uncc.scavenger.rest; + +import java.util.List; +import java.util.Map; + +import retrofit.http.GET; +import retrofit.http.QueryMap; + +public interface LocationService { + + @GET("/locations") + List listLocations(); + + @GET("/validate") + String getResult(@QueryMap Map keys); + +}