Created
July 30, 2013 14:05
-
-
Save pratamawijaya/6113194 to your computer and use it in GitHub Desktop.
method getDistance dan getDuration yang ditambahkan pada file JSONAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getDistance(JSONObject jsonObject) | |
{ | |
String distance = null; | |
try | |
{ | |
JSONObject objRoute = jObj.getJSONArray(TAG_ROUTES).getJSONObject(0); | |
Utils.TRACE("get Routes"); | |
JSONObject objLegs = objRoute.getJSONArray(TAG_LEGS).getJSONObject(0); | |
Utils.TRACE("get Legs"); | |
JSONObject objDistance = objLegs.getJSONObject(TAG_DISTANCE); | |
distance = objDistance.getString(TAG_TEXT); | |
Utils.TRACE("distance :" + distance); | |
} catch (JSONException e) | |
{ | |
// TODO: handle exception | |
Utils.TRACE("JSON distance gagal : " + e.toString()); | |
} | |
return distance; | |
} | |
public String getDuration(JSONObject jsonObject) | |
{ | |
String duration = null; | |
try | |
{ | |
JSONObject objRoute = jObj.getJSONArray(TAG_ROUTES).getJSONObject(0); | |
Utils.TRACE("get Routes"); | |
JSONObject objLegs = objRoute.getJSONArray(TAG_LEGS).getJSONObject(0); | |
Utils.TRACE("get Legs"); | |
JSONObject objDistance = objLegs.getJSONObject(TAG_DURATION); | |
duration = objDistance.getString(TAG_TEXT); | |
Utils.TRACE("duration :" + duration); | |
} catch (JSONException e) | |
{ | |
// TODO: handle exception | |
Utils.TRACE("JSON duration gagal : " + e.toString()); | |
} | |
return duration; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment