mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-03 11:17:25 +00:00
Now storing fetched satellite types in shared prefs
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user