Currently, I'm trying to implement the paging library provided by android jetpack. But I having some troubles when getting the data from DAO. Actually, when I get the data, the PagedList
have the size of all the rows in the table!
Here my DAO:
@Dao
interface TableDao {
@Query("SELECT * FROM table")// I tried also with ORDER BY field DESC, as I saw in some examples.
fun getData(): DataSource.Factory<Int, MyEntity>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(songs: List<SongEntity>)
}
I trying to satisfy this test:
@Test
fun pageSize() {
val data = EntityFactory.makeList(50)
database.getTableDao().apply {
insertAll(data)
val pageSize = 5
RxPagedListBuilder(getData(), pageSize)
.buildObservable()
.map { it.size }
.test()
.assertValue(pageSize)
}
}
I don't know if I'm missing some context, but what I wanted to achieve was a progressive loading of the data. Any help/explanation will be very appreciated.