How to load more conversations after the limit is crossed of 50

var conversationRequest: ConversationsRequest? = null
val LIMIT:Int=50

conversationRequest = ConversationsRequest.ConversationsRequestBuilder().setLimit(LIMIT).build()
conversationRequest?.fetchNext(object : CometChat.CallbackListener<List>() {
override fun onSuccess(p0: List?) {
//Handle List of Conversations
}
override fun onError(p0: CometChatException?) {
//Handle Failure
}
})

Hi,

You need to use fetchNext() method again with same conversationRequest object to fetch next 50 conversations.

Hope it helps.

i have already used the fetchNext() method i was asking how would the recycler view understand there are more number of conversations and load the next set of conversations let say we have set a limit of 10

Hi,

You need to add ScrollListener to a recyclerView to handle it. Please check below code snippet for reference.

recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
            override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
                if (!recyclerView.canScrollVertically(1)) {
                    fetchConversationList()
                }
            }
        })

Also, please check our Kotlin UIKit for reference.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.