kopia lustrzana https://github.com/rt-bishop/Look4Sat
Stopped clearing satellite entries on each TLE update #39
rodzic
9199765c61
commit
bf1ce64553
|
@ -26,7 +26,7 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import com.rtbishop.look4sat.data.*
|
||||
import com.rtbishop.look4sat.repo.EntriesRepo
|
||||
import com.rtbishop.look4sat.repo.DefaultSourcesRepo
|
||||
import com.rtbishop.look4sat.repo.SourcesRepo
|
||||
import com.rtbishop.look4sat.repo.TransmittersRepo
|
||||
import com.rtbishop.look4sat.utility.PassPredictor
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
|
@ -40,7 +40,7 @@ import javax.inject.Inject
|
|||
@HiltViewModel
|
||||
class SharedViewModel @Inject constructor(
|
||||
private val prefsManager: PrefsManager,
|
||||
private val sourcesRepo: DefaultSourcesRepo,
|
||||
private val sourcesRepo: SourcesRepo,
|
||||
private val entriesRepo: EntriesRepo,
|
||||
private val transmittersRepo: TransmittersRepo
|
||||
) : ViewModel() {
|
||||
|
|
|
@ -49,7 +49,7 @@ class EntriesRepo @Inject constructor(
|
|||
resolver.openInputStream(fileUri)?.use { stream ->
|
||||
val importedEntries = TLE.importSat(stream).map { SatEntry(it) }
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.updateEntries(importedEntries)
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class EntriesRepo @Inject constructor(
|
|||
importedEntries.addAll(entries)
|
||||
}
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.updateEntries(importedEntries)
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.rtbishop.look4sat.data.TleSource
|
|||
import com.rtbishop.look4sat.repo.local.SourcesDao
|
||||
import javax.inject.Inject
|
||||
|
||||
class DefaultSourcesRepo @Inject constructor(private val sourcesDao: SourcesDao) {
|
||||
class SourcesRepo @Inject constructor(private val sourcesDao: SourcesDao) {
|
||||
|
||||
fun getSources(): LiveData<List<TleSource>> {
|
||||
return sourcesDao.getSources()
|
|
@ -29,15 +29,6 @@ interface EntriesDao {
|
|||
@Query("SELECT * FROM entries ORDER BY name ASC")
|
||||
fun getEntries(): LiveData<List<SatEntry>>
|
||||
|
||||
@Transaction
|
||||
suspend fun updateEntries(entries: List<SatEntry>) {
|
||||
clearEntries()
|
||||
insertEntries(entries)
|
||||
}
|
||||
|
||||
@Query("DELETE FROM entries")
|
||||
suspend fun clearEntries()
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertEntries(entries: List<SatEntry>)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue