简体   繁体   English

环氧,Kotlin:使用@ModelView不会产生任何错误

[英]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 . 但不幸的是不是来自ModelView It builds without errors, but no generated epoxy classes around this: 它的构建没有错误,但是围绕此没有生成环氧树脂类:

@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. 对此进行了多种尝试以使其正确,但是构建日志中没有有用的错误。

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
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM