Remove SelfossApi from SourcesActivity

All network calls to access sources go through the repository
This commit is contained in:
davide
2022-07-23 01:44:47 +02:00
parent 8898e85f02
commit 12e174dacd
4 changed files with 33 additions and 29 deletions

View File

@ -16,7 +16,7 @@ interface Repository {
fun stats(): SelfossModel.Stats
fun getTags(): List<SelfossModel.Tag>
suspend fun getSpouts(): Map<String, SelfossModel.Spout>?
fun getSources(): List<SelfossModel.Source>
suspend fun getSources(): ArrayList<SelfossModel.Source>?
suspend fun markAsRead(id: String): Boolean
suspend fun unmarkAsRead(id: String): Boolean
suspend fun starr(id: String): Boolean
@ -27,7 +27,7 @@ interface Repository {
spout: String,
tags: String,
filter: String): Boolean
fun deleteSource(id: Int): Boolean
suspend fun deleteSource(id: Int): Boolean
fun updateRemote(): Boolean
suspend fun login(): Boolean
fun refreshLoginInformation()

View File

@ -42,8 +42,9 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
return api.spouts()
}
override fun getSources(): List<SelfossModel.Source> {
TODO("Not yet implemented")
override suspend fun getSources(): ArrayList<SelfossModel.Source>? {
// TODO: Check success
return api.sources()
}
override suspend fun markAsRead(id: String): Boolean {
@ -98,8 +99,15 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
return result
}
override fun deleteSource(id: Int): Boolean {
TODO("Not yet implemented")
override suspend fun deleteSource(id: Int): Boolean {
// TODO: Check connectivity, store in DB
var success = false
val response = api.deleteSource(id)
if (response != null) {
success = response.isSuccess
}
return success
}
override fun updateRemote(): Boolean {