Ігор Онек
Ігор Онек

Reputation: 270

Is it possible to implement realtime paging(aac library) with room?

Currently, I'm working on p2p messenger app. Our messages are storing inside room database. When we send or receive a new message we insert it in room db. And it works, method onItemRangeInserted from RecyclerView.AdapterDataObserver is triggered.

But, when the datasource riches the last page(fetch last data from db), method onItemRangeInserted is not called. Only after the second insert into db, this method is triggered.

We use default PositionalDataSource implemented by room and LivePagedListBuilder.

So, is it real to use it for real-time paging with room? If yes, then what could be the problem?

If need some code, please, let me know. Because there are a lot of code, and I'm not sure which part I should attach.

Upvotes: 5

Views: 150

Answers (2)

Anjan Debnath
Anjan Debnath

Reputation: 120

Though I am not working on a real-time chat application but I think this repo will help you and solve your problem.

Upvotes: 2

Ігор Онек
Ігор Онек

Reputation: 270

Set setEnablePlaceholders to true in PagedList.Config did the trick.

Upvotes: 0

Related Questions