mirror of
https://github.com/bspeice/itcs4180
synced 2024-11-13 19:08:20 -05:00
Add REST implementation skeleton
The Location class is still in flux, so waiting on that.
This commit is contained in:
parent
a4412c749b
commit
8a527aace4
@ -3,6 +3,7 @@
|
||||
|
||||
<string name="app_name">UNCC Scavenger</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="endpoint">http://djbushido.no-ip.org/</string>
|
||||
|
||||
</resources>
|
||||
|
5
UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java
Normal file
5
UNCCScavenger/src/edu/uncc/scavenger/rest/Location.java
Normal file
@ -0,0 +1,5 @@
|
||||
package edu.uncc.scavenger.rest;
|
||||
|
||||
public class Location {
|
||||
|
||||
}
|
@ -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<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("key", key);
|
||||
keys.put("id", String.valueOf(id));
|
||||
return client.getResult(keys);
|
||||
}
|
||||
|
||||
public static List<Location> getLocations(Context ctx) {
|
||||
LocationService client = getAdapter(ctx);
|
||||
return client.listLocations();
|
||||
}
|
||||
}
|
@ -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<Location> listLocations();
|
||||
|
||||
@GET("/validate")
|
||||
String getResult(@QueryMap Map<String, String> keys);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user