diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2015-05-08 17:10:06 +0200 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2015-10-11 23:55:58 +0200 |
commit | 8ff62c5f34db48aa15c7252c40fea3381bba0952 (patch) | |
tree | 2a0ffd9bcf9a2648c45f170426cf86fb319509f2 /main/src/cgeo/geocaching/network/StatusUpdater.java | |
parent | 1d2b34e71a01d6af118ed89258ad0ecb983e1a9c (diff) | |
parent | 59b8b2e26a7fff6072c4d5d96f51035dc900e0bc (diff) | |
download | cgeo-8ff62c5f34db48aa15c7252c40fea3381bba0952.zip cgeo-8ff62c5f34db48aa15c7252c40fea3381bba0952.tar.gz cgeo-8ff62c5f34db48aa15c7252c40fea3381bba0952.tar.bz2 |
merge upstream
Diffstat (limited to 'main/src/cgeo/geocaching/network/StatusUpdater.java')
-rw-r--r-- | main/src/cgeo/geocaching/network/StatusUpdater.java | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/main/src/cgeo/geocaching/network/StatusUpdater.java b/main/src/cgeo/geocaching/network/StatusUpdater.java index 82650d1..bc4a5db 100644 --- a/main/src/cgeo/geocaching/network/StatusUpdater.java +++ b/main/src/cgeo/geocaching/network/StatusUpdater.java @@ -4,8 +4,7 @@ import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.utils.RxUtils; import cgeo.geocaching.utils.Version; -import org.json.JSONException; -import org.json.JSONObject; +import com.fasterxml.jackson.databind.node.ObjectNode; import rx.functions.Action0; import rx.subjects.BehaviorSubject; @@ -31,11 +30,11 @@ public class StatusUpdater { this.url = url; } - Status(final JSONObject response) { - message = get(response, "message"); - messageId = get(response, "message_id"); - icon = get(response, "icon"); - url = get(response, "url"); + Status(final ObjectNode response) { + message = response.path("message").asText(null); + messageId = response.path("message_id").asText(null); + icon = response.path("icon").asText(null); + url = response.path("url").asText(null); } final static public Status closeoutStatus = @@ -55,7 +54,7 @@ public class StatusUpdater { RxUtils.networkScheduler.createWorker().schedulePeriodically(new Action0() { @Override public void call() { - final JSONObject response = + final ObjectNode response = Network.requestJSON("http://status.cgeo.org/api/status.json", new Parameters("version_code", String.valueOf(Version.getVersionCode(CgeoApplication.getInstance())), "version_name", Version.getVersionName(CgeoApplication.getInstance()), @@ -67,12 +66,4 @@ public class StatusUpdater { }, 0, 1800, TimeUnit.SECONDS); } - private static String get(final JSONObject json, final String key) { - try { - return json.getString(key); - } catch (final JSONException e) { - return null; - } - } - } |