amar_1995
01/28/2020, 2:10 PM@Composable
private fun ShowArticle(
articleList: List<NewsArticle>
) {
val scrollerPosition: ScrollerPosition = +memo {ScrollerPosition(0f)}
if(scrollerPosition.isAtEndOfList) {
newArticleModel.loadMoreNationData(2)
}
VerticalScroller(scrollerPosition = scrollerPosition) {
Column(Expanded) {
articleList.forEach {
ArticleTicket(
backgroundColor = (+MaterialTheme.colors()).background,
article = it
)
}
}
}
}
val ScrollerPosition.isAtEndOfList: Boolean get() = value >= maxPosition
amar_1995
01/28/2020, 2:11 PMManuel Wrage
01/28/2020, 2:12 PMManuel Wrage
01/28/2020, 2:15 PMamar_1995
01/28/2020, 2:23 PMval observe = Observer<Boolean> {
if (it) {
newArticleModel.loadMoreNationData(2)
}
}
observe.onChanged(scrollerPosition.isAtEndOfList)
Like this ?Manuel Wrage
01/28/2020, 2:23 PMManuel Wrage
01/28/2020, 2:27 PMandroidx.compose.Observe {
if(scrollerPosition.isAtEndOfList) {
newArticleModel.loadMoreNationData(2)
}
}
Like thisamar_1995
01/28/2020, 2:27 PMamar_1995
01/28/2020, 2:27 PMManuel Wrage
01/28/2020, 2:27 PMChuck Jazdzewski [G]
01/28/2020, 11:11 PMObserve
is a confusing name. Any recommendations for renaming it?Val Salamakha
01/29/2020, 5:01 AMManuel Wrage
01/29/2020, 10:16 AMKlaas Kabini
02/12/2020, 4:18 AM