Balakrishna Sangem
11/14/2019, 3:35 PMVerticalScroller
, Is it a lot laggy.Bruno_
11/14/2019, 5:03 PM@Composable
fun PagedVerticalScroller(
onNextPage: (page: Int) -> Unit,
child: @Composable() () -> Unit
) {
var currentPage = 0
val scrollerPosition: ScrollerPosition = +memo { ScrollerPosition() }
VerticalScroller(scrollerPosition, { pos: Px, maxPos: Px ->
scrollerPosition.value = pos
if (pos.value > maxPos.value - 500) {
onNextPage(currentPage)
currentPage++
}
}) {
child()
}
}
in onNextPage
add elements to a ModelList to reload the componentBruno_
11/14/2019, 5:05 PMprivate fun loadMoreAds(page: Int, pageSize: Int = 10) {
flowable
.skip((page * pageSize).toLong())
.take(((page + 1) * pageSize).toLong())
.toList()
.doOnSuccess { modelList.addAll(it) }
.subscribe()
}
Bruno_
11/14/2019, 5:52 PMBruno_
11/14/2019, 5:52 PM