0

I am trying to create a chat app. What I want:

  • To implement an infinite list of previous messages
  • To append new messages to the beginning of list whenever a new message is received/sent.

I have implemented infinite list of previous messages using paging library 3 and listen to new messages using Firestore Snapshot listener.

My problem now is I can't find a way to append the new list of messages obtained by the snapshot listener with the paging adapter showing my previous list

I tried using separate recycler views for displaying previous message and live messages, but it's not working correctly.

Hyzam
  • 143
  • 8
  • What exactly have you tried in code and doesn't work the way you expect? – Alex Mamo Jun 02 '21 at 06:12
  • I implemented 2 recycler views vertically in the same layout. One to display the paginated list of previous messages and the other to display the new messages whenever the snapshot listener has been triggered. But this approach requires a scrollview wrap which is not giving me a smooth scroll experience. What I want is to integrate these 2 list into a single list – Hyzam Jun 02 '21 at 06:30
  • Posting the code you have could be a good starting point for other people to help you. – user1239299 Jun 02 '21 at 11:16

1 Answers1

0

What I wanted was to have 2 lists in the same page without using 2 recycler views. I did some research and found that the easiest way to achieve that is using a ConCat Adapter. It combines 2 different adapters for the different incoming datas and combine them into a single adapter.

For more details check https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter

Hyzam
  • 143
  • 8