mirror of
https://github.com/bspeice/itcs4180
synced 2025-04-20 23:01:34 -04:00
The LocationClient shouldn't be static.
This commit is contained in:
parent
c41c2bf4b9
commit
cea007421b
@ -11,24 +11,28 @@ import retrofit.RestAdapter;
|
|||||||
|
|
||||||
public class LocationClient {
|
public class LocationClient {
|
||||||
|
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
|
public LocationClient(Context ctx) {
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
public static LocationService getAdapter(Context ctx) {
|
public LocationService getAdapter() {
|
||||||
String endpoint = ctx.getString(R.string.endpoint);
|
String endpoint = ctx.getString(R.string.endpoint);
|
||||||
RestAdapter ra = new RestAdapter.Builder().setEndpoint(endpoint).build();
|
RestAdapter ra = new RestAdapter.Builder().setEndpoint(endpoint).build();
|
||||||
return ra.create(LocationService.class);
|
return ra.create(LocationService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String validateLocation(Context ctx, int id, String key) {
|
public String validateLocation(int id, String key) {
|
||||||
LocationService client = getAdapter(ctx);
|
LocationService client = getAdapter();
|
||||||
Map<String, String> keys = new HashMap<String, String>();
|
Map<String, String> keys = new HashMap<String, String>();
|
||||||
keys.put("key", key);
|
keys.put("key", key);
|
||||||
keys.put("id", String.valueOf(id));
|
keys.put("id", String.valueOf(id));
|
||||||
return client.getResult(keys);
|
return client.getResult(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Location> getLocations(Context ctx) {
|
public List<Location> getLocations(Context ctx) {
|
||||||
LocationService client = getAdapter(ctx);
|
LocationService client = getAdapter();
|
||||||
return client.listLocations();
|
return client.listLocations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user