Kotlin synthetic caching not working in library artifact
See original GitHub issueI’ve created a self-contained project using groupie where I checked that seems the caching of the kotlin synthetic views seems not being used whatsover . if you look at the code
class GroupieDummyModel(val content: String = "Hello World") : Item() {
override fun bind(viewHolder: ViewHolder, position: Int) {
viewHolder.textView.text = content
}
override fun getLayout(): Int = R.layout.item_content
}
It will produce the following bytecode
public void bind(@NotNull ViewHolder viewHolder, int position) {
Intrinsics.checkParameterIsNotNull(viewHolder, "viewHolder");
TextView var10000 = (TextView)((LayoutContainer)viewHolder).getContainerView().findViewById(id.textView);
Intrinsics.checkExpressionValueIsNotNull(var10000, "viewHolder.textView");
var10000.setText((CharSequence)this.content);
}
which it stills use findViewById
and not findViewByCache
since Item
doesn’t implements LayoutContainer
doesn’t really matter that ViewHolder implements its Ithink, the Kotlin Compiler doesn´t know about that because it really expects the Item
implementing it so it doesn´t generate the caching bytecode, seems like doing this is the same as not using LayoutContainer whatsover since it stills make the lookup in the hole itemView tree view.
Or maybe I’m really missing something here
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
import kotlinx.android.synthetic.main.activity_main is not working
So the problem as I have found is in gradle plugins, then you need to restart, rebuild your project. Share.
Read more >Migrating to Apollo Kotlin 3.0 - Apollo GraphQL Docs
To quickly reach a working state, follow the steps below. Once you have a working app, we strongly recommend to migrate to idiomatic...
Read more >Navigation | Android Developers
The navigation-testing artifact now has a dependency on the Kotlin standard library. The API has been changed to be more consistent with Kotlin ......
Read more >What's new in Kotlin 1.6.0
Kotlin 1.6.0 introduces new language features, optimizations and improvements to existing features, and a lot of improvements to the Kotlin ...
Read more >Kotlin 1.2.20 is out - The JetBrains Blog
Build caching for Kotlin annotation processors is disabled by ... As usual, if you run into any problems with the new release, you're ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I opened an issue with the Kotlin team: https://youtrack.jetbrains.com/issue/KT-28617
OK, bizarre. It’s happening only with the published library…
If you go in https://github.com/lisawray/groupie/blob/master/example/build.gradle and change the dependency to the library module rather than the published library
Then you see any Item (say CardItem) using
findCachedViewById
. If you do the reverse, it usesfindViewById
.