Improve: Reduce memory allocation on viewmodel startup

This commit is contained in:
LooKeR 2022-01-16 18:36:24 +05:30
parent ab5c26bec4
commit 77afcf8877
2 changed files with 6 additions and 9 deletions

View File

@ -146,7 +146,6 @@ dependencies {
// Material3
implementation 'com.google.android.material:material:1.6.0-alpha01'
// FastAdapter
implementation("com.mikepenz:fastadapter:5.6.0")
implementation("com.mikepenz:fastadapter-extensions-diff:5.6.0")

View File

@ -84,18 +84,16 @@ class MainNavFragmentViewModelX(val db: DatabaseX, source: Source) : ViewModel()
}
}
var productsList: LiveData<PagedList<Product>>
init {
val pagedListConfig = PagedList.Config.Builder()
private val pagedListConfig by lazy {
PagedList.Config.Builder()
.setPageSize(30)
.setPrefetchDistance(30)
.setEnablePlaceholders(false)
.build()
}
val request = request(source)
productsList = LivePagedListBuilder(
val productsList: LiveData<PagedList<Product>> by lazy {
LivePagedListBuilder(
db.productDao.queryList(
installed = request.installed,
updates = request.updates,