Epoxy, Kotlin: Using @ModelView generates nothing with no errors
Epoxy, Kotlin: Using @ModelView generates nothing with no errors
I'm successfully able to have epoxy generate code from this EpoxyModelClass
EpoxyModelClass
@EpoxyModelClass(layout = R.layout.card_sample)
abstract class PhotoModel : EpoxyModelWithHolder<PhotoModel.Holder>() {
@EpoxyAttribute
var title: String? = null
override fun bind(holder: PhotoModel.Holder) {
holder.header.text = title
}
class Holder : EpoxyHolder() {
override fun bindView(itemView: View) {
header = itemView.findViewById(R.id.header_label)
}
lateinit var header: TextView
}
}
but unfortunately not from a ModelView
. It builds without errors, but no generated epoxy classes around this:
ModelView
@ModelView
abstract class HeaderView : LinearLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
context,
attrs,
defStyle
)
private var titleProp: CharSequence? = null
@TextProp(defaultRes = R.string.app_name)
fun setTitle(title: CharSequence) {
titleProp = title
}
}
Tried many variations on this to get it right but there are no helpful errors in build logs.
1 Answer
1
Using open
on both functions and class instead of abstract
seems to work.
open
abstract
@ModelView(defaultLayout = R.layout.card_sample)
open class HeaderView : RelativeLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
context,
attrs,
defStyle
)
private var titleProp: CharSequence? = null
@TextProp(defaultRes = R.string.app_name)
open fun setTitle(string: CharSequence?) {
titleProp = string
}
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment