Sami Issa
Sami Issa

Reputation: 1974

Kotlin + Parceler + Realm

I'm trying to integrate Parceler library in a Kotlin project with Realm, but I'm facing with problems when I try to adapt an entity to Realm and Parcel.

@Parcel(implementations = { EventRealmProxy::class.java },
        value = Parcel.Serialization.BEAN,
        analyze = { Event::class.java })
@RealmClass
open class Event : Serializable, RealmObject(){

    open var dislike : Boolean = false
    open var like : Boolean = false
    open var blocked : Boolean = false
    open var visits : Boolean = false

}

And this is the error:

Error:(13, 19) Type mismatch: inferred type is () -> Class<Event>
but Array<KClass<(raw) Any>> was expected

I'm trying to find some example of a Class defined with Realm and Parceler in Kotlin.

Upvotes: 0

Views: 612

Answers (2)

EpicPandaForce
EpicPandaForce

Reputation: 81529

@Parcel(implementations = { EventRealmProxy::class.java },

should have been

@Parcel(implementations = [EventRealmProxy::class.java],

Upvotes: 0

savepopulation
savepopulation

Reputation: 11921

I modified your code a little bit. Can you try this?

@Parcel(implementations = arrayOf(EventRealmProxy::class.java),
        value = Parcel.Serialization.BEAN,
        analyze = arrayOf(Event::class))
@RealmClass
open class Event : Serializable, RealmObject(){

    open var dislike : Boolean = false
    open var like : Boolean = false
    open var blocked : Boolean = false
    open var visits : Boolean = false

}

I'm not on my personal computer so i couldn't run code. If it's not working sorry for wasting your time. i'll try to improve my answer when i have time.

Upvotes: 1

Related Questions