mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Switched to a generic LocationHandler.kt
This commit is contained in:
1 parent
eebe691419
commit
a9a4aa9737
24 files changed
+462
-557
No files matched your search
@@ -32,7 +32,7 @@ class DefaultRepository(
|
||||
private val dataParser: DataParser,
|
||||
private val localSource: LocalDataSource,
|
||||
private val remoteSource: RemoteDataSource,
|
||||
private val preferences: PreferencesHandler
|
||||
private val settings: SettingsHandler
|
||||
) : DataRepository {
|
||||
|
||||
override fun getSatelliteItems() = localSource.getSatelliteItems()
|
||||
@@ -48,7 +48,7 @@ class DefaultRepository(
|
||||
override suspend fun updateDataFromWeb(sources: List<String>) {
|
||||
coroutineScope {
|
||||
launch {
|
||||
preferences.saveDataSources(sources)
|
||||
settings.saveDataSources(sources)
|
||||
}
|
||||
launch {
|
||||
val updateTimeMillis = measureTimeMillis {
|
||||
@@ -78,7 +78,7 @@ class DefaultRepository(
|
||||
println("Update from web took $updateTimeMillis ms")
|
||||
}
|
||||
launch {
|
||||
remoteSource.fetchFileStream(preferences.transmittersSource)?.let { inputStream ->
|
||||
remoteSource.fetchFileStream(settings.transmittersSource)?.let { inputStream ->
|
||||
val transmitters = dataParser.parseJSONStream(inputStream)
|
||||
localSource.updateTransmitters(transmitters)
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.rtbishop.look4sat.data
|
||||
|
||||
interface PreferencesHandler {
|
||||
interface SettingsHandler {
|
||||
|
||||
val defaultSources: List<String>
|
||||
get() = listOf(
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.rtbishop.look4sat.domain
|
||||
|
||||
import com.rtbishop.look4sat.domain.model.DataState
|
||||
import com.rtbishop.look4sat.domain.predict.GeoPos
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
|
||||
interface LocationHandler {
|
||||
|
||||
val stationPosition: SharedFlow<DataState<GeoPos>>
|
||||
|
||||
fun getStationPosition(): GeoPos
|
||||
|
||||
fun setStationPosition(latitude: Double, longitude: Double)
|
||||
|
||||
fun setPositionFromLocation()
|
||||
|
||||
fun setPositionFromNet()
|
||||
|
||||
fun setPositionFromGps()
|
||||
|
||||
fun setPositionFromQth(qthString: String)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.rtbishop.look4sat.domain
|
||||
|
||||
import com.rtbishop.look4sat.domain.predict.GeoPos
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
|
||||
interface LocationProvider {
|
||||
|
||||
val updatedLocation: SharedFlow<GeoPos?>
|
||||
}
|
||||
@@ -19,7 +19,6 @@ package com.rtbishop.look4sat.domain.model
|
||||
|
||||
sealed class DataState<out T> {
|
||||
data class Success<out T>(val data: T) : DataState<T>()
|
||||
data class Error(val error: Throwable) : DataState<Nothing>()
|
||||
object Empty : DataState<Nothing>()
|
||||
data class Error(val message: String?) : DataState<Nothing>()
|
||||
object Loading : DataState<Nothing>()
|
||||
}
|
||||
@@ -84,8 +84,6 @@ class DataParserTest {
|
||||
fun `Given valid data streams parsed results match`() = runTest(testDispatcher) {
|
||||
val csvResult = dataParser.parseCSVStream(validCSVStream)
|
||||
val tleResult = dataParser.parseTLEStream(validTLEStream)
|
||||
println(csvResult)
|
||||
println(tleResult)
|
||||
assert(csvResult == tleResult)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user