mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Added passes filtering by modes to PassesScreen
This commit is contained in:
1 parent
a088a7a0a2
commit
269d48d250
6 files changed
+19
-11
No files matched your search
@@ -46,6 +46,9 @@ interface StorageDao {
|
||||
@Query("DELETE FROM entries")
|
||||
suspend fun deleteEntries()
|
||||
|
||||
@Query("SELECT catnum FROM radios WHERE mode IN (:modes)")
|
||||
suspend fun getIdsWithModes(modes: List<String>): List<Int>
|
||||
|
||||
@Query("SELECT COUNT(*) FROM radios")
|
||||
suspend fun getRadiosTotal(): Int
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ class SatelliteRepo(
|
||||
override suspend fun initRepository() = withContext(dispatcher) {
|
||||
settingsRepo.selectedIds.collect { selectedIds ->
|
||||
_satellites.update { localStorage.getEntriesWithIds(selectedIds) }
|
||||
val (hoursAhead, minElevation) = settingsRepo.passesSettings.value
|
||||
calculatePasses(System.currentTimeMillis(), hoursAhead, minElevation)
|
||||
val (hoursAhead, minElevation, modes) = settingsRepo.passesSettings.value
|
||||
calculatePasses(System.currentTimeMillis(), hoursAhead, minElevation, modes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,15 +99,17 @@ class SatelliteRepo(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun calculatePasses(time: Long, hoursAhead: Int, minElevation: Double) {
|
||||
override suspend fun calculatePasses(time: Long, hoursAhead: Int, minElevation: Double, modes: List<String>) {
|
||||
if (_satellites.value.isNotEmpty()) {
|
||||
withContext(dispatcher) {
|
||||
val allPasses = mutableListOf<SatPass>()
|
||||
val stationPos = settingsRepo.stationPosition.value
|
||||
val newPasses = mutableListOf<SatPass>()
|
||||
val idsWithModes = localStorage.getIdsWithModes(modes)
|
||||
_satellites.value.forEach { satellite ->
|
||||
allPasses.addAll(satellite.getPasses(stationPos, time, hoursAhead))
|
||||
if (idsWithModes.isEmpty() || satellite.data.catnum in idsWithModes) {
|
||||
newPasses.addAll(satellite.getPasses(settingsRepo.stationPosition.value, time, hoursAhead))
|
||||
}
|
||||
}
|
||||
_passes.update { allPasses.filter(time, hoursAhead, minElevation) }
|
||||
_passes.update { newPasses.filter(time, hoursAhead, minElevation) }
|
||||
}
|
||||
} else {
|
||||
_passes.update { emptyList() }
|
||||
|
||||
@@ -53,6 +53,8 @@ class LocalSource(private val storageDao: StorageDao) : ILocalSource {
|
||||
|
||||
override suspend fun deleteEntries() = storageDao.deleteEntries()
|
||||
|
||||
override suspend fun getIdsWithModes(modes: List<String>) = storageDao.getIdsWithModes(modes)
|
||||
|
||||
private fun DomainEntry.toFramework() = FrameworkEntry(this.data, this.comment)
|
||||
|
||||
private fun FrameworkItem.toDomain() = DomainItem(this.catnum, this.name, false)
|
||||
|
||||
Reference in new issue
Block a user