I am using the Android Arch PagedListAdapter
class. The issue I have run into is that since my app is a chat style app, I need to scroll to position 0 when an item is inserted. But the PagedListAdapter finds the diffs and calls necessary methods on the background thread so it seems that there is no dependable way to call layoutManager.scrollToPosition(0)
If anyone has any ideas on how I could scroll at the right time, it would be greatly appreciated. Thanks!
Here is my Room Dao:
@Dao
abstract class MessagesDao {
@Query("SELECT ...")
abstract fun getConversation(threadId: String): DataSource.Factory<Int, Conversation>
}
and then the LivePagedListBuilder:
LivePagedListBuilder(database.messagesDao.getConversation(threadId), PagedList.Config.Builder()
.setInitialLoadSizeHint(20)
.setPageSize(12)
.setEnablePlaceholders(true)
.build()).build()
HOW
did you do that? – Boiling