I am building a chat app where every data enter in room database first and it's on data insert the recyclerview get update with new data. It works as expected but now i need to update my paging library to version 3. For this i need to update these changes as per this link and this
I have made all the changes but i am stuck at viewmodel
class. I am not getting what changes i need to make in this class to make it work with the paging library version 3
This is my ViewModel
public class Chat_ViewModel extends ViewModel {
public final LiveData<PagedList<ChatEntity_TableColums>> chatList;
public Chat_ViewModel() {
chatList = new LivePagedListBuilder<>(
RoomDatabase.getInstance(MyApplication.getmContext(),1).chatDAO().getPaginationChat(String.valueOf(UserID())),20).build();
}
}
In above class i know the PagedList
and LivePagedListBuilder
is deprecated but here i am not sure about the what to replace in updated library to make it work perfectly.
My room Database Query
@Query("SELECT * FROM tapChatter WHERE userName = :UserName ORDER BY ID DESC")
PagingSource<Integer, ChatEntity_TableColums> getPaginationChat(String UserName);
Issue facing:
1: How can i Update ViewModel
for optimal performance for chat app? Is my current ViewModel
is perfect for the chat app?
2: Is it possible to update the RecyclerView
UI on Room Database data update ?