airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.47k stars 731 forks source link

OnModelBoundListener is not getting called #1284

Closed sanginovs closed 2 years ago

sanginovs commented 2 years ago

Hi there

I extended OnModelBoundListener interface however i don't see onModelBound being called.

@EpoxyModelClass
abstract class SomeEpoxyModel : OnModelBoundListener<SomeEpoxyModel, View>, ViewBindingEpoxyModelWithHolder<SomeItemBinding>() {
    @EpoxyAttribute var someText: CharSequence? = null

    override fun SometemBinding.bind() {
        title.text = text
    }

    override fun onModelBound(model: SomeEpoxyModel?, view: View?, position: Int) {
        Log.d("Epoxy", "onModelBound called")
    }

    override fun getDefaultLayout(): Int = R.layout.moderation_content_item
}

The documentation of OnModelBoundListener says it's called immediately after a model was bound: Screen Shot 2022-03-15 at 5 30 26 PM

sanginovs commented 2 years ago

Never mind. Looks like i don't need to extend the interface. I can just do this during initialization of my model:

myModel {
     id("xyz")
     text("xyz")
     onBind { model, view, position ->
                    Log.d("Epoxy", "onModelBound called")
       }
}