From 4264fa6fc72066c7248f24e30474dacb8499a852 Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 12:04:35 -0400 Subject: [PATCH 1/5] Move the rateLot function to a new URL --- src/com/uncc/gameday/rest/GamedayService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/uncc/gameday/rest/GamedayService.java b/src/com/uncc/gameday/rest/GamedayService.java index 59b67c2..e573fc7 100644 --- a/src/com/uncc/gameday/rest/GamedayService.java +++ b/src/com/uncc/gameday/rest/GamedayService.java @@ -17,7 +17,7 @@ public interface GamedayService { @GET("/lots/{lot}/") ParkingLot listLot(@Path("lot") String lot); - @POST("/rate/") + @POST("/lots/rate/") void rateLot(@Body ParkingRating p, Callback lot); @GET("/register/{id}/") From 6955ef0b093fe64ea8365af402effe4be03cc5f8 Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 14:20:22 -0400 Subject: [PATCH 2/5] Add code to grab parking lot locations from the server Hindsight being what it is, this would have been just as easy to write client-side. May end up doing that. --- .../uncc/gameday/parking/ParkingClient.java | 16 +++++++++++ .../uncc/gameday/parking/ParkingLocation.java | 27 +++++++++++++++++++ src/com/uncc/gameday/rest/GamedayService.java | 4 +++ 3 files changed, 47 insertions(+) create mode 100644 src/com/uncc/gameday/parking/ParkingLocation.java diff --git a/src/com/uncc/gameday/parking/ParkingClient.java b/src/com/uncc/gameday/parking/ParkingClient.java index d25e217..8f34745 100644 --- a/src/com/uncc/gameday/parking/ParkingClient.java +++ b/src/com/uncc/gameday/parking/ParkingClient.java @@ -1,6 +1,8 @@ package com.uncc.gameday.parking; +import java.util.HashMap; import java.util.List; +import java.util.Map; import retrofit.RestAdapter; import android.content.Context; @@ -41,4 +43,18 @@ public class ParkingClient { public void rateLot(ParkingRating rating) { gds.rateLot(rating, new ParkingLotCallback()); } + + public Map listLotLocation(ParkingLot p){ + HashMap mMap = new HashMap(); + mMap.put(p, gds.listLotLocation(p.getLocation().getValue())); + return mMap; + } + + public Map listLotLocation(ParkingChoices c) { + HashMap mMap = new HashMap(); + ParkingLot mParkingLot = new ParkingLot(); + mParkingLot.setLocation(c); + mMap.put(mParkingLot, gds.listLotLocation(c.getValue())); + return mMap; + } } diff --git a/src/com/uncc/gameday/parking/ParkingLocation.java b/src/com/uncc/gameday/parking/ParkingLocation.java new file mode 100644 index 0000000..28a44c6 --- /dev/null +++ b/src/com/uncc/gameday/parking/ParkingLocation.java @@ -0,0 +1,27 @@ +package com.uncc.gameday.parking; + +public class ParkingLocation { + + private int latitude; + private int longitude; + private String label; + + public int getLatitude() { + return latitude; + } + public void setLatitude(int latitude) { + this.latitude = latitude; + } + public int getLongitude() { + return longitude; + } + public void setLongitude(int longitude) { + this.longitude = longitude; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } +} diff --git a/src/com/uncc/gameday/rest/GamedayService.java b/src/com/uncc/gameday/rest/GamedayService.java index e573fc7..f485ef7 100644 --- a/src/com/uncc/gameday/rest/GamedayService.java +++ b/src/com/uncc/gameday/rest/GamedayService.java @@ -2,6 +2,7 @@ package com.uncc.gameday.rest; import java.util.List; +import com.uncc.gameday.parking.ParkingLocation; import com.uncc.gameday.parking.ParkingLot; import com.uncc.gameday.parking.ParkingRating; import com.uncc.gameday.registration.Attendee; @@ -20,6 +21,9 @@ public interface GamedayService { @POST("/lots/rate/") void rateLot(@Body ParkingRating p, Callback lot); + @GET("/lots/{lot}/") + ParkingLocation listLotLocation(@Path("lot") String lot); + @GET("/register/{id}/") Attendee getUser(@Path("id") int id); From 6a37e14a470097d44e329ae468f968768e9d4127 Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 14:22:21 -0400 Subject: [PATCH 3/5] Rename ParkingChoices to ParkingChoice --- .../parking/{ParkingChoices.java => ParkingChoice.java} | 4 ++-- src/com/uncc/gameday/parking/ParkingClient.java | 6 +++--- src/com/uncc/gameday/parking/ParkingLot.java | 6 +++--- src/com/uncc/gameday/parking/ParkingRating.java | 6 +++--- src/com/uncc/gameday/registration/RegistrationClient.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename src/com/uncc/gameday/parking/{ParkingChoices.java => ParkingChoice.java} (73%) diff --git a/src/com/uncc/gameday/parking/ParkingChoices.java b/src/com/uncc/gameday/parking/ParkingChoice.java similarity index 73% rename from src/com/uncc/gameday/parking/ParkingChoices.java rename to src/com/uncc/gameday/parking/ParkingChoice.java index 2d1bd14..7574a9f 100644 --- a/src/com/uncc/gameday/parking/ParkingChoices.java +++ b/src/com/uncc/gameday/parking/ParkingChoice.java @@ -1,6 +1,6 @@ package com.uncc.gameday.parking; -public enum ParkingChoices { +public enum ParkingChoice { GREEN ("GREEN"), BLACK ("BLACK"), RED ("RED"), @@ -14,6 +14,6 @@ public enum ParkingChoices { GOLD ("GOLD"); String choice; - ParkingChoices(String choice) { this.choice = choice; } + ParkingChoice(String choice) { this.choice = choice; } public String getValue() { return choice; } } \ No newline at end of file diff --git a/src/com/uncc/gameday/parking/ParkingClient.java b/src/com/uncc/gameday/parking/ParkingClient.java index 8f34745..f9dabcd 100644 --- a/src/com/uncc/gameday/parking/ParkingClient.java +++ b/src/com/uncc/gameday/parking/ParkingClient.java @@ -25,7 +25,7 @@ public class ParkingClient { return gds.listLots(); } - public ParkingLot listLot(ParkingChoices choice) { + public ParkingLot listLot(ParkingChoice choice) { return gds.listLot(choice.getValue()); } @@ -33,7 +33,7 @@ public class ParkingClient { return gds.listLot(lot.getLocation().getValue()); } - public void rateLot(RatingChoices rating, ParkingChoices parkingLot) { + public void rateLot(RatingChoices rating, ParkingChoice parkingLot) { ParkingRating pRating = new ParkingRating(); pRating.setParkingLot(parkingLot); pRating.setRating(rating); @@ -50,7 +50,7 @@ public class ParkingClient { return mMap; } - public Map listLotLocation(ParkingChoices c) { + public Map listLotLocation(ParkingChoice c) { HashMap mMap = new HashMap(); ParkingLot mParkingLot = new ParkingLot(); mParkingLot.setLocation(c); diff --git a/src/com/uncc/gameday/parking/ParkingLot.java b/src/com/uncc/gameday/parking/ParkingLot.java index 2c278a9..df5b8f9 100644 --- a/src/com/uncc/gameday/parking/ParkingLot.java +++ b/src/com/uncc/gameday/parking/ParkingLot.java @@ -2,7 +2,7 @@ package com.uncc.gameday.parking; public class ParkingLot { - private ParkingChoices location; + private ParkingChoice location; private int filled_pct; public int getFilledPct() { @@ -11,10 +11,10 @@ public class ParkingLot { public void setFilledPct(int filled_pct) { this.filled_pct = filled_pct; } - public ParkingChoices getLocation() { + public ParkingChoice getLocation() { return location; } - public void setLocation(ParkingChoices location) { + public void setLocation(ParkingChoice location) { this.location = location; } diff --git a/src/com/uncc/gameday/parking/ParkingRating.java b/src/com/uncc/gameday/parking/ParkingRating.java index 8670d61..9e03669 100644 --- a/src/com/uncc/gameday/parking/ParkingRating.java +++ b/src/com/uncc/gameday/parking/ParkingRating.java @@ -1,13 +1,13 @@ package com.uncc.gameday.parking; public class ParkingRating { - private ParkingChoices parking_lot; + private ParkingChoice parking_lot; private RatingChoices rating; - public ParkingChoices getParkingLot() { + public ParkingChoice getParkingLot() { return parking_lot; } - public void setParkingLot(ParkingChoices parking_lot) { + public void setParkingLot(ParkingChoice parking_lot) { this.parking_lot = parking_lot; } public RatingChoices getRating() { diff --git a/src/com/uncc/gameday/registration/RegistrationClient.java b/src/com/uncc/gameday/registration/RegistrationClient.java index f20a00b..cf292ba 100644 --- a/src/com/uncc/gameday/registration/RegistrationClient.java +++ b/src/com/uncc/gameday/registration/RegistrationClient.java @@ -6,7 +6,7 @@ import retrofit.RestAdapter; import android.content.Context; import com.uncc.gameday.R; -import com.uncc.gameday.parking.ParkingChoices; +import com.uncc.gameday.parking.ParkingChoice; import com.uncc.gameday.parking.ParkingLot; import com.uncc.gameday.parking.ParkingLotCallback; import com.uncc.gameday.parking.ParkingRating; From 5ad1f3b075a534401c7bcad0ae8b03349f0860fd Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 14:58:44 -0400 Subject: [PATCH 4/5] Move off the HashMap stuff, stick a ParkingCoordinate inside a ParkingLot --- .../uncc/gameday/parking/ParkingClient.java | 21 ++++++------ .../gameday/parking/ParkingCoordinate.java | 33 +++++++++++++++++++ .../uncc/gameday/parking/ParkingLocation.java | 27 --------------- src/com/uncc/gameday/parking/ParkingLot.java | 7 ++++ src/com/uncc/gameday/rest/GamedayService.java | 13 +++++--- 5 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 src/com/uncc/gameday/parking/ParkingCoordinate.java delete mode 100644 src/com/uncc/gameday/parking/ParkingLocation.java diff --git a/src/com/uncc/gameday/parking/ParkingClient.java b/src/com/uncc/gameday/parking/ParkingClient.java index f9dabcd..ac30b4a 100644 --- a/src/com/uncc/gameday/parking/ParkingClient.java +++ b/src/com/uncc/gameday/parking/ParkingClient.java @@ -44,17 +44,18 @@ public class ParkingClient { gds.rateLot(rating, new ParkingLotCallback()); } - public Map listLotLocation(ParkingLot p){ - HashMap mMap = new HashMap(); - mMap.put(p, gds.listLotLocation(p.getLocation().getValue())); - return mMap; + public ParkingLot listLotLocation(ParkingLot p){ + ParkingCoordinate pc = gds.listLotLocation(p.getLocation().getValue()); + p.setCoordinate(pc); + return p; } - public Map listLotLocation(ParkingChoice c) { - HashMap mMap = new HashMap(); - ParkingLot mParkingLot = new ParkingLot(); - mParkingLot.setLocation(c); - mMap.put(mParkingLot, gds.listLotLocation(c.getValue())); - return mMap; + public ParkingLot listLotLocation(ParkingChoice c) { + ParkingCoordinate pc = gds.listLotLocation(c.getValue()); + ParkingLot pl = new ParkingLot(); + pl.setLocation(c); + pl.setCoordinate(pc); + return pl; } + } diff --git a/src/com/uncc/gameday/parking/ParkingCoordinate.java b/src/com/uncc/gameday/parking/ParkingCoordinate.java new file mode 100644 index 0000000..3fe8587 --- /dev/null +++ b/src/com/uncc/gameday/parking/ParkingCoordinate.java @@ -0,0 +1,33 @@ +package com.uncc.gameday.parking; + +public class ParkingCoordinate { + private double latitude; + private double longitude; + private String label; + + public double getLatitude() { + return latitude; + } + public void setLatitude(double latitude) { + this.latitude = latitude; + } + public double getLongitude() { + return longitude; + } + public void setLongitude(double longitude) { + this.longitude = longitude; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + + public ParkingCoordinate(double latitude, double longitude, String label) { + this.latitude = latitude; + this.longitude = longitude; + this.label = label; + } + +} diff --git a/src/com/uncc/gameday/parking/ParkingLocation.java b/src/com/uncc/gameday/parking/ParkingLocation.java deleted file mode 100644 index 28a44c6..0000000 --- a/src/com/uncc/gameday/parking/ParkingLocation.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.uncc.gameday.parking; - -public class ParkingLocation { - - private int latitude; - private int longitude; - private String label; - - public int getLatitude() { - return latitude; - } - public void setLatitude(int latitude) { - this.latitude = latitude; - } - public int getLongitude() { - return longitude; - } - public void setLongitude(int longitude) { - this.longitude = longitude; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } -} diff --git a/src/com/uncc/gameday/parking/ParkingLot.java b/src/com/uncc/gameday/parking/ParkingLot.java index df5b8f9..ecaa8fa 100644 --- a/src/com/uncc/gameday/parking/ParkingLot.java +++ b/src/com/uncc/gameday/parking/ParkingLot.java @@ -4,6 +4,7 @@ public class ParkingLot { private ParkingChoice location; private int filled_pct; + private ParkingCoordinate coordinate; public int getFilledPct() { return filled_pct; @@ -17,5 +18,11 @@ public class ParkingLot { public void setLocation(ParkingChoice location) { this.location = location; } + public ParkingCoordinate getCoordinate() { + return coordinate; + } + public void setCoordinate(ParkingCoordinate coordinate) { + this.coordinate = coordinate; + } } diff --git a/src/com/uncc/gameday/rest/GamedayService.java b/src/com/uncc/gameday/rest/GamedayService.java index f485ef7..23baa61 100644 --- a/src/com/uncc/gameday/rest/GamedayService.java +++ b/src/com/uncc/gameday/rest/GamedayService.java @@ -2,14 +2,17 @@ package com.uncc.gameday.rest; import java.util.List; -import com.uncc.gameday.parking.ParkingLocation; +import retrofit.Callback; +import retrofit.http.Body; +import retrofit.http.GET; +import retrofit.http.POST; +import retrofit.http.Path; + +import com.uncc.gameday.parking.ParkingCoordinate; import com.uncc.gameday.parking.ParkingLot; import com.uncc.gameday.parking.ParkingRating; import com.uncc.gameday.registration.Attendee; -import retrofit.Callback; -import retrofit.http.*; - public interface GamedayService { @GET("/lots/") @@ -22,7 +25,7 @@ public interface GamedayService { void rateLot(@Body ParkingRating p, Callback lot); @GET("/lots/{lot}/") - ParkingLocation listLotLocation(@Path("lot") String lot); + ParkingCoordinate listLotLocation(@Path("lot") String lot); @GET("/register/{id}/") Attendee getUser(@Path("id") int id); From a20b2e4789fca22a8c2175adc6459d40eb1f4d9f Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 15:12:12 -0400 Subject: [PATCH 5/5] Add utility code to make navigation easy --- src/com/uncc/gameday/parking/ParkingCoordinate.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/uncc/gameday/parking/ParkingCoordinate.java b/src/com/uncc/gameday/parking/ParkingCoordinate.java index 3fe8587..be1a966 100644 --- a/src/com/uncc/gameday/parking/ParkingCoordinate.java +++ b/src/com/uncc/gameday/parking/ParkingCoordinate.java @@ -1,5 +1,8 @@ package com.uncc.gameday.parking; +import android.content.Intent; +import android.net.Uri; + public class ParkingCoordinate { private double latitude; private double longitude; @@ -24,6 +27,16 @@ public class ParkingCoordinate { this.label = label; } + public Uri getNavigationURI() { + // URI used to construct an intent for navigation + return Uri.parse("google.navigation:q=" + this.getLatitude() + "," + this.getLongitude()); + } + + public Intent getNavigationIntent() { + // Intent used to do navigation + return new Intent(Intent.ACTION_VIEW, this.getNavigationURI()); + } + public ParkingCoordinate(double latitude, double longitude, String label) { this.latitude = latitude; this.longitude = longitude;