airbnb / epoxy

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

No value passed for parameter #1332

Open zokirjonkodirov opened 1 year ago

zokirjonkodirov commented 1 year ago

In EpoxyModel i'm trying to pass data through constructor and not using @EpoxyAttribute annotation. Parameter has a default value. Before I was using kapt and there was no problem. When I switched to KSP there is such an error: No value passed for parameter 'isFullScreen'

Can't I use default parameter values?

@EpoxyModelClass(layout = R.layout.component_loading)
abstract class ProgressModel(
    private val isFullScreen: Boolean = false
) : EpoxyModelWithHolder<ProgressModel.ProgressHolder>() {

    inner class ProgressHolder : EpoxyHolder() {

        lateinit var binding: ComponentLoadingBinding
            private set

        override fun bindView(itemView: View) {
            binding = ComponentLoadingBinding.bind(itemView)

            itemView.layoutParams = itemView.layoutParams.apply {
                height = if (isFullScreen) MATCH_PARENT else WRAP_CONTENT
            }
        }
    }
}
viroth-ty commented 1 year ago

why not using EpoxyAttribute?

zokirjonkodirov commented 1 year ago

Not to generate extra methods. Just wanted to pass data through constructor. I don't know it's recommended way or not.

viroth-ty commented 1 year ago

I recommend to use EpoxyAttribute. Epoxy will generate the method to use in EpoxyController

oana-bejenaru commented 1 year ago

I have the same issue on my side. It worked before switching to ksp. Also lots of my epoxy models had a lot of declarations like

@EpoxyAttributes 
lateinit var title: String

Which are not working anymore either after switching to ksp. The app is crashing even though I don't try to access that variable.