[Kotlin] Generated Epoxy Models not working anymore
See original GitHub issueAfter updating from 2.14.0
to 2.15.1
or anything newer (tried up to 2.16.2
) using the generated Models directly instead of their Kotlin extension function will throw an Cannot create an instance of an abstract class
exception.
This is especially frustrating for carousels since the provided withModelsFrom(...)
extension function expects you to use the generatedWhateverViewModel_().id(...)...
instead of the extension function which returns Unit
.
Example EpoxyModel:
@EpoxyModelClass(layout = R2.layout.ui_recyclerview_epoxy_shift)
abstract class ShiftEpoxyModel : EpoxyModelWithHolder<ShiftEpoxyModel.ShiftViewHolder>() {
@EpoxyAttribute
var day: String = ""
@EpoxyAttribute
@StringRes
var dayRes: Int? = null
@EpoxyAttribute
var beginDate: Date = Date()
@EpoxyAttribute
var endDate: Date = Date()
override fun bind(holder: ShiftViewHolder) {
super.bind(holder)
...
}
class ShiftViewHolder : EpoxyHolder() {
lateinit var dayTextView: TextView
lateinit var dateTextView: TextView
lateinit var timeTextView: TextView
override fun bindView(itemView: View) {
dayTextView = itemView.findViewById(R.id.day)
dateTextView = itemView.findViewById(R.id.date)
timeTextView = itemView.findViewById(R.id.time)
}
}
}
In the controller
shift {
id("123")
beginDate(beginDate)
endDate(endDate)
}
works just fine,
add(ShiftEpoxyModel_()
.id("123")
.beginDate(beginDate)
.endDate(endDate))
throws an Cannot create an instance of an abstract class
exception.
Same thing when trying to create a carousel like this:
carousel {
id("shifts-carousel")
withModelsFrom(data.offer!!.shifts) {
ShiftEpoxyModel_()
.id(it.toString())
.beginDate(it.beginDate)
.endDate(it.endDate)
}
}
Am i missing something ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Why Epoxy does not generate model class? - Stack Overflow
I want to use Epoxy for my recyclerView with kotlin, but Epoxy Model does not generate PostModel_() class, what wrong with it?
Read more >[Solved]-Why Epoxy does not generate model class?-kotlin
[Solved]-Why Epoxy does not generate model class?-kotlin ... One common mistake when using Epoxy in Kotlin is mixing annotation processing engines.
Read more >Swipe to delete Epoxy tutorial | Android 2022 | Kotlin - YouTube
This video demonstrates how to implement the "swipe to dismiss" feature with Epoxy to allow our users to delete an item from the...
Read more >How to build your complex UI with Epoxy - Factory.dev
But no worries, Kotlin is very easy to learn. ... To be able to generate epoxy models from data binding add epoxy databinding...
Read more >Hibernate ORM 5.2.18.Final User Guide - Red Hat on GitHub
Hibernate not only takes care of the mapping from Java classes to ... It is the model that ultimately describes the problem domain...
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 Free
Top 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
Thanks a lot @elihart ! Works perfectly now 😄
2.17.0 is pushed and should be available in a few minutes. Please let me know if that works