Question for those who are using LazyColumn (versi...
# compose
f
Question for those who are using LazyColumn (version 1.0.0-rc02). Do you feel that LazyColumn (with pager) feels a bit laggy? On older device feeling that it’s skipping frames 🤔
👀 1
v
Yes
a
AndroidX Pager or Accompanist Pager?
f
AndroiX pager
But I feel that as soon I’m removing
Image(…)
(backed or not by Coil) the scroll is way better
a
Are you using stable keys? They just added it in Rc02 for paged items
f
Well, I did a custom one.
Copy code
fun <T : Any> LazyListScope.lazyItems(
    lazyPagingItems: LazyPagingItems<T>,
    key: ((index: Int) -> Any)? = null,
    itemContent: @Composable LazyItemScope.(index: Int, value: T?) -> Unit
) {

    items(lazyPagingItems.itemCount, key) { index ->
        itemContent(index, lazyPagingItems.getAsState(index).value)
    }
}
I didn’t know that Rc02 introduced it. I’m gonna give a try with the one provided by Compose then
a
Yeah, I think it’s quite different. `getAsState`is deprecated as well
Copy code
public fun <T : Any> LazyListScope.items(
    items: LazyPagingItems<T>,
    key: ((item: T) -> Any)? = null,
    itemContent: @Composable LazyItemScope.(value: T?) -> Unit
) {
    items(
        count = items.itemCount,
        key = if (key == null) null else { index ->
            val item = items.peek(index)
            if (item == null) {
                PagingPlaceholderKey(index)
            } else {
                key(item)
            }
        }
    ) { index ->
        itemContent(items[index])
    }
}
f
Well it’s little bit better but still not quiet smooth but it might my UI too complicated.
a
Note that debug builds are way slower as well.
f
Yeah I saw that R8 is doing a lot of work while building in release mode