question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Kotlin] Generated Epoxy Models not working anymore

See original GitHub issue

After updating from 2.14.0 to 2.15.1 or anything newer (tried up to 2.16.2) using the generated Models directly instead of their Kotlin extension function will throw an Cannot create an instance of an abstract class exception.

This is especially frustrating for carousels since the provided withModelsFrom(...) extension function expects you to use the generatedWhateverViewModel_().id(...)... instead of the extension function which returns Unit.

Example EpoxyModel:

@EpoxyModelClass(layout = R2.layout.ui_recyclerview_epoxy_shift)
abstract class ShiftEpoxyModel : EpoxyModelWithHolder<ShiftEpoxyModel.ShiftViewHolder>() {
    @EpoxyAttribute
    var day: String = ""

    @EpoxyAttribute
    @StringRes
    var dayRes: Int? = null

    @EpoxyAttribute
    var beginDate: Date = Date()

    @EpoxyAttribute
    var endDate: Date = Date()

    override fun bind(holder: ShiftViewHolder) {
        super.bind(holder)
        ...
    }

    class ShiftViewHolder : EpoxyHolder() {
        lateinit var dayTextView: TextView
        lateinit var dateTextView: TextView
        lateinit var timeTextView: TextView

        override fun bindView(itemView: View) {
            dayTextView = itemView.findViewById(R.id.day)
            dateTextView = itemView.findViewById(R.id.date)
            timeTextView = itemView.findViewById(R.id.time)
        }
    }
}

In the controller

 shift {
                id("123")
                beginDate(beginDate)
                endDate(endDate)
}

works just fine,

 add(ShiftEpoxyModel_()
                    .id("123")
                    .beginDate(beginDate)
                    .endDate(endDate))

throws an Cannot create an instance of an abstract class exception.

Same thing when trying to create a carousel like this:

carousel {
            id("shifts-carousel")
            withModelsFrom(data.offer!!.shifts) {
                ShiftEpoxyModel_()
                        .id(it.toString())
                        .beginDate(it.beginDate)
                        .endDate(it.endDate)
            }
        }

Am i missing something ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
pwillmanncommented, Sep 6, 2018

Thanks a lot @elihart ! Works perfectly now 😄

1reaction
elihartcommented, Sep 6, 2018

2.17.0 is pushed and should be available in a few minutes. Please let me know if that works

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Epoxy does not generate model class? - Stack Overflow
I want to use Epoxy for my recyclerView with kotlin, but Epoxy Model does not generate PostModel_() class, what wrong with it?
Read more >
[Solved]-Why Epoxy does not generate model class?-kotlin
[Solved]-Why Epoxy does not generate model class?-kotlin ... One common mistake when using Epoxy in Kotlin is mixing annotation processing engines.
Read more >
Swipe to delete Epoxy tutorial | Android 2022 | Kotlin - YouTube
This video demonstrates how to implement the "swipe to dismiss" feature with Epoxy to allow our users to delete an item from the...
Read more >
How to build your complex UI with Epoxy - Factory.dev
But no worries, Kotlin is very easy to learn. ... To be able to generate epoxy models from data binding add epoxy databinding...
Read more >
Hibernate ORM 5.2.18.Final User Guide - Red Hat on GitHub
Hibernate not only takes care of the mapping from Java classes to ... It is the model that ultimately describes the problem domain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found