I want to use Epoxy for my recyclerView with kotlin, but Epoxy Model does not generate PostModel_() class, what wrong with it?
@EpoxyModelClass(layout = R.layout.iteam)
abstract class PostModel : EpoxyModelWithHolder<PostModel.PostHolder>() {
@EpoxyAttribute
lateinit var userName: String
@EpoxyAttribute
lateinit var avatarIcon: Drawable
@EpoxyAttribute
lateinit var post: Drawable
override fun bind(holder: PostHolder) {
holder.avatarIcon.setImageDrawable(avatarIcon)
holder.post.setImageDrawable(post)
holder.name.text = userName
}
class PostHolder : BaseEpoxyHolder() {
@BindView(R.id.name)
lateinit var name: TextView
@BindView(R.id.ic_avatar)
lateinit var avatarIcon: ImageView
@BindView(R.id.post)
lateinit var post: ImageView
}
}
One common mistake when using Epoxy in Kotlin is mixing annotation processing engines. If you copied this from Epoxy's readme:
dependencies {
implementation 'com.airbnb.android:epoxy:3.x.y'
// Add the annotation processor if you are using Epoxy's annotations (recommended)
annotationProcessor 'com.airbnb.android:epoxy-processor:3.x.y'
}
You probably forgot to apply what they suggest for kotlin users few lines later in the same readme:
make sure to use kapt
instead of annotationProcessor
I mistakenly deleted the first line from my model file:
package com.myCustomDomain.myapp.epoxyModel
so the auto generated files were generated with wrong filename.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.