1

I am using database only pagination to paginate chat heads from my db. There are around 450 enteries in my db

@Query("select * from ChatHeadMaster where archive= :archive order by chatBot desc,lastMessageTimestamp desc")
    fun fetchPagedChatHeadList(archive: Int): DataSource.Factory<Int,ChatHeadWithMessages>

There are two problems that i am facing with pagination

1) Even thought data source does fetch data page by page but it fetches all the data at once. So if i set my page size to 30 it will fetch data in chunks of 30 until the entire data is fetched due to which my main thread hangs until the complete data is fetched

2) Whenever there is a change in my table, the data source behaves abruptly and it would skip the first page and return me the remaining data. So if have 75 items in my table and my page size is 10 initially datasource will run as follows 30(because of initial load size hint),10,10,10,10,5 and on change in table data source will return 55 items. which i dont know why is this happening

UPDATE

Found the issue. My RecyclerView was inside the NestedScrollView due to which positional data source was unable to correctly calculate offset. For now i have removed nested scroll view and it works like a charm

1 Answers1

1

The issue happened because of NestedScrollView due to which paged list adapter was unable to correctly calculate offset