2 ms·
Kotlin Android Extensions is a tad more than that. It's also a View cache that grabs all view references in a single pass. I routinely have to explain to other
by mncolinlee 9y ago
Kotlin Android Extensions is a tad more than that. It's also a View cache that grabs all view references in a single pass. I routinely have to explain to other senior Android developers that findViewById() traverses the entire view hierarchy until it finds that ID each time you call it. This won't be noticeable with simple views, but becomes a bigger problem as complexity increases. Which also results in more wasteful calls to findViewById().
Android Data Binding does something very similar to Kotlin Android Extensions, which is why it also perplexes me to see experienced devs bind a model to a view and then call findViewById() to alter it. I'll see calls to binding.getRoot().findViewById(), which is crazy redundant.