Skip to content

Commit

Permalink
vehicle and place kind enums
Browse files Browse the repository at this point in the history
  • Loading branch information
janvde committed Aug 29, 2017
1 parent 14a81a7 commit 9033be0
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package nl.endevelopment.r2randroid.r2rlib.enums;

/**
* Created by jan on 29/08/2017.
* <p>
* unknown, continent, country, admin3, admin2, admin1, island, village, town, city,
* capital, landmark, place, road, accomodation, station, airport, seaport, sea, lake and river
*/

public enum PlaceKind {
UNKNOWN("unknown"),
CONTINENT("continent"),
COUNTRY("country"),
ADMIN3("admin3"),
ADMIN2("admin2"),
ADMIN1("admin1"),
ISLAND("island"),
VILLAGE("village"),
TOWN("town"),
CAPITAL("capital"),
LANDMARK("landmark"),
PLACE("place"),
ROAD("road"),
ACCOMODATION("accomodation"),
STATION("station"),
AIRPORT("airport"),
SEAPORT("seaport"),
SEA("sea"),
LAKE("lake"),
RIVER("river");


private String type;

PlaceKind(String s) {
type = s;
}

public String getType() {
return type;
}

public static PlaceKind fromString(String text) {
for (PlaceKind p : PlaceKind.values()) {
if (p.getType().equalsIgnoreCase(text)) {
return p;
}
}
return UNKNOWN;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package nl.endevelopment.r2randroid.r2rlib.enums;

/**
* Created by jan on 29/08/2017.
* <p>
* unknown, plane, helicopter, car, bus, taxi, rideshare, shuttle, towncar,
* train, tram, cablecar, subway, ferry, foot, animal, bicycle
*/

public enum VehicleKind {
UNKNOWN("unknown"),
PLANE("plane"),
HELICOPTER("helicopter"),
CAR("car"),
BUS("bus"),
TAXI("taxi"),
RIDESHARE("rideshare"),
SHUTTLE("shuttle"),
TOWNCAR("towncar"),
TRAIN("train"),
TRAM("tram"),
CABLECAR("cablecar"),
SUBWAY("subway"),
FERRY("ferry"),
FOOT("foot"),
ANIMAL("animal"),
BICYCLE("bicycle");


String type;

VehicleKind(String s) {
type = s;
}

public String getType() {
return type;
}

public static VehicleKind fromString(String text) {
for (VehicleKind vehicleKind : VehicleKind.values()) {
if (vehicleKind.getType().equalsIgnoreCase(text)) {
return vehicleKind;
}
}
return UNKNOWN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.os.Parcelable;

/**
*
*If the estimated price is a single value (not a range) then only price is returned.
If the estimated price is a range, then both price and priceLow/priceHigh are returned.
You can choose to display either the single price (for brevity) or the range (for accuracy).
*/
public class IndicativePrice implements Parcelable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import nl.endevelopment.r2randroid.r2rlib.enums.PlaceKind;

/**
* Created by Jan on 23-09-17.
* class for api v1.4
Expand Down Expand Up @@ -78,6 +80,11 @@ public String getKind() {
return kind;
}

//get enum type
public PlaceKind getPlaceKind(){
return PlaceKind.fromString(getKind());
}

public void setKind(String kind) {
this.kind = kind;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.os.Parcel;
import android.os.Parcelable;

import nl.endevelopment.r2randroid.r2rlib.enums.VehicleKind;

/**
* Created by jan on 11/07/16.
*
Expand Down Expand Up @@ -39,6 +41,10 @@ public String getKind() {
return kind;
}

public VehicleKind getVehicleKind(){
return VehicleKind.fromString(getKind());
}

public void setKind(String kind) {
this.kind = kind;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
package nl.endevelopment.r2randroid.r2rlib.request;

import io.reactivex.Observable;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
import retrofit2.http.Url;

/**
* Created by jan on 14/07/16.
*
* <p>
* http://<server>/api/1.4/json/Search?key=<key>&oName=Bern&dName=Zurich&noRideshare
*/

public interface Rome2RioService {
@GET("Search?oName={oName}&dName={dName}&oPos={oPosLat},{oPosLng}&dPost={dPosLat},{dPosLng}")
Call<String> getSearchResponse(
@Path("key") String key,
@Path("oName") String oName, @Path("dName") String dName,
@Path("oPosLat") double oPosLat, @Path("oPosLng") double oPosLng,
@Path("dPosLat") double dPosLat, @Path("dPosLng") double dPosLng);

@GET
Observable<SearchResponse> getSearchResponseRx(@Url String url);
}

0 comments on commit 9033be0

Please sign in to comment.