I'm using Android paging library androidx.paging:paging-runtime:2.0.0 to build a list. The problem is that when I want to build PagedList (LivePagedList works well) i have an error:
java.lang.IllegalArgumentException: MainThreadExecutor required
at androidx.paging.PagedList$Builder.build(PagedList.java:355)
But I don't see that setMainThreadExecutor method available, there is only setFetchExecutor:
val result = list.filter { it.desc?.contains(query, ignoreCase = true) == true }
val dataSource = MyDataSource(result)
val mainHandler = Handler(Looper.getMainLooper())
val pagedList: PagedList<MyDetails> = PagedList.Builder<Int, MyDetails>(dataSource, 500).setFetchExecutor { mainHandler.post(it) }
.build()
Who knows what's the problem here?