Skip to content

Commit

Permalink
dependency + ios/mac updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joreilly committed Dec 15, 2020
1 parent 77393df commit 89d14d5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import com.squareup.sqldelight.runtime.coroutines.mapToList
import com.surrus.galwaybus.common.model.*
import com.surrus.galwaybus.common.remote.GalwayBusApi
import com.surrus.galwaybus.db.MyDatabase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collect
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlin.time.Duration
Expand All @@ -30,9 +28,10 @@ open class GalwayBusRepository {
private val galwayBusApi = GalwayBusApi()
private val galwayBusDb = createDb()
private val galwayBusQueries = galwayBusDb?.galwayBusQueries
private val coroutineScope: CoroutineScope = MainScope()

init {
GlobalScope.launch(Dispatchers.Main) {
coroutineScope.launch {
// TODO have "staleness check" here?
fetchAndStoreBusStops()
}
Expand All @@ -43,7 +42,7 @@ open class GalwayBusRepository {
try {
val existingBusStops = getBusStops()
if (existingBusStops.isEmpty()) {
val busStops = galwayBusApi.fetchAllBusStops().filter { it.galway }
val busStops = galwayBusApi.fetchAllBusStops()

busStops.forEach {
galwayBusQueries?.insertItem(it.stop_id, it.stopRef, it.shortName, it.longName, it.latitude, it.longitude)
Expand Down Expand Up @@ -115,8 +114,10 @@ open class GalwayBusRepository {


fun getBusStops(success: (List<BusStop>) -> Unit) {
GlobalScope.launch(Dispatchers.Main) {
success(getBusStops())
coroutineScope.launch {
getBusStopsFlow()?.collect {
success(it)
}
}
}

Expand Down Expand Up @@ -153,30 +154,4 @@ open class GalwayBusRepository {
}
return busRouteList
}


// RTPI based queries
//private val rtpiApi = RTPIApi()

// suspend fun getNearestStops(center: Location): Result<List<Stop>> {
// try {
// val result = rtpiApi.getBusStopInformation()
// val nearestStops = result.results.map { stop ->
// stop to center.distance((Location(stop.latitude.toDouble(), stop.longitude.toDouble()))) //poses.sortedBy { point.distance(it) }.drop(1).take(10)
// }.sortedBy { it.second }.take(20).map { it -> it.first }
//
// return Result.Success(nearestStops)
// } catch(e: Exception) {
// return Result.Error(e)
// }
// }

// suspend fun getRealtimeBusInformation(stopId: String): Result<List<RealtimeBusInformation>> {
// try {
// val result = rtpiApi.getRealtimeBusInformation(stopId)
// return Result.Success(result.results)
// } catch(e: Exception) {
// return Result.Error(e)
// }
// }
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

object Versions {
const val kotlin = "1.4.20"
const val kotlin = "1.4.21"
const val kotlinCoroutines = "1.4.2-native-mt"
const val ktor = "1.4.1"
const val kotlinxSerialization = "1.0.0-RC2"
const val ktor = "1.4.0"
const val kotlinxSerialization = "1.0.0-RC"
const val kotlinxDateTime = "0.1.1"
const val koin = "3.0.0-alpha-4"
const val sqlDelight = "1.4.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>GalwayBusAppSwiftUI.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>2</integer>
</dict>
</dict>
</dict>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "C6C35F96-A8BA-4EF1-85FA-829CCEF0F125"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "GalwayBusAppSwiftUI/MapView.swift"
Expand All @@ -30,8 +30,8 @@
filePath = "GalwayBusAppSwiftUI/ViewModels.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "33"
endingLineNumber = "33"
startingLineNumber = "32"
endingLineNumber = "32"
landmarkName = "fetch()"
landmarkType = "7">
</BreakpointContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ struct BusStopRow : View {
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(busStop.shortName).font(.headline)
Text(busStop.irishShortName).font(.subheadline)
Text(busStop.longName).font(.headline)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class BusRouteViewModel: ObservableObject {


class BusStopViewModel: ObservableObject {
//@Published private(set) var listStops: [listStops] = []
@Published var listStops = [BusStop]()

private let repository: GalwayBusRepository
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
3 changes: 1 addition & 2 deletions macOS/GalwayBus/GalwayBus/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ struct BusStopRow : View {
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(busStop.shortName).font(.headline)
Text(busStop.irishShortName).font(.subheadline)
Text(busStop.longName).font(.headline)
}
}
}
Expand Down

0 comments on commit 89d14d5

Please sign in to comment.