Prepare the repository functions for DB implementation
This commit is contained in:
parent
3aa6934f86
commit
ef0f326073
@ -62,8 +62,9 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
|
||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||
// TODO: Use the updatedSince parameter
|
||||
var fetchedItems: List<SelfossModel.Item>? = null
|
||||
if (isNetworkAvailable()) {
|
||||
val fetchedItems = api.getItems(
|
||||
fetchedItems = api.getItems(
|
||||
displayedItems.type,
|
||||
settings.getString("prefer_api_items_number", "200").toInt(),
|
||||
offset = 0,
|
||||
@ -72,20 +73,21 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
searchFilter,
|
||||
null
|
||||
)
|
||||
} else {
|
||||
// TODO: Get items from the database
|
||||
}
|
||||
|
||||
if (fetchedItems != null) {
|
||||
items = ArrayList(fetchedItems)
|
||||
}
|
||||
} else {
|
||||
// TODO: Get items from the database
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
suspend fun getOlderItems(): ArrayList<SelfossModel.Item> {
|
||||
var fetchedItems: List<SelfossModel.Item>? = null
|
||||
if (isNetworkAvailable()) {
|
||||
val offset = items.size
|
||||
val fetchedItems = api.getItems(
|
||||
fetchedItems = api.getItems(
|
||||
displayedItems.type,
|
||||
settings.getString("prefer_api_items_number", "200").toInt(),
|
||||
offset,
|
||||
@ -94,13 +96,13 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
searchFilter,
|
||||
null
|
||||
)
|
||||
} else {
|
||||
// TODO: Get items from the database
|
||||
}
|
||||
|
||||
if (fetchedItems != null) {
|
||||
appendItems(fetchedItems)
|
||||
}
|
||||
} else {
|
||||
// TODO: Get items from the database
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user