aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/location/OpenCellIdLocationProvider.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-20 18:11:06 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-20 18:11:06 +1300
commit192800b5261d3128386bd83d6b8b684ea417fa9b (patch)
tree6044a01d9cb8cbb17bedd854e75d36e65a3990df /src/org/traccar/location/OpenCellIdLocationProvider.java
parentffd0d7f5a60b33ba45c22210d4ba5f07f2a6d789 (diff)
downloadtrackermap-server-192800b5261d3128386bd83d6b8b684ea417fa9b.tar.gz
trackermap-server-192800b5261d3128386bd83d6b8b684ea417fa9b.tar.bz2
trackermap-server-192800b5261d3128386bd83d6b8b684ea417fa9b.zip
Add support for Mozilla Location Service
Diffstat (limited to 'src/org/traccar/location/OpenCellIdLocationProvider.java')
-rw-r--r--src/org/traccar/location/OpenCellIdLocationProvider.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/org/traccar/location/OpenCellIdLocationProvider.java b/src/org/traccar/location/OpenCellIdLocationProvider.java
index b06f44d1e..94cc1a4e4 100644
--- a/src/org/traccar/location/OpenCellIdLocationProvider.java
+++ b/src/org/traccar/location/OpenCellIdLocationProvider.java
@@ -38,26 +38,26 @@ public class OpenCellIdLocationProvider extends BaseLocationProvider {
protected void getLocation(int mcc, int mnc, long lac, long cid, final LocationProviderCallback callback) {
Context.getAsyncHttpClient().prepareGet(String.format(url, mcc, mnc, lac, cid))
.execute(new AsyncCompletionHandler() {
- @Override
- public Object onCompleted(Response response) throws Exception {
- try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
- JsonObject json = reader.readObject();
- if (json.containsKey("lat") && json.containsKey("lon")) {
- callback.onSuccess(
- json.getJsonNumber("lat").doubleValue(),
- json.getJsonNumber("lon").doubleValue());
- } else {
- callback.onFailure();
- }
- }
- return null;
- }
-
- @Override
- public void onThrowable(Throwable t) {
+ @Override
+ public Object onCompleted(Response response) throws Exception {
+ try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
+ JsonObject json = reader.readObject();
+ if (json.containsKey("lat") && json.containsKey("lon")) {
+ callback.onSuccess(
+ json.getJsonNumber("lat").doubleValue(),
+ json.getJsonNumber("lon").doubleValue());
+ } else {
callback.onFailure();
}
- });
+ }
+ return null;
+ }
+
+ @Override
+ public void onThrowable(Throwable t) {
+ callback.onFailure();
+ }
+ });
}
}