mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-23 19:50:18 +00:00
Collections fragment: cache paging data (bitfireAT/davx5#206)
Closes bitfireAT/davx5#205
This commit is contained in:
parent
179602df46
commit
1dd93ae43a
|
@ -285,7 +285,7 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
|
|||
val collectionColors = db.collectionDao().colorsByServiceLive(serviceId)
|
||||
val collections: LiveData<PagingData<Collection>> =
|
||||
Transformations.switchMap(accountModel.showOnlyPersonal) { onlyPersonal ->
|
||||
Pager(
|
||||
val pager = Pager(
|
||||
PagingConfig(pageSize = 25),
|
||||
pagingSourceFactory = {
|
||||
Logger.log.info("Creating new pager onlyPersonal=$onlyPersonal")
|
||||
|
@ -296,7 +296,10 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
|
|||
// show all collections
|
||||
db.collectionDao().pageByServiceAndType(serviceId, collectionType)
|
||||
}
|
||||
).liveData
|
||||
)
|
||||
return@switchMap pager
|
||||
.liveData
|
||||
.cachedIn(viewModelScope)
|
||||
}
|
||||
|
||||
// observe RefreshCollectionsWorker status
|
||||
|
|
Loading…
Reference in a new issue