199 messages are currently stored in the My Rooms database.
so I want paging this data with Paging Library.
I followed Android Developer explaination.
but My PagingData emit all of my Message Data at once..
what is the problem..
Dao
@Query("SELECT * FROM msgentity WHERE room_id =:roomId ORDER by msg")
fun getPassedMsg(roomId: String) : PagingSource<Int, MsgEntity>
In ViewModel
val lst = Pager(
PagingConfig(
pageSize = 30,
enablePlaceholders = true,
)
){
dao.getPassedMsg(argus.roomId)
}.flow.cachedIn(viewModelScope)
my Compose functions
val msgL = viewModel.lst.collectAsLazyPagingItems()
ChatInsideScreen(/*viewModel = viewModel*/msgL)
and
@Composable
fun ChatInsideScreen(
msgL : LazyPagingItems<MsgEntity>
) {
TestList(lst = msgL)
}
@Composable
fun TestList(lst : LazyPagingItems<MsgEntity>){
LazyColumn(){
itemsIndexed(lst) { idx, msg ->
Text(text = "$idx : ${msg?.msg ?: "nono"}",)
if (msg == null){
Text(text = "placeHolder")
}
}
}
}
when My Screen init all of 199 messages are delivered by Pager...
how can I fix it..