Added framework DataSources, DataMapper and Models
This commit is contained in:
1 parent
865ecfb5bf
commit
53fcf4790a
46 files changed
+571
-63
No files matched your search
@@ -1,9 +1,9 @@
|
||||
package com.rtbishop.look4sat.data
|
||||
|
||||
import com.rtbishop.look4sat.domain.SatelliteRepo
|
||||
import com.rtbishop.look4sat.domain.model.SatEntry
|
||||
import com.rtbishop.look4sat.domain.model.SatItem
|
||||
import com.rtbishop.look4sat.domain.SatelliteRepo
|
||||
import com.rtbishop.look4sat.domain.model.Transmitter
|
||||
import com.rtbishop.look4sat.domain.model.SatTrans
|
||||
import com.rtbishop.look4sat.predict4kotlin.Satellite
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
@@ -23,7 +23,7 @@ class DefaultSatelliteRepo(
|
||||
return localSource.getSatItems()
|
||||
}
|
||||
|
||||
override fun getTransmittersForSat(catNum: Int): Flow<List<Transmitter>> {
|
||||
override fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>> {
|
||||
return localSource.getTransmittersForSat(catNum)
|
||||
}
|
||||
|
||||
@@ -44,12 +44,13 @@ class DefaultSatelliteRepo(
|
||||
val entries = mutableListOf<SatEntry>()
|
||||
val streams = mutableListOf<InputStream>()
|
||||
sources.forEach { source ->
|
||||
val stream = remoteSource.fetchFileStream(source)
|
||||
if (source.contains(".zip", true)) {
|
||||
val zipStream = ZipInputStream(stream).apply { nextEntry }
|
||||
streams.add(zipStream)
|
||||
} else {
|
||||
streams.add(stream)
|
||||
remoteSource.fetchFileStream(source)?.let { stream ->
|
||||
if (source.contains(".zip", true)) {
|
||||
val zipStream = ZipInputStream(stream).apply { nextEntry }
|
||||
streams.add(zipStream)
|
||||
} else {
|
||||
streams.add(stream)
|
||||
}
|
||||
}
|
||||
}
|
||||
streams.forEach { stream ->
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.rtbishop.look4sat.data
|
||||
|
||||
import com.rtbishop.look4sat.domain.model.SatEntry
|
||||
import com.rtbishop.look4sat.domain.model.SatItem
|
||||
import com.rtbishop.look4sat.domain.model.Transmitter
|
||||
import com.rtbishop.look4sat.domain.model.SatTrans
|
||||
import com.rtbishop.look4sat.predict4kotlin.Satellite
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -16,7 +16,7 @@ interface LocalDataSource {
|
||||
|
||||
suspend fun updateEntriesSelection(catNums: List<Int>, isSelected: Boolean)
|
||||
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<Transmitter>>
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>>
|
||||
|
||||
suspend fun updateTransmitters(transmitters: List<Transmitter>)
|
||||
suspend fun updateTransmitters(satelliteTrans: List<SatTrans>)
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.rtbishop.look4sat.data
|
||||
|
||||
import com.rtbishop.look4sat.domain.model.Transmitter
|
||||
import com.rtbishop.look4sat.domain.model.SatTrans
|
||||
import java.io.InputStream
|
||||
|
||||
interface RemoteDataSource {
|
||||
|
||||
fun fetchFileStream(url: String): InputStream
|
||||
suspend fun fetchFileStream(url: String): InputStream?
|
||||
|
||||
fun fetchTransmitters(): List<Transmitter>
|
||||
suspend fun fetchTransmitters(): List<SatTrans>
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.rtbishop.look4sat.domain
|
||||
|
||||
import com.rtbishop.look4sat.domain.model.SatItem
|
||||
import com.rtbishop.look4sat.domain.model.Transmitter
|
||||
import com.rtbishop.look4sat.domain.model.SatTrans
|
||||
import com.rtbishop.look4sat.predict4kotlin.Satellite
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.io.InputStream
|
||||
@@ -10,7 +10,7 @@ interface SatelliteRepo {
|
||||
|
||||
fun getSatItems(): Flow<List<SatItem>>
|
||||
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<Transmitter>>
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>>
|
||||
|
||||
suspend fun getSelectedSatellites(): List<Satellite>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.rtbishop.look4sat.predict4kotlin.TLE
|
||||
|
||||
data class SatEntry(
|
||||
val tle: TLE,
|
||||
var isSelected: Boolean = false,
|
||||
val catNum: Int = tle.catnum,
|
||||
val name: String = tle.name
|
||||
val name: String = tle.name,
|
||||
var isSelected: Boolean = false
|
||||
)
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
* Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rtbishop.look4sat.domain.model
|
||||
|
||||
import com.rtbishop.look4sat.predict4kotlin.PassPredictor
|
||||
import java.util.*
|
||||
|
||||
data class SatPass(
|
||||
val catNum: Int,
|
||||
val name: String,
|
||||
val isDeepSpace: Boolean,
|
||||
private val aosTime: Long,
|
||||
val aosAzimuth: Double,
|
||||
private val losTime: Long,
|
||||
val losAzimuth: Double,
|
||||
private val tcaTime: Long,
|
||||
val tcaAzimuth: Double,
|
||||
val altitude: Double,
|
||||
val maxElevation: Double,
|
||||
val predictor: PassPredictor,
|
||||
var progress: Int = 0
|
||||
) {
|
||||
val aosDate: Date
|
||||
get() = Date(aosTime)
|
||||
|
||||
val losDate: Date
|
||||
get() = Date(losTime)
|
||||
|
||||
val tcaDate: Date
|
||||
get() = Date(tcaTime)
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.rtbishop.look4sat.domain.model
|
||||
|
||||
data class Transmitter(
|
||||
data class SatTrans(
|
||||
val uuid: String,
|
||||
val info: String,
|
||||
val isAlive: Boolean,
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.rtbishop.look4sat.interactors
|
||||
|
||||
import com.rtbishop.look4sat.domain.SatelliteRepo
|
||||
import com.rtbishop.look4sat.domain.model.Transmitter
|
||||
import com.rtbishop.look4sat.domain.model.SatTrans
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class GetTransmittersForSat(private val satelliteRepo: SatelliteRepo) {
|
||||
|
||||
operator fun invoke(catNum: Int): Flow<List<Transmitter>> {
|
||||
operator fun invoke(catNum: Int): Flow<List<SatTrans>> {
|
||||
return satelliteRepo.getTransmittersForSat(catNum)
|
||||
}
|
||||
}
|
||||
@@ -349,9 +349,12 @@ abstract class Satellite(val tle: TLE) {
|
||||
|
||||
companion object {
|
||||
|
||||
fun createSat(tle: TLE): Satellite {
|
||||
return if (tle.isDeepspace) DeepSpaceSat(tle)
|
||||
else NearEarthSat(tle)
|
||||
fun createSat(tle: TLE?): Satellite? {
|
||||
return when {
|
||||
tle == null -> null
|
||||
tle.isDeepspace -> DeepSpaceSat(tle)
|
||||
else -> NearEarthSat(tle)
|
||||
}
|
||||
}
|
||||
|
||||
fun importTLE(tleStream: InputStream): List<TLE> {
|
||||
|
||||
Reference in new issue
Block a user