【发布时间】:2022-03-09 06:31:47
【问题描述】:
我有一个模块化应用程序,它有 3 个模块 feature 和 local 和 remote。
我在使用 remoteMediator 的功能模块中使用了分页。
我的 remoteMediator 使用 PagingSource
remoteMediator 需要 PagingSource
如何将 PagingSource
我的道:
@Dao
interface UsersDao {
@Query("SELECT * FROM ${Constants.USERS_TABLE}")
fun getAllUsers(): PagingSource<Int, UserEntity>
}
我的仓库:
override fun getUsers(): Flow<PagingData<UserModel>> {
val pagingSourceFactory = {
githubDatabase.usersDao().getAllUsers()
}
return Pager(
config = PagingConfig(pageSize = ITEMS_PER_PAGE),
remoteMediator = AllUsersPagingSource(
githubApi = githubApi,
githubDatabase = githubDatabase,
allUsersMapper = allUsersMapper,
allUsersRemoteLocalMapper = allUsersRemoteLocalMapper
), pagingSourceFactory = pagingSourceFactory
).flow
}
【问题讨论】:
标签: android pagination