paging: reuse DEFAULT_PAGE_SIZE
This commit is contained in:
@@ -28,7 +28,7 @@ class GenericPagingSource<T : Any>(
|
||||
) : PagingSource<Int, T>() {
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_PAGE_SIZE = 20
|
||||
const val DEFAULT_PAGE_SIZE = 20
|
||||
|
||||
/**
|
||||
* Method to create pager objects using [PagingSource]
|
||||
|
||||
@@ -27,6 +27,7 @@ import androidx.paging.cachedIn
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.gplayapi.helpers.web.WebAppDetailsHelper
|
||||
import com.aurora.store.data.PageResult
|
||||
import com.aurora.store.data.paging.GenericPagingSource
|
||||
import com.aurora.store.data.paging.GenericPagingSource.Companion.manualPager
|
||||
import com.aurora.store.data.providers.BlacklistProvider
|
||||
import com.aurora.store.util.PackageUtil
|
||||
@@ -65,7 +66,7 @@ class InstalledViewModel @Inject constructor(
|
||||
) {
|
||||
PackageUtil.getAllValidPackages(context)
|
||||
.filterNot { it.packageName in blacklist }
|
||||
.chunked(PAGE_SIZE)
|
||||
.chunked(GenericPagingSource.DEFAULT_PAGE_SIZE)
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -73,7 +74,7 @@ class InstalledViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun fetchApps() {
|
||||
manualPager(pageSize = PAGE_SIZE) { page ->
|
||||
manualPager(pageSize = GenericPagingSource.DEFAULT_PAGE_SIZE) { page ->
|
||||
// page is 1-indexed, but list is 0-indexed
|
||||
val chunks = pagedPackages.await()
|
||||
val chunk = chunks.getOrNull(page - 1)
|
||||
@@ -85,8 +86,4 @@ class InstalledViewModel @Inject constructor(
|
||||
.onEach { _apps.value = it }
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PAGE_SIZE = 20
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user