This commit is contained in:
RowenaWinston 2013-10-29 13:59:50 -04:00
commit 264c6020ea
7 changed files with 92 additions and 15 deletions

View File

@ -1,6 +1,6 @@
package com.uncc.gameday.parking; package com.uncc.gameday.parking;
public enum ParkingChoices { public enum ParkingChoice {
GREEN ("GREEN"), GREEN ("GREEN"),
BLACK ("BLACK"), BLACK ("BLACK"),
RED ("RED"), RED ("RED"),
@ -14,6 +14,6 @@ public enum ParkingChoices {
GOLD ("GOLD"); GOLD ("GOLD");
String choice; String choice;
ParkingChoices(String choice) { this.choice = choice; } ParkingChoice(String choice) { this.choice = choice; }
public String getValue() { return choice; } public String getValue() { return choice; }
} }

View File

@ -1,6 +1,8 @@
package com.uncc.gameday.parking; package com.uncc.gameday.parking;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import retrofit.RestAdapter; import retrofit.RestAdapter;
import android.content.Context; import android.content.Context;
@ -23,7 +25,7 @@ public class ParkingClient {
return gds.listLots(); return gds.listLots();
} }
public ParkingLot listLot(ParkingChoices choice) { public ParkingLot listLot(ParkingChoice choice) {
return gds.listLot(choice.getValue()); return gds.listLot(choice.getValue());
} }
@ -31,7 +33,7 @@ public class ParkingClient {
return gds.listLot(lot.getLocation().getValue()); return gds.listLot(lot.getLocation().getValue());
} }
public void rateLot(RatingChoices rating, ParkingChoices parkingLot) { public void rateLot(RatingChoices rating, ParkingChoice parkingLot) {
ParkingRating pRating = new ParkingRating(); ParkingRating pRating = new ParkingRating();
pRating.setParkingLot(parkingLot); pRating.setParkingLot(parkingLot);
pRating.setRating(rating); pRating.setRating(rating);
@ -41,4 +43,19 @@ public class ParkingClient {
public void rateLot(ParkingRating rating) { public void rateLot(ParkingRating rating) {
gds.rateLot(rating, new ParkingLotCallback()); gds.rateLot(rating, new ParkingLotCallback());
} }
public ParkingLot listLotLocation(ParkingLot p){
ParkingCoordinate pc = gds.listLotLocation(p.getLocation().getValue());
p.setCoordinate(pc);
return p;
}
public ParkingLot listLotLocation(ParkingChoice c) {
ParkingCoordinate pc = gds.listLotLocation(c.getValue());
ParkingLot pl = new ParkingLot();
pl.setLocation(c);
pl.setCoordinate(pc);
return pl;
}
} }

View File

@ -0,0 +1,46 @@
package com.uncc.gameday.parking;
import android.content.Intent;
import android.net.Uri;
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 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;
this.label = label;
}
}

View File

@ -2,8 +2,9 @@ package com.uncc.gameday.parking;
public class ParkingLot { public class ParkingLot {
private ParkingChoices location; private ParkingChoice location;
private int filled_pct; private int filled_pct;
private ParkingCoordinate coordinate;
public int getFilledPct() { public int getFilledPct() {
return filled_pct; return filled_pct;
@ -11,11 +12,17 @@ public class ParkingLot {
public void setFilledPct(int filled_pct) { public void setFilledPct(int filled_pct) {
this.filled_pct = filled_pct; this.filled_pct = filled_pct;
} }
public ParkingChoices getLocation() { public ParkingChoice getLocation() {
return location; return location;
} }
public void setLocation(ParkingChoices location) { public void setLocation(ParkingChoice location) {
this.location = location; this.location = location;
} }
public ParkingCoordinate getCoordinate() {
return coordinate;
}
public void setCoordinate(ParkingCoordinate coordinate) {
this.coordinate = coordinate;
}
} }

View File

@ -1,13 +1,13 @@
package com.uncc.gameday.parking; package com.uncc.gameday.parking;
public class ParkingRating { public class ParkingRating {
private ParkingChoices parking_lot; private ParkingChoice parking_lot;
private RatingChoices rating; private RatingChoices rating;
public ParkingChoices getParkingLot() { public ParkingChoice getParkingLot() {
return parking_lot; return parking_lot;
} }
public void setParkingLot(ParkingChoices parking_lot) { public void setParkingLot(ParkingChoice parking_lot) {
this.parking_lot = parking_lot; this.parking_lot = parking_lot;
} }
public RatingChoices getRating() { public RatingChoices getRating() {

View File

@ -6,7 +6,7 @@ import retrofit.RestAdapter;
import android.content.Context; import android.content.Context;
import com.uncc.gameday.R; 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.ParkingLot;
import com.uncc.gameday.parking.ParkingLotCallback; import com.uncc.gameday.parking.ParkingLotCallback;
import com.uncc.gameday.parking.ParkingRating; import com.uncc.gameday.parking.ParkingRating;

View File

@ -2,13 +2,17 @@ package com.uncc.gameday.rest;
import java.util.List; import java.util.List;
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.ParkingLot;
import com.uncc.gameday.parking.ParkingRating; import com.uncc.gameday.parking.ParkingRating;
import com.uncc.gameday.registration.Attendee; import com.uncc.gameday.registration.Attendee;
import retrofit.Callback;
import retrofit.http.*;
public interface GamedayService { public interface GamedayService {
@GET("/lots/") @GET("/lots/")
@ -17,9 +21,12 @@ public interface GamedayService {
@GET("/lots/{lot}/") @GET("/lots/{lot}/")
ParkingLot listLot(@Path("lot") String lot); ParkingLot listLot(@Path("lot") String lot);
@POST("/rate/") @POST("/lots/rate/")
void rateLot(@Body ParkingRating p, Callback<ParkingLot> lot); void rateLot(@Body ParkingRating p, Callback<ParkingLot> lot);
@GET("/lots/{lot}/")
ParkingCoordinate listLotLocation(@Path("lot") String lot);
@GET("/register/{id}/") @GET("/register/{id}/")
Attendee getUser(@Path("id") int id); Attendee getUser(@Path("id") int id);