Do Kotlin Android Extensions cache the synthetic properties or each time it calls findViewById()?

In the current version (1.1.3), views are cached for Activities and Fragments layouts. For other kinds of containers like RecyclerView ViewHolders, there is no cache.

Also, the cache is a HashMap with Integer boxing for keys. A SparseArray would have been better.

Edit: Since version 1.1.4, views can be cached for other classes too, including ViewHolder, if you make them implement the LayoutContainer interface. You can also use the @ContainerOptions annotation to specify another cache implementation, including SparseArray. Both of these features are still experimental and need to be enabled manually in your build.gradle file:

androidExtensions {
    experimental = true
}

Read more about it.


Since 1.1.4 views can be cached in any class. Caching in custom views enabled by default. For ViewHolders you need to implement LayoutContainer interface like this:

class MyViewHolder(override val containerView: View): LayoutContainer

See this doc for details https://github.com/Kotlin/KEEP/blob/master/proposals/android-extensions-entity-caching.md

Update: To be able to use LayoutContainer you should add this to the gradle script:

androidExtensions {
    experimental = true
}