Now storing fetched satellite types in shared prefs

This commit is contained in:
Arty Bishop committed 2022-05-18 19:00:48 +01:00
1 parent 8c9d2031c2
commit 53697ef0c4
5 files changed
+70 -4

No files matched your search

@@ -80,6 +80,16 @@ class SettingsManager @Inject constructor(private val prefs: SharedPreferences)
return catnums?.sorted() ?: emptyList()
}
override fun saveSatType(type: String, catnums: List<Int>) {
val stringList = catnums.map { catnum -> catnum.toString() }
prefs.edit { putStringSet("type$type", stringList.toSet()) }
}
override fun loadSatType(type: String): List<Int> {
val catnums = prefs.getStringSet("type$type", emptySet())?.map { catnum -> catnum.toInt() }
return catnums ?: emptyList()
}
override fun getHoursAhead(): Int {
return prefs.getInt(keyHoursAhead, 24)
}
@@ -48,7 +48,10 @@ object BaseModule {
@Provides
@Singleton
fun provideDataRepository(@ApplicationContext context: Context): IDataRepository {
fun provideDataRepository(
@ApplicationContext context: Context,
settings: ISettingsManager
): IDataRepository {
val db = Room.databaseBuilder(context, LocalDatabase::class.java, "Look4SatDb")
.addMigrations(MIGRATION_1_2).fallbackToDestructiveMigration().build()
val parser = DataParser(Dispatchers.Default)
@@ -56,8 +59,8 @@ object BaseModule {
val entries = LocalEntrySource(db.entriesDao())
val radios = LocalRadioSource(db.radiosDao())
val remoteSource = RemoteDataSource(Dispatchers.IO)
val repositoryScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
return DataRepository(parser, fileSource, entries, radios, remoteSource, repositoryScope)
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
return DataRepository(parser, fileSource, entries, radios, remoteSource, scope, settings)
}
@Provides