Implemented Clean architecture, removed redundant dependencies

This commit is contained in:
Arty Bishop committed 2021-04-23 12:59:18 +01:00
1 parent 53fcf4790a
commit e9a6471b6d
66 files changed
+318 -934

No files matched your search

@@ -4,7 +4,7 @@ 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.model.SatTrans
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
@@ -32,15 +32,13 @@ class DefaultSatelliteRepo(
}
override suspend fun importDataFromFile(stream: InputStream) = withContext(ioDispatcher) {
val entries = mutableListOf<SatEntry>()
val tleList = Satellite.importTLE(stream)
tleList.forEach { tle -> entries.add(SatEntry(tle)) }
val entries = Satellite.importTLE(stream).map { tle -> SatEntry(tle) }
localSource.updateEntries(entries)
}
override suspend fun importDataFromWeb(sources: List<String>) {
coroutineScope {
launch {
launch(ioDispatcher) {
val entries = mutableListOf<SatEntry>()
val streams = mutableListOf<InputStream>()
sources.forEach { source ->
@@ -59,7 +57,7 @@ class DefaultSatelliteRepo(
}
localSource.updateEntries(entries)
}
launch {
launch(ioDispatcher) {
val transmitters = remoteSource.fetchTransmitters().filter { it.isAlive }
localSource.updateTransmitters(transmitters)
}
@@ -3,7 +3,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.SatTrans
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
import kotlinx.coroutines.flow.Flow
interface LocalDataSource {
@@ -2,7 +2,7 @@ package com.rtbishop.look4sat.domain
import com.rtbishop.look4sat.domain.model.SatItem
import com.rtbishop.look4sat.domain.model.SatTrans
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
import kotlinx.coroutines.flow.Flow
import java.io.InputStream
@@ -19,4 +19,4 @@ interface SatelliteRepo {
suspend fun importDataFromWeb(sources: List<String>)
suspend fun updateEntriesSelection(catNums: List<Int>, isSelected: Boolean)
}
}
@@ -1,6 +1,6 @@
package com.rtbishop.look4sat.domain.model
import com.rtbishop.look4sat.predict4kotlin.TLE
import com.rtbishop.look4sat.domain.predict4kotlin.TLE
data class SatEntry(
val tle: TLE,
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import kotlin.math.*
@@ -15,6 +15,6 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
data class GroundPos(val lat: Double, val lon: Double, val alt: Double, val name: String = "base")
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import kotlin.math.*
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import java.util.*
@@ -15,6 +15,6 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
data class Position(val lat: Double, val lon: Double)
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import java.util.*
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import java.util.*
import kotlin.math.*
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
import java.io.InputStream
import java.util.*
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict4kotlin
data class TLE(
val name: String,
@@ -9,4 +9,4 @@ class GetSatItems(private val satelliteRepo: SatelliteRepo) {
operator fun invoke(): Flow<List<SatItem>> {
return satelliteRepo.getSatItems()
}
}
}
@@ -1,11 +1,11 @@
package com.rtbishop.look4sat.interactors
import com.rtbishop.look4sat.domain.SatelliteRepo
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
class GetSelectedSatellites(private val satelliteRepo: SatelliteRepo) {
suspend operator fun invoke(): List<Satellite> {
return satelliteRepo.getSelectedSatellites()
}
}
}
@@ -9,4 +9,4 @@ class GetTransmittersForSat(private val satelliteRepo: SatelliteRepo) {
operator fun invoke(catNum: Int): Flow<List<SatTrans>> {
return satelliteRepo.getTransmittersForSat(catNum)
}
}
}
@@ -8,4 +8,4 @@ class ImportDataFromFile(private val satelliteRepo: SatelliteRepo) {
suspend operator fun invoke(stream: InputStream) {
satelliteRepo.importDataFromFile(stream)
}
}
}
@@ -7,4 +7,4 @@ class ImportDataFromWeb(private val satelliteRepo: SatelliteRepo) {
suspend operator fun invoke(sources: List<String>) {
satelliteRepo.importDataFromWeb(sources)
}
}
}
@@ -7,4 +7,4 @@ class UpdateEntriesSelection(private val satelliteRepo: SatelliteRepo) {
suspend operator fun invoke(catNums: List<Int>, isSelected: Boolean) {
satelliteRepo.updateEntriesSelection(catNums, isSelected)
}
}
}