Skip to content

Commit 733bb40

Browse files
committed
minor optimization
1 parent 901c053 commit 733bb40

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

.idea/workspace.xml

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.codebyashish.googledirectionapi;
22

3-
public class KeyConstants {
3+
public class Constants {
44

55
public static String DIRECTION_BASE_URL = "https://maps.googleapis.com/maps/api/directions/json?";
66
public static String START_LOCATION = "start_location";

GoogleDirectionApi/src/main/java/com/codebyashish/googledirectionapi/RouteDrawing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private RouteDrawing(Builder builder) {
2727
}
2828

2929
protected String constructURL() {
30-
StringBuilder stringBuilder = new StringBuilder(KeyConstants.DIRECTION_BASE_URL);
30+
StringBuilder stringBuilder = new StringBuilder(Constants.DIRECTION_BASE_URL);
3131
LatLng origin = this.waypoints.get(0);
3232
stringBuilder.append("origin=");
3333
stringBuilder.append(origin.latitude);

GoogleDirectionApi/src/main/java/com/codebyashish/googledirectionapi/RouteJsonParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ArrayList<RouteInfoModel> parse() throws ErrorHandling {
3131
} else {
3232
try {
3333
JSONObject json = new JSONObject(result);
34-
if (!json.getString("status").equals(KeyConstants.OK)) {
34+
if (!json.getString("status").equals(Constants.OK)) {
3535
throw new ErrorHandling(json);
3636
} else {
3737
JSONArray jsonRoutes = json.getJSONArray("routes");
@@ -46,7 +46,7 @@ public ArrayList<RouteInfoModel> parse() throws ErrorHandling {
4646
JSONObject leg = jsonRoute.getJSONArray("legs").getJSONObject(0);
4747
JSONArray steps = leg.getJSONArray("steps");
4848

49-
routeInfoModel.setName(leg.getString(KeyConstants.START_ADDRESS) + " to " + leg.getString(KeyConstants.END_ADDRESS));
49+
routeInfoModel.setName(leg.getString(Constants.START_ADDRESS) + " to " + leg.getString(Constants.END_ADDRESS));
5050
routeInfoModel.setCopyright(jsonRoute.getString("copyrights"));
5151
routeInfoModel.setDurationText(leg.getJSONObject("duration").getString("text"));
5252
routeInfoModel.setDurationValue(leg.getJSONObject("duration").getInt("value"));
@@ -60,7 +60,7 @@ public ArrayList<RouteInfoModel> parse() throws ErrorHandling {
6060

6161
for(int y = 0; y < steps.length(); ++y) {
6262
JSONObject step = steps.getJSONObject(y);
63-
JSONObject start = step.getJSONObject(KeyConstants.START_LOCATION);
63+
JSONObject start = step.getJSONObject(Constants.START_LOCATION);
6464
LatLng position = new LatLng(start.getDouble("lat"), start.getDouble("lng"));
6565
stepsModel.setPoint(position);
6666
int length = step.getJSONObject("distance").getInt("value");

0 commit comments

Comments
 (0)