-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added RouteOptions.kt * Implemented [RouteAdapter] * Implemented [getRouteOptions] * Changed some naming * Change query parameters for routeNetworking * Changed some location to coordinate * Fixed generic import call * Create customDateAdapter * Create customDateAdapter. * networking fix * added stop class * Computed boardinMins * Compute boardinMins * Cleaned up networking code * Moved [boardInMin] to [Route] and moved [serverFormat] out of a companion object * Fixed a generic import call * Moved some code into a helper function * Added testing comments * Removed an unnecessary comment * Fixed mostly all comments, but I had questions about
- Loading branch information
1 parent
2372e33
commit 22fbcff
Showing
9 changed files
with
174 additions
and
26 deletions.
There are no files selected for viewing
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
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
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
9 changes: 8 additions & 1 deletion
9
app/src/main/java/com/example/ithaca_transit_android_v2/models/Coordinate.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
|
||
import com.squareup.moshi.Json | ||
|
||
//Coordinate.kt - Represents the longitude and latitude of a Location | ||
data class Coordinate( | ||
@Json(name = "lat") | ||
val latitude: Double, | ||
@Json(name = "long") | ||
val longitude: Double | ||
) | ||
){ | ||
override fun toString(): String = "$latitude, $longitude" | ||
} | ||
|
19 changes: 14 additions & 5 deletions
19
app/src/main/java/com/example/ithaca_transit_android_v2/models/Direction.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
import java.util.* | ||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import java.util.Date | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class Direction( | ||
val type : DirectionType, | ||
@Json(name = "path") | ||
val listOfCoordinates: List<Coordinate>, | ||
val startTime: Date, | ||
val endTime: Date, | ||
val startLocation: Location, | ||
val endLocation: Location, | ||
val busStops: List<Location>, | ||
val busNumber: Int | ||
@Json(name = "startLocation") | ||
val startCoords: Coordinate, | ||
@Json(name = "endLocation") | ||
val endCoords: Coordinate, | ||
@Json(name = "stops") | ||
val busStops: List<Stop>, | ||
@Json(name = "routeNumber") | ||
val busNumber: Int? | ||
) |
6 changes: 5 additions & 1 deletion
6
...ca_transit_android_v2/models/RouteType.kt → ...ransit_android_v2/models/DirectionType.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
|
||
import com.squareup.moshi.Json | ||
|
||
/* | ||
Represents the type of route that is displayed on the map | ||
*/ | ||
enum class RouteType { | ||
enum class DirectionType { | ||
@Json(name = "depart") | ||
BUS, | ||
@Json(name = "walk") | ||
WALK | ||
} |
21 changes: 17 additions & 4 deletions
21
app/src/main/java/com/example/ithaca_transit_android_v2/models/Route.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import java.util.Date | ||
import java.util.Calendar | ||
import java.util.concurrent.TimeUnit | ||
|
||
// [Route] is a collection of [Direction] objects and other essential information | ||
// to represent a way of getting to the destination | ||
@JsonClass(generateAdapter = true) | ||
data class Route ( | ||
val directions: List<Direction>, | ||
val startLocation: Location, | ||
val endLocation: Location, | ||
val isWalkingOnly: Boolean, | ||
val startCoords: Coordinate, | ||
val endCoords: Coordinate, | ||
@Json(name ="arrivalTime") | ||
val arrival: Date, | ||
@Json(name ="departureTime") | ||
val depart: Date, | ||
val boardInMin: Int | ||
) | ||
) { | ||
companion object { | ||
fun computeBoardInMin(firstBusDirection: Direction): Int { | ||
val diff = firstBusDirection.startTime.time - Calendar.getInstance().time.time | ||
return TimeUnit.MINUTES.convert(diff, TimeUnit.MILLISECONDS).toInt() | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/ithaca_transit_android_v2/models/RouteOptions.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
/* | ||
* [RouteOptions] is a collection of three groups of route objects | ||
* (fromStop, walking and boardingSoon) for the RouteOptions view | ||
*/ | ||
@JsonClass(generateAdapter = true) | ||
data class RouteOptions ( | ||
val boardingSoon: List<Route>, | ||
val fromStop: List<Route>, | ||
val walking: List<Route> | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/example/ithaca_transit_android_v2/models/Stop.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.ithaca_transit_android_v2.models | ||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
@JsonClass(generateAdapter = true) | ||
data class Stop( | ||
val stopID: String, | ||
val lat: Double, | ||
val long: Double | ||
) |